We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexSuggestions & BugsWebsite,  Documentation,  Book Bugs › error in embedded iteration example - have fix
Page Index Toggle Pages: 1
error in embedded iteration example - have fix (Read 537 times)
error in embedded iteration example - have fix
Mar 15th, 2008, 10:03pm
 
A simple bug in the embedded iteration example.
The height and width were swapped.  I've fixed this, and also added an 'if' statement to catch negative box sizes.
I've pasted the fixed code below:

float box_size = 11;
float box_space = 12;
int margin = 7;

size(200,200);
background(0);
noStroke();

//draw gray boxes

for(int i = margin; i < height-margin; i += box_space){
 if(box_size>0){
   for(int j = margin; j < width-margin; j+= box_space){
     fill(255-box_size*10);
     rect(j, i, box_size, box_size);
   }
   box_size = box_size - 0.6;
 }
}
Re: error in embedded iteration example - have fix
Reply #1 - Mar 27th, 2008, 5:04am
 
Thank you. The change is made in the master file.
Page Index Toggle Pages: 1