week06_1
//week06_1_ellipse_translate_push_rotate_box_pop
void setup(){
size(500, 500, P3D);
}
void draw(){
background(142);
ellipse(width/2, height/2, 200, 200);
translate(width/2, height/2); //把東西放到畫面中心
pushMatrix(); //第五周教過的matrix保護
//改移下,要按下mouse才轉給你看
if(mousePressed) rotateZ(radians(frameCount)); //對著下面中心旋轉
box(100, 30, 30); //橫的棒子
popMatrix(); //第五周教過的matrix保護
}
//week06_2_ellipse_translate_push_rotate_translate_box_pop void setup(){ size(500, 500, P3D); } void draw(){ background(142); ellipse(width/2, height/2, 200, 200); translate(width/2, height/2); //把東西放到畫面中心 pushMatrix(); //第五周教過的matrix保護 if(mousePressed) rotateZ(radians(frameCount)); //對著下面中心旋轉 translate(-50, 0, 0);//把棒子往左移一半,讓右端在正中心 box(100, 30, 30); //橫的棒子 popMatrix(); //第五周教過的matrix保護 }
week06_3
//week06_3_push_translate_rotate_translate_box_pop void setup(){ size(500, 500, P3D); } void draw(){ background(142); ellipse(width/2, height/2, 200, 200); translate(width/2, height/2); //把東西放到畫面中心 pushMatrix(); //第五周教過的matrix保護 translate(x, y); if(mousePressed && mouseButton==RIGHT){ rotateZ(radians(frameCount)); //對著下面中心旋轉 } translate(-50, 0, 0);//把棒子往左移一半,讓右端在正中心 box(100, 30, 30); //橫的棒子 popMatrix(); //第五周教過的matrix保護 } float x = 0, y = 0; void mouseDragged(){ x += mouseX - pmouseX; y += mouseY - pmouseY; }
week06_4
//week06_4_sphere_box_push_T_R_T_box_pop void setup(){ size(500, 400, P3D); } void draw(){ background(255);//step00 translate(width/2, height/2);//step00 sphere(10); //step 放圓球 box(200, 50, 25); //step05手肘 fill(252,131,77); pushMatrix(); //step03 translate(x, y);//step06 發現放100, 0 很好 if(mousePressed) rotateZ(radians(frameCount)); //step 03 translate(25, 0, 0);//step02 往右推讓左端放中心 box(50, 25, 50); //step01 popMatrix(); //step03 } float x = 0, y= 0;//step 06會動的位置 void mouseDragged(){//step06 x += mouseX - pmouseX; y += mouseY - pmouseY; println("x:" + x + " y:" + y); //step07 印出來 } week06_5
//week06_5_push_T_box_push_T_R_T_box_pop void setup(){ size(500, 400, P3D); } void draw(){ background(255); translate(width/2, height/2); sphere(10); fill(252,131,77); pushMatrix();//step04 new一組 translate(x, y);//step05 new轉動 box(200, 50, 25);//step05 手肘 pushMatrix();//step03 translate(100, 0);//step01 把剛剛前一步發現的100, 0放好 rotateZ(radians(frameCount)); //step02 只轉動 translate(25, 0, 0);//往右推讓左端放中心 box(50, 25, 50);//小手腕 popMatrix();//step03 把程式往右縮排 popMatrix();//step04 new一組 } float x = 0, y= 0; //會動的位置 void mouseDragged(){ x += mouseX - pmouseX; y += mouseY - pmouseY; println("x:" + x + " y:" + y); }
week06_6//week06_6_push_box_push_TRT_box_push_TRT_box_pop_pop_pop void setup(){ size(500, 400, P3D); } void draw(){ background(255); translate(width/2, height/2); sphere(10); fill(252,131,77); pushMatrix();//step04 push //step05 tab box(50, 200, 25);//step03 手臂 pushMatrix(); translate(x, y); //step 03 掛到手臂上面,觀察0, -100 if(mousePressed) rotateZ(radians(frameCount));//step02 把旋轉放入 translate(100, 0);//step01 把手肘的移動量100, 0放入 box(200, 50, 25);//手肘 pushMatrix(); translate(100, 0); rotateZ(radians(frameCount)); translate(25, 0, 0); box(50, 25, 50);//小手腕 popMatrix(); popMatrix(); popMatrix();//step04 pop } float x = 0, y= 0; void mouseDragged(){ x += mouseX - pmouseX; y += mouseY - pmouseY; println("x:" + x + " y:" + y); }
week06_7//week06_7_push_RRT_many_TRT_inside_pop void setup(){ size(500, 800, P3D);//step00 放大視窗 } void draw(){ background(255); translate(width/2, height/2); sphere(10);//中心 fill(252,131,77); pushMatrix(); if(mousePressed && mouseButton==RIGHT) rotateY(radians(frameCount));//step03 右鍵旋轉 if(mousePressed && mouseButton==RIGHT) rotateZ(radians(frameCount));//step02 右鍵旋轉 translate(0, -100);//translate(x, y);//step01 要往上抬升 把關節到中心 box(50, 200, 25);// 手臂 pushMatrix(); translate(0, -100); //step00 掛到手臂上觀察到0,-100 //if(mousePressed) //step00 讓他一直轉 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); }







沒有留言:
張貼留言