04.04.2013 Views

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

PROCESSING: CREATIVE CODING AND COMPUTATIONAL ART<br />

348<br />

conditional statement. Since I increased the value of p[0].x each time the function executed,<br />

I used the conditional to ensure that p[0].x would never exceed the midpoint of<br />

the display window. Next, I’ll add a gradient blur effect to the sketch (see Figure 9-8):<br />

//Triangle Blur<br />

Point[]p = new Point[3];<br />

float shift = 2;<br />

float fade = 0;<br />

float fillCol = 0;<br />

void setup(){<br />

size(400, 400);<br />

background(0);<br />

smooth();<br />

fade = 255.0/(width/2.0/shift);<br />

p[0] = new Point(1, height-1);<br />

p[1] = new Point(width-1, height-1);<br />

p[2] = new Point(width/2, 1);<br />

noStroke();<br />

triBlur();<br />

}<br />

void triBlur(){<br />

fill(fillCol);<br />

fillCol+=fade;<br />

triangle(p[0].x+=shift, p[0].y-=shift/2, p[1].x-=shift, ➥<br />

p[1].y-=shift/2, p[2].x, p[2].y+=shift);<br />

if(p[0].x

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!