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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Notice that you can make the value of cellWidth different than the value of cellHeight,<br />

creating an alternative grid (see Figure 6-12). Finally, let’s add some r<strong>and</strong>om() functions<br />

throughout the program.<br />

Figure 6-12. Alternative grid made from points<br />

One of the advantages of generating a line this way, using adjacent points, is the ability to<br />

alter the spacing of the points, as in the next example (see Figure 6-13):<br />

/*<br />

Point Grid<br />

Ira Greenberg, November 20, 2005<br />

*/<br />

size(300, 300);<br />

background(0);<br />

// grid variables<br />

int cellWidth = width/20;<br />

int cellHeight = height/20;<br />

int ptGap = 3;<br />

int r<strong>and</strong>Ht = 4;<br />

int r<strong>and</strong>Wdth = 10;<br />

stroke(255);<br />

//vertical lines<br />

for (int i=cellWidth; i

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

Saved successfully!

Ooh no, something went wrong!