上节介绍了基本管理变换参数的方法,这节继续升入。
首先看这样一个例子:
void setup()
{
size(600, 600);
frameRate(60);
smooth();
}
void draw()
{
background(250);
Draw_Ellipse(width/2,height/2,0,100);
pushMatrix();
translate(width/2,height/2);
rotate(radians(frameCount));
Draw_Ellipse(100,0,0,60);
popMatrix();
pushMatrix();
translate(width/2,height/2);
rotate(radians(-frameCount));
Draw_Rect(200,0,frameCount*2,60);
popMatrix();
}
void Draw_Ellipse(float x, float y, int v, int r)
{
pushMatrix();
translate(x, y);
rotate(radians(v));
ellipse(0, 0, r, r);
popMatrix();
}
void Draw_Rect(float x, float y, int v, int r)
{
pushMatrix();
translate(x, y);
rotate