第一個作業
int value = 0;
void setup(){
size(600,600);
}
void draw(){
fill(0,0,0);
ellipse(mouseX,mouseY,10,10);
}
void mousePressed(){
fill(value);
ellipse(mouseX,mouseY,100,100);
}
void mouseReleased(){
fill(100,0,100);
ellipse(mouseX,mouseY,10,100);
}
void mouseMoved(){
value = value + 5;
if (value > 255) {
value = 0;
}
}
黑色小圓球可以跟著回署一直畫,當滑鼠點下去會產生不固定色的大圓球(白色、灰色、黑色),滑鼠放開會產生紫色橢圓。
void setup(){
size(600,600);
}
float x=100,y=100;
void draw(){
background(0,0,0);
fill(100,0,255);
rect(x+65,y-20,100,100);
fill(255,255,255);
rect(x+85,y+30,60,10);
fill(255,255,255);
ellipse(x+85,y,20,20);
ellipse(x+145,y,20,20);
fill(255,0,0);
ellipse(mouseX,mouseY,50,50);
translate(x,y);
myball();
x=x*0.8 + mouseX*0.1;
y=y*0.8 + mouseY*0.1;
}
void myball(){
scale(0.5,0.5);
noStroke();
smooth();
fill(0,64,128);
ellipse(230,308,430,430);//底圓1
noStroke();
smooth();
fill(117,186,255);
ellipse(230,308,410,410);//底圓2
noStroke();
smooth();
fill(0,186,255);
ellipse(230,308,305,305);//底圓3
noStroke();
smooth();
fill(255,255,255);
ellipse(230,308,285,285);//底圓4
/* ------------------------------------------------------*/
noStroke();
smooth();
fill(0,128,192);
ellipse(231,190,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(231,190,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(231,190,12,12);//淺藍 小圓1
noStroke();
smooth();
fill(0,128,192);
ellipse(265,195,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(265,195,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(265,195,12,12);//淺藍 小圓2
noStroke();
smooth();
fill(0,128,192);
ellipse(190,195,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(190,195,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(190,195,12,12);//淺藍 小圓2
noStroke();
smooth();
fill(0,128,192);
ellipse(295,210,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(295,210,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(295,210,12,12);//淺藍 小圓3
noStroke();
smooth();
fill(0,128,192);
ellipse(160,215,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(160,215,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(160,215,12,12);//淺藍 小圓3
noStroke();
smooth();
fill(0,128,192);
ellipse(323,233,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(323,233,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(323,233,12,12);//淺藍 小圓4
noStroke();
smooth();
fill(0,128,192);
ellipse(137,240,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(137,240,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(137,240,12,12);//淺藍 小圓4
noStroke();
smooth();
fill(0,128,192);
ellipse(343,263,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(343,263,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(343,263,12,12);//淺藍 小圓5
noStroke();
smooth();
fill(0,128,192);
ellipse(120,275,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(120,275,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(120,275,12,12);//淺藍 小圓5
/* ------------------------------------------------------*/
noStroke();
smooth();
fill(0,128,192);
ellipse(350,297,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(350,297,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(350,297,12,12);//淺藍 小圓6 mid
noStroke();
smooth();
fill(0,128,192);
ellipse(120,310,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(120,310,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(120,310,12,12);//淺藍 小圓6 mid
/* ------------------------------------------------------*/
noStroke();
smooth();
fill(0,128,192);
ellipse(345,330,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(345,330,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(345,330,12,12);//淺藍 小圓7
noStroke();
smooth();
fill(0,128,192);
ellipse(125,345,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(125,345,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(125,345,12,12);//淺藍 小圓7
noStroke();
smooth();
fill(0,128,192);
ellipse(330,365,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(330,365,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(330,365,12,12);//淺藍 小圓8
noStroke();
smooth();
fill(0,128,192);
ellipse(140,375,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(140,375,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(140,375,12,12);//淺藍 小圓8
noStroke();
smooth();
fill(0,128,192);
ellipse(308,395,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(308,395,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(308,395,12,12);//淺藍 小圓9
noStroke();
smooth();
fill(0,128,192);
ellipse(160,400,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(160,400,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(160,400,12,12);//淺藍 小圓9
noStroke();
smooth();
fill(0,128,192);
ellipse(275,415,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(275,415,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(275,415,12,12);//淺藍 小圓10
noStroke();
smooth();
fill(0,128,192);
ellipse(195,415,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(195,415,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(195,415,12,12);//淺藍 小圓10
noStroke();
smooth();
fill(0,128,192);
ellipse(235,420,29,29);//深藍
noStroke();
smooth();
fill(255,255,255);
ellipse(235,420,20,20);//白
noStroke();
smooth();
fill(117,186,255);
ellipse(235,420,12,12);//淺藍 小圓11
/* ------------------------------------------------------*/
noStroke();
smooth();
fill(0,118,174);
ellipse(230,308,165,165);//底圓5
noStroke();
smooth();
fill(0,64,128);
ellipse(230,308,120,120);//底圓6
noStroke();
smooth();
fill(117,186,255);
ellipse(230,308,100,100);//底圓7
noStroke();
smooth();
fill(0,64,128);
ellipse(230,308,60,60);//底圓8
noStroke();
smooth();
fill(255,255,255);
ellipse(230,308,30,30);//底圓9
跟著滑鼠移動的紅點,和跟著紅點移動的蝸牛
}
心得:
今天的上課學用滑鼠作變化,圖案跟著滑鼠移動還有我自己查到的當滑鼠按下跟放開的時候有另外的變化,以及將之前第一周的作業如何包成一個函式運用在別的地方做放大縮小和移動的變化。
沒有留言:
張貼留言