注意:
size(w,h); //頁面大小
line(x,y,x,y); //線
rect(x,y,w,h); //矩形
circle(x,y,r); //圓形
ellipse(x,y,w,h); //橢圓
fill(R,G,B); //在矩形,圓形...等裡面的顏色
background(R,G,B); //頁面背景的顏色
打開processing
改字體大小:文件→偏好設定→編輯器字體大小
程式碼
畫一個圓,讓圓留在框框裡,打到牆壁就反彈
PVector user;
PVector userV;
void setup(){
size(400,400);
user=new PVector(200,200);
userV=new PVector(1,1);
}
void draw(){
background(255);
ellipse(user.x,user.y,100,100);
user.add(userV);
if(user.x>400-50)userV.x=-1;
if(user.y>400-50)userV.y=-1;
if(user.x<50)userV.x=+1;
if(user.y<50)userV.y=+1;
}
碰到紅色,整個螢幕就變紅
PImage imgMap;
void setup(){
size(400,400);
imgMap=loadImage("789.png");
imgMap.loadPixels();
}
void draw(){
background(imgMap);
if(imgMap.pixels[mouseX+mouseY*400]==color(237,28,36)){
background(255,0,0);
}
fill(imgMap.pixels[mouseX+mouseY*400]);
rect(255,255,100,100);
}

沒有留言:
張貼留言