//week04-1-atan
void setup(){
size(600,300);
}
void draw(){
background(#C0FFEE);
ellipse(150,150,100,100);
//ellipse(150+25,150,50,50);
float dx=mouseX-150,dy=mouseY-150;
float a=atan2(dy,dx);
ellipse(150+cos(a)*25,150+sin(a)*25,50,50);
}
//week04-2-atan
void setup(){
size(600,300);
}
void draw(){
background(#C0FFEE);
for(int x=150;x<=450;x+=300){
ellipse(x,150,100,100);
//ellipse(150+25,150,50,50);
float dx=mouseX-x,dy=mouseY-150;
float a=atan2(dy,dx);
ellipse(x+cos(a)*25,150+sin(a)*25,50,50);
}
}
//week04-5-robot-arm
void setup(){
size(400,400,P3D);
}
void draw(){
background(128);
translate(width/2,height/2);
pushMatrix();
translate(0,100);
box(50);//台座
pushMatrix();
translate(0,-25);
rotateZ(radians(mouseX));
translate(0,-50);
box(10,100,10);
popMatrix();
popMatrix();
//week04_05a_rotateZ_translate_box void setup(){ size(400,400,P3D); } void draw(){ background(128); //translate(width/2,height/2);//移到畫面中心 //以下兩行分別註解,排列組合觀察 translate(mouseX,mouseY); rotateZ(radians(frameCount)); //對Z軸旋轉 translate(0,-50); //把下端移到中心 box(10,100,10);//可轉動的長條 }//week04_05b_rotateZ_translate_boxvoid setup(){ size(400,400,P3D); } void draw(){ background(128); //translate(width/2,height/2);//移到畫面中心 //以下兩行分別註解,排列組合觀察 translate(mouseX,mouseY); rotateZ(radians(frameCount)); //對Z軸旋轉 translate(0,-50); //把下端移到中心 box(10,100,10);//可轉動的長條 }
//week04-6 void setup(){ size(400,400,P3D); } void draw(){ background(128); pushMatrix(); translate(mouseX,mouseY); rotateY(radians(frameCount)); sphere(100); popMatrix(); }
//week04-7-sun void setup(){ size(400,400,P3D); } void draw(){ background(128); translate(width/2,height/2); sphere(50); rotateY(radians(frameCount)); pushMatrix(); translate(150,0); rotateY(radians(frameCount)); sphere(30); popMatrix(); }
//week04-8-sun void setup-(){
size(400,400,P3D); } void draw(){ background(128); translate(width/2,height/2); sphere(50); rotateY(radians(frameCount)); pushMatrix(); translate(150,0); rotateY(radians(frameCount)); sphere(30); pushMatrix(); translate(50,0); rotateY(radians(frameCount)); sphere(10); popMatrix(); popMatrix(); }
//week04-9-earth //google:earth map texture 下載一張地球的地圖 //把圖檔拉到城市裡面 PImage img=loadImage("earth.jpg"); size(600,300); image(img,0,0,600,300);//week04-10-earth size(400,400,P3D); PShape earth=createShape(SPHERE,100); PImage img=loadImage("earth.jpg"); earth.setTexture(img); shape(earth);












沒有留言:
張貼留言