Processing 程式碼
改背景顏色
size(500,500); background(255,255,0);
按滑鼠案件可以改背景顏色void setup(){ size(500,500); } void draw(){ if(mousePressed) background(255,0,0); //紅色 else background(0,255,0); //綠色 }按著滑鼠按鍵寫字void setup(){ size(500,500); } void draw(){ if(mousePressed) line(mouseX, mouseY, pmouseX, pmouseY); } //如果 mouse 按下去,就畫線 mouse 的 XY 座標到 previous mouseXY按滑鼠按, 選擇數字, 鍵畫出不同粗細的線void setup() { size(500, 500); } void draw() { if (mousePressed) line(mouseX, mouseY, pmouseX, pmouseY); } //如果 mouse 按下去,就畫線 mouse 的 XY 座標到 previous mouseXY void keyPressed() { if (key=='1') strokeWeight(1); if (key=='2') strokeWeight(5); if (key=='3') strokeWeight(10); } //如果 key 按下去,看 key 的值,決定線的粗細Processing 快捷鍵按滑鼠按鍵, 選擇數字, 畫出不同顏色的線void setup() { size(500, 500); } void draw() { if (mousePressed) line(mouseX, mouseY, pmouseX, pmouseY); } //如果 mouse 按下去,就畫線 mouse 的 XY 座標到 previous mouseXY void keyPressed() { if (key=='1') strokeWeight(1); if (key=='2') strokeWeight(5); if (key=='3') strokeWeight(10); if (key=='4') stroke(255,0,0); if (key=='5') stroke(255,255,0); if (key=='6') stroke(0,255,0); if (key=='7') stroke(0,0,255); if (key=='8') stroke(255,0,255); } //如果 key 按下去,看 key 的值,決定線的顏色畫圓跟長方形, 填充顏色size(600, 400); background(#7CC5F5); //色彩的色碼 #RRGGBB rect(100, 100, 400, 200); //在100,100的地方, 畫寬度400, 高度200 的長方形 fill(#7CC5F5); //填充色 ellipse(300, 200, 100, 100); //畫圓用蘋果派的方法畫小精靈size(400,400); background(0, 0, 0); fill(#F0CF2C); //填充黃色 noStroke(); //不要有邊線筆觸 //ellipse(50, 50, 100, 100); arc(50, 50, 100, 100, 0 + 1, PI*2 - 1, PIE); //畫弧度 //X座標, Y座標, 寬, 高, 開始, 結束, 蘋果派的方法畫Ctrl-T 自動排版Ctrl-N 新文件Ctrl-S 存檔
沒有留言:
張貼留言