topical media & game development

talk show tell print

graphic-processing-site-examples-Basics-Control-EmbeddedIteration-EmbeddedIteration.pde / pde



  
Embedding Iteration. Embedding "for" structures allows repetition in two dimensions.

  
   
  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;
    }
  }
  
                  
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.