//week06-1
void setup(){
size(500,500, P3D);
}
void draw(){
background(142);
ellipse(width/2, height/2, 200, 200);
translate(width/2, height/2); //至中用
pushMatrix();
if(mousePressed) rotateZ(radians(frameCount)); //按一下才會轉
box(100,30,30);
popMatrix();
}
------------------------------------------------------------------------------------------------
//week06-2 中心改新圖
void setup(){
size(500,500, P3D);
}
void draw(){
background(142);
ellipse(width/2, height/2, 200, 200);
translate(width/2, height/2); //至中用
pushMatrix();
if(mousePressed) rotateZ(radians(frameCount)); //按一下才會轉
translate(-50,0,0); //把box移到左方 讓一邊成為圓心點
box(100,30,30);
popMatrix();
}
--------------------------------------------------------------------------------------
//week06-3
void setup(){
size(500,500, P3D);
}
void draw(){
background(142);
ellipse(width/2, height/2, 200, 200);
translate(width/2, height/2); //至中用
pushMatrix();
translate(x, y);
if(mousePressed && mouseButton==RIGHT) {
rotateZ(radians(frameCount));
} //按一下才會轉
translate(-50,0,0); //把box移到左方 讓一邊成為圓心點
box(100,30,30);
popMatrix();
}
float x = 0, y = 0;
void mouseDragged(){
x += mouseX - pmouseX;
y += mouseX - pmouseY;
}
---------------------------------------------------------------------------------
//week06-4 機械手臂
void setup(){
size(500,500,P3D);
}
void draw(){
background(255);
translate(width/2, height/2);
sphere(10); //參考用圓球
box(200,50,25); //機械手臂一號 手肘部位
fill(252,131,77);
pushMatrix();
translate(x,y);
if(mousePressed) rotateZ(radians(frameCount)); //6-3的概念
translate(25,0,0);
box(50,25,50);
popMatrix();
}
float x = 0, y =0;
void mouseDragged(){
x += mouseX - pmouseX;
y += mouseY - pmouseY;
println("x:" + x + "y:" + y);
}
---------------------------------------------------------------------------------------
//week06-5 機械手臂-2
void setup(){
size(500,500,P3D);
}
void draw(){
background(255);
translate(width/2, height/2);
sphere(10); //參考用圓球
fill(252,131,77);
pushMatrix();
translate(x,y);
box(200,50,25);//機械手臂一號 手肘部位
pushMatrix();
translate(100,0); //固定手臂一號
//if(mousePressed) rotateZ(radians(frameCount)); //6-3的概念
rotateZ(radians(frameCount)); //把上面的改成自動轉動
translate(25,0,0);
box(50,25,50);
popMatrix();
popMatrix();
}
float x = 0, y =0;
void mouseDragged(){
x += mouseX - pmouseX;
y += mouseY - pmouseY;
println("x:" + x + "y:" + y);
}
----------------------------------------------------------------------------------
//week06-6 機械手臂-3
void setup(){
size(500,500,P3D);
}
void draw(){
background(255);
translate(width/2, height/2);
sphere(10);
fill(252,131,77);
pushMatrix();
box(50,200,25);
pushMatrix();
translate(x,y);
if(mousePressed) rotateZ(radians(frameCount));
translate(100,0);
box(200,50,25);//機械手臂一號 手肘部位
pushMatrix();
translate(100,0); //固定手臂一號
rotateZ(radians(frameCount)); //把上面的改成自動轉動
translate(25,0,0);
box(50,25,50);
popMatrix();
popMatrix();
popMatrix();
}
float x = 0, y =0;
void mouseDragged(){
x += mouseX - pmouseX;
y += mouseY - pmouseY;
println("x:" + x + "y:" + y);
}
------------------------------------------------------------------------------------
沒有留言:
張貼留言