實作:
下載processing
1.上網搜尋processing.org
2.Download
3.選擇符合自己電腦的版本
4.下載
畫線
1.一條斜線
2.把視窗放大
3.畫正方形
小畫家
1.正常顯示的時候
程式碼:
//void Setup()//Unity uses it
void setup(){
size(800,600);
}
//void Update()//Unity uses it
void draw(){
if(mousePressed) background(255,0,0);///按下去變紅色
else background(0,255,0);///正常情況是綠色
}
正式畫
1.失敗版
滑鼠過去之後就會出現一堆線
2.成功版
可以正常畫,滑鼠按下去才會畫,沒有按的時候不會有線出現,跟真的小畫家有點像了
3.真正可以用的有粗細有顏色
程式碼
void setup(){
size(800,600);
}
void draw(){
if (mousePressed)line(mouseX, mouseY, pmouseX, pmouseY);
}
void keyPressed(){
if(key=='1') strokeWeight(1);//粗細
if(key=='2') strokeWeight(2);
if(key=='3') strokeWeight(4);
if(key=='4') strokeWeight(6);
if(key=='5') strokeWeight(8);
if(key=='6') strokeWeight(10);
if(key=='7') strokeWeight(20);
if(key=='8') strokeWeight(100);
if(key=='r') stroke(255,0,0);//顏色
if(key=='g') stroke(0,255,0);
if(key=='b') stroke(0,0,255);
if(key=='p') stroke(100,180,255);
}

沒有留言:
張貼留言