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.
Page Index Toggle Pages: 1
Loop 3D shapes (Read 852 times)
Loop 3D shapes
Oct 3rd, 2009, 8:19am
 
Hi there,

I want to create the following sketch with boxes instead of rects:

int x=0;
int y=0;
void setup(){
 size(500,500);}
void draw(){
 background(200);
 for(x=0;x<width;x+=15)
  for(y=0;y<height;y+=15){
   rect(x,y,10,10);}
}

I tried translate with x and y co-ordinates but didn't work. All I want is boxes in x and y axes, with equal distance. Any ideas?
Re: Loop 3D shapes
Reply #1 - Oct 3rd, 2009, 12:11pm
 
Quote:
int x=0;
int y=0;
void setup(){
 size(500,500, P3D);}
void draw(){
 background(0);
 
 for(x=-width/2;x<width;x+=15){
   resetMatrix();
   translate(x, -height/2, -300);
  for(y=0;y<height;y+=15)
  {
    translate(0, 15, 0);
   box(5,5,5);
 }
 }
}

Page Index Toggle Pages: 1