Rotation on vertex
in
Programming Questions
•
3 years ago
So I'm trying to rotate each of the individual squares on its upper left corer, but when I implement the rotate the command it just rotates the entire row. Can anybody tell help? My professor and I were stumped.
Thanks
B.S.T.
void setup()
{
size (1000,600);
int X;
int Y;
int X_c,Y_c;
for(Y=0;Y<30;Y++)
{
for(X=0;X<30;X++)
{
X_c=X*100;
Y_c=Y*90;
if(Y%2==0)
{
if(X%2==1)
{
pushMatrix();
translate(X_c,Y_c);
rotate(radians(45));
stroke(0,0,255);
strokeWeight(2);
rect(X_c,Y_c,100,90);
rotate(radians(0));
popMatrix();
}
else
{
pushMatrix();
translate(X_c,Y_c);
rotate(radians(45));
stroke(255,0,0);
strokeWeight(2);
rect(X_c,Y_c,100,90);
rotate(radians(0));
popMatrix();
}
}
else
{
if(X%2==1)
{
pushMatrix();
translate(X_c,Y_c);
rotate(radians(45));
stroke(255,0,0);
strokeWeight(2);
rect(X_c,Y_c,100,90);
rotate(radians(0));
popMatrix();
}
else
{
pushMatrix();
translate(X_c,Y_c);
rotate(radians(45));
stroke(0,0,255);
strokeWeight(2);
rect(X_c,Y_c,100,90);
rotate(radians(0));
popMatrix();
}
}
}
}
}
1
