float x,y;
int i=0;
void setup(){
size(600,600);
x=100;
y=100;
noStroke();
}
void draw()
{
background(255,255,255);
for(int i=50;i>=0;i--){
fill(0,i*4,0);
rect(mouseX-i,mouseY-i,i*2,i*2);
}
if(++i==200) save("C:/sv.jpg");
}
2.物體跟著滑鼠動:
float x,y;
int i=0;
void setup(){
size(600,600);
x=100;
y=100;
noStroke();
}
void draw()
{
x+=(mouseX-x)/20.0;
y+=(mouseY-y)/20.0;
background(255,255,255);
for(int i=50;i>=0;i--){
fill(0,i*4,0);
rect(mouseX-i,mouseY-i,i*2,i*2);
}
fill(255,0,0);
ellipse(x,y,100,100);
}
3.
float x,y;
int i=0;
int rt=0;
void setup(){
size(600,600);
x=300;
y=300;
noStroke();
}
void pic()
{
//卡片底
strokeWeight(2);
stroke(131,199,252);
translate(5,419);
rotate(-PI/4);
fill(39,134,200);
rect(0,0,580,250,18,18);
rotate(PI/4);
translate(-5,-419);
//臉區
strokeWeight(0);
stroke(255,255,255);
translate(390,396);
rotate(-PI/4);
fill(254,251,242);
ellipse(0, 0, 500, 360);
rotate(PI/4);
translate(-396,-396);
//眼睛
strokeWeight(6);
stroke(39,134,200);
translate(235,315);
rotate(-PI/4);
fill(254,251,242);
ellipse(0, 0, 120, 150);
ellipse(120, 0, 120, 150);
rotate(PI/4);
translate(-235,-315);
//瞳孔
strokeWeight(12);
stroke(39,134,200);
translate(260,305);
rotate(-PI/4);
fill(254,251,242);
ellipse(0, 0, 20, 30);
ellipse(70, 0, 20, 30);
rotate(PI/4);
translate(-260,-305);
//鼻線
strokeWeight(6);
stroke(39,134,200);
translate(330,324);
rotate(PI/4);
line(0,0,90,0);
rotate(-PI/4);
translate(-330,-324);
//鼻子
strokeWeight(0);
stroke(234,4,31);
translate(330,324);
rotate(-PI/4);
fill(231,4,31);
ellipse(0, 0, 68, 68);
fill(255,255,255);
ellipse(-4, -10, 24, 24);
rotate(PI/4);
translate(-330,-324);
//鬍鬚
//left
strokeWeight(6);
stroke(39,134,200);
translate(158,483);
rotate(-PI/7.5);
line(0,0,150,0);
rotate(PI/7.5);
translate(-158,-483);
strokeWeight(6);
stroke(39,134,200);
translate(200,540);
rotate(-PI/4.34);
line(0,0,150,0);
rotate(PI/4.34);
translate(-200,-540);
//right
strokeWeight(6);
stroke(39,134,200);
translate(414,299);
rotate(-PI/7.5-PI/5);
line(0,0,150,0);
rotate(PI/7.5+PI/5);
translate(-414,-299);
strokeWeight(6);
stroke(39,134,200);
translate(434,319);
rotate(-PI/3.85);
line(0,0,150,0);
rotate(PI/3.85);
translate(-434,-319);
//卡片底線
strokeWeight(2);
stroke(205);
translate(215,568);
rotate(-PI/4);
line(0,0,500,0);
rotate(PI/4);
translate(-215,-568);
}
float[] xsite = new float[20];
float[] ysite = new float[20];
void draw()
{
background(0);
translate(300,300);
rotate(++rt%3600/100.0);
noStroke();
for(int i=0;i<600;i++){
fill(255-i/600.0*255,255,255-i/600.0*255);
triangle(300*cos(i/72.0),300*sin(i/72.0),300*cos((i+1)/72.0),300*sin((i+1)/72.0),0,0);
}
rotate(-rt%3600/100.0);
stroke(0);
strokeWeight(1);
noFill();
line(-300,0,300,0);
line(0,-300,0,300);
ellipse(0,0,200,200);
ellipse(0,0,300,300);
ellipse(0,0,400,400);
ellipse(0,0,500,500);
delay(10);
translate(-300,-300);
noStroke();
x+=(mouseX-x)/20.0;
y+=(mouseY-y)/20.0;
for(int i=50;i>=0;i--){
fill(0,i*4,i*4);
ellipse(mouseX,mouseY,i*2,i*2);
}
xsite[19]=mouseX;
ysite[19]=mouseY;
for(int i=0;i<19;i++){
fill(0,i*10,i*10);
ellipse(xsite[i],ysite[i],20,20);
xsite[i]=xsite[i+1];
ysite[i]=ysite[i+1];
}
translate(x-70,y-70);
scale(0.2,0.2);
pic();
scale(5,5);
translate(-x+70,-y+70);
}
4.心得:
經過這三周學習後的感覺,Processing相較先前所璇是比較平易近人......
目前學習起來感覺很輕鬆也很有趣,能夠不用像opengl這樣多的程式碼,卻能達到相同的效果。
未來希望能夠交更多一些很炫的功能、特效,或是一些應用,我想是沒問題的。
3.
float x,y;
int i=0;
int rt=0;
void setup(){
size(600,600);
x=300;
y=300;
noStroke();
}
void pic()
{
//卡片底
strokeWeight(2);
stroke(131,199,252);
translate(5,419);
rotate(-PI/4);
fill(39,134,200);
rect(0,0,580,250,18,18);
rotate(PI/4);
translate(-5,-419);
//臉區
strokeWeight(0);
stroke(255,255,255);
translate(390,396);
rotate(-PI/4);
fill(254,251,242);
ellipse(0, 0, 500, 360);
rotate(PI/4);
translate(-396,-396);
//眼睛
strokeWeight(6);
stroke(39,134,200);
translate(235,315);
rotate(-PI/4);
fill(254,251,242);
ellipse(0, 0, 120, 150);
ellipse(120, 0, 120, 150);
rotate(PI/4);
translate(-235,-315);
//瞳孔
strokeWeight(12);
stroke(39,134,200);
translate(260,305);
rotate(-PI/4);
fill(254,251,242);
ellipse(0, 0, 20, 30);
ellipse(70, 0, 20, 30);
rotate(PI/4);
translate(-260,-305);
//鼻線
strokeWeight(6);
stroke(39,134,200);
translate(330,324);
rotate(PI/4);
line(0,0,90,0);
rotate(-PI/4);
translate(-330,-324);
//鼻子
strokeWeight(0);
stroke(234,4,31);
translate(330,324);
rotate(-PI/4);
fill(231,4,31);
ellipse(0, 0, 68, 68);
fill(255,255,255);
ellipse(-4, -10, 24, 24);
rotate(PI/4);
translate(-330,-324);
//鬍鬚
//left
strokeWeight(6);
stroke(39,134,200);
translate(158,483);
rotate(-PI/7.5);
line(0,0,150,0);
rotate(PI/7.5);
translate(-158,-483);
strokeWeight(6);
stroke(39,134,200);
translate(200,540);
rotate(-PI/4.34);
line(0,0,150,0);
rotate(PI/4.34);
translate(-200,-540);
//right
strokeWeight(6);
stroke(39,134,200);
translate(414,299);
rotate(-PI/7.5-PI/5);
line(0,0,150,0);
rotate(PI/7.5+PI/5);
translate(-414,-299);
strokeWeight(6);
stroke(39,134,200);
translate(434,319);
rotate(-PI/3.85);
line(0,0,150,0);
rotate(PI/3.85);
translate(-434,-319);
//卡片底線
strokeWeight(2);
stroke(205);
translate(215,568);
rotate(-PI/4);
line(0,0,500,0);
rotate(PI/4);
translate(-215,-568);
}
float[] xsite = new float[20];
float[] ysite = new float[20];
void draw()
{
background(0);
translate(300,300);
rotate(++rt%3600/100.0);
noStroke();
for(int i=0;i<600;i++){
fill(255-i/600.0*255,255,255-i/600.0*255);
triangle(300*cos(i/72.0),300*sin(i/72.0),300*cos((i+1)/72.0),300*sin((i+1)/72.0),0,0);
}
rotate(-rt%3600/100.0);
stroke(0);
strokeWeight(1);
noFill();
line(-300,0,300,0);
line(0,-300,0,300);
ellipse(0,0,200,200);
ellipse(0,0,300,300);
ellipse(0,0,400,400);
ellipse(0,0,500,500);
delay(10);
translate(-300,-300);
noStroke();
x+=(mouseX-x)/20.0;
y+=(mouseY-y)/20.0;
for(int i=50;i>=0;i--){
fill(0,i*4,i*4);
ellipse(mouseX,mouseY,i*2,i*2);
}
xsite[19]=mouseX;
ysite[19]=mouseY;
for(int i=0;i<19;i++){
fill(0,i*10,i*10);
ellipse(xsite[i],ysite[i],20,20);
xsite[i]=xsite[i+1];
ysite[i]=ysite[i+1];
}
translate(x-70,y-70);
scale(0.2,0.2);
pic();
scale(5,5);
translate(-x+70,-y+70);
}
4.心得:
經過這三周學習後的感覺,Processing相較先前所璇是比較平易近人......
目前學習起來感覺很輕鬆也很有趣,能夠不用像opengl這樣多的程式碼,卻能達到相同的效果。
未來希望能夠交更多一些很炫的功能、特效,或是一些應用,我想是沒問題的。
100
回覆刪除