課堂作業一
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);
}
課堂作業二
void setup(){
size(600,300);
}
void draw(){
background(#C0FFEE);
for(int x=150;x<=450;x+=300){//用迴圈做出兩組眼睛
ellipse(x,150,100,100);
float dx=mouseX-x,dy=mouseY-150;
float a=atan2(dy,dx);
ellipse(x+cos(a)*25,150+sin(a)*25,50,50);
}
}
課堂作業三
void setup(){
size(400,400,P3D);
}
void draw(){
background(128);
translate(width/2,height/2);
//rotateY(radians(mouseX));//上周的左右轉
rotateX(radians(-mouseY));//本周的上下轉
box(200);
}
課堂作業四
void setup(){
size(400,400,P3D);
}
void draw(){
background(128);
translate(width/2,height/2);
//rotateY(radians(mouseX));//上周的左右轉
rotateZ(radians(-mouseX));
ellipse(0,0,100,150);
}
課堂作業五
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();
}
課堂作業五a
void setup(){
size(400,400,P3D);
}
void draw(){
background(128);
translate(width/2,height/2);//移到畫面中心
rotateZ(radians(-mouseX));//對Z軸旋轉
translate(0,-50);//把下端移到中心
box(10,100,10);//可轉動的長條
}
課堂作業五b
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);//可轉動的長條
}
課堂作業六
void setup(){
size(400,400,P3D);
}
void draw(){
background(128);
pushMatrix();
translate(mouseX,mouseY);
rotateY(radians(frameCount));
sphere(100);
popMatrix();
}
課堂作業七
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();
}
課堂作業八
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();
}
課堂作業九
PImage img=loadImage("earth.jpg");
size(600,300);
image(img,0,0,600,300);
課堂作業十
size(400,400,P3D);
PShape earth =createShape(SPHERE,100);
PImage img = loadImage("earth.jpg");
earth.setTexture(img);
shape(earth);
課堂作業十一
PShape earth;
void setup(){
size(400,400,P3D);
earth =createShape(SPHERE,100);
PImage img = loadImage("earth.jpg");
earth.setTexture(img);
}
void draw(){
background(0);
translate(width/2,height/2);
rotateY(radians(frameCount));
shape(earth);
}
課堂作業十二
PShape moon;
void setup(){
size(400,400,P3D);
moon =createShape(SPHERE,100);
PImage img = loadImage("moon.jpg");
moon.setTexture(img);
}
void draw(){
background(0);
translate(width/2,height/2);
rotateY(radians(frameCount));
shape(moon);
}
課堂作業十三
PShape sun;
void setup(){
size(400,400,P3D);
sun =createShape(SPHERE,100);
PImage img = loadImage("sun.jpg");
sun.setTexture(img);
}
void draw(){
background(0);
translate(width/2,height/2);
//rotateY(radians(frameCount));
shape(sun);
}
課堂作業十四
PShape sun,earth,moon;
//樓下剪貼自week04-8樓上是week04-11-12-13
void setup(){
size(400,400,P3D);
sun =createShape(SPHERE,50);
PImage img = loadImage("sun.jpg");
sun.setTexture(img);
earth =createShape(SPHERE,30);
img = loadImage("earth.jpg");
earth.setTexture(img);
moon =createShape(SPHERE,10);
img = loadImage("moon.jpg");
moon.setTexture(img);
}
void draw(){
background(128);
translate(width/2,height/2);
shape(sun);//sphere(50);//太陽
rotateY(radians(frameCount));
pushMatrix();
translate(150,0);
rotateY(radians(frameCount));
shape(earth);//sphere(30);//地球
pushMatrix();
translate(50,0);
rotateY(radians(frameCount));
shape(moon);//sphere(10);//月球
popMatrix();
popMatrix();
}
沒有留言:
張貼留言