2020/09/14
(一)畫線、畫圓、畫方,利用函式及座標畫出想要的形狀
1.畫線 line(x1,y1,x2,y2); //點到點畫線
2.畫圓 ellipse(x1,y1,width,height); //左上角的點(x1,y1)畫width,height的圓
3.畫方
法一:
rect(x1,y1,width,height); // processing預設的
法二:
rectMode(CORNERS);
rect(x1,y1,x2,y2);
rectMode(RADIUS);
4.color: 屬於Hexadecimal notation的部分
RGB:
colorMode(RGB);
fill(R,G,B);
HSB:
colorMode(HSB);
fill(H,S,B);
//fill(#FF0000,alpha)
//可以有alpha值
my penguin project:
int y=125,x=235;
void setup(){
background(0);
size(400,400);
colorMode(RGB);
fill(180,125,155);
stroke(255);
rect(50,50,300,300,10);//big rect
colorMode(RGB);
fill(#FFFF00,100);
stroke(255);
rect(100,100,200,200,15);//small rect
//eyebrown
fill(255);
rect(120,130,50,20);
rect(230,130,50,20);
fill(155);
stroke(255);
ellipse(250,200,50,50);//right eye
ellipse(150,200,50,50);//left eye
fill(0);
ellipse(250,200,30,30);//right eye
ellipse(150,200,30,30);//left eye
fill(#FF0000);
ellipse(200,250,60,30);//mouth
}
void draw(){
//eyebrown
stroke(0);
for(int i=x;i<280;i+=5){
line(i,130,i,150);
}
for(int m=y;m<170;m+=5){
line(m,130,m,150);
}
}
沒有留言:
張貼留言