1.1
color dw=color(0,0,0); PImage a; int type=0,ex=0,ey=0,wt=1; boolean draw_ellipse=false; void setup() { background(255); size(500,400); } void Colorarea() { //Color stroke(0); strokeWeight(1); fill(255,0,0); rect(0,0,50,50); fill(0,255,0); rect(0,50,50,50); fill(0,0,255); rect(0,100,50,50); fill(255,255,0); rect(0,150,50,50); fill(255,0,255); rect(0,200,50,50); fill(0,255,255); rect(0,250,50,50); fill(0,0,0); rect(0,300,50,50); fill(255); rect(0,375,50,25); fill(0); text("Clean", 7,392); fill(255); rect(50,375,50,25); fill(0); text("Save", 60,392); stroke(dw); strokeWeight(wt); } void Strokearea() { //Stroke noFill(); stroke(0); strokeWeight(1); rect(450,0,50,50); ellipse(475,25,5,5); rect(450,50,50,50); ellipse(475,75,10,10); rect(450,100,50,50); ellipse(475,125,15,15); rect(450,350,50,50); line(460,360,490,390); rect(400,350,50,50); ellipse(425,375,30,20); rect(350,350,50,50); fill(0); ellipse(375,375,30,20); stroke(dw); strokeWeight(wt); } void checked() { int k=mouseY/50; if(mouseX<50&&mouseY<350){ if(k==0) dw=color(255,0,0); else if(k==1) dw=color(0,255,0,150); else if(k==2) dw=color(0,0,255,150); else if(k==3) dw=color(255,255,0,150); else if(k==4) dw=color(255,0,255,150); else if(k==5) dw=color(0,255,255,150); else if(k==6) dw=color(0); } else if(mouseX&rt;450&&mouseY<150){ if(k==0) wt=1; else if(k==1) wt=3; else if(k==2) wt=5; } else if(mouseX<50&&mouseY&rt;375) background(255); else if(mouseX<100&&mouseY&rt;375) save("C:/save1.jpg"); else if(mouseX&rt;350&&mouseY&rt;350){ if(mouseX&rt;450) type=0; else if(mouseX&rt;400) type=1; else if(mouseX&rt;350) type=2; } else{ stroke(dw); strokeWeight(wt); if(type==0){ line(pmouseX,pmouseY,mouseX,mouseY); draw_ellipse=false; } else if(type==1){ noFill(); draw_ellipse=true; } else if(type==2){ fill(dw); draw_ellipse=true; } } } void mouseReleased() { if(draw_ellipse){ noFill(); ellipse(ex,ey,mouseX-ex,mouseY-ey); } } void mousePressed() { save("C:/temp.jpg"); ex=mouseX; ey=mouseY; a=loadImage("C:/temp.jpg"); } void draw() { Colorarea(); Strokearea(); if(mousePressed&&draw_ellipse){ image(a,0,0); if(type==1) noFill(); else fill(dw); ellipse(ex,ey,abs(mouseX-ex),abs(mouseY-ey)); } if(mousePressed) checked(); }
100
回覆刪除認真~
回覆刪除