float dx, dy, delta,angle; float centerX,centerY; int valueR,valueG,valueB,valueCommon; boolean mouseFlag; void setup(){ size(400,400); background(255); mouseFlag = true; PFont f = loadFont("ArialNarrow-64.vlw"); textFont(f,20); } void draw(){ if(keyPressed){ if(mousePressed){ if(mouseFlag){ centerX = mouseX; centerY = mouseY; mouseFlag = false; if(key=='1'){ stroke(255,0,0,50); valueR=valueCommon; } else if(key=='2'){ stroke(0,255,0,50); valueG=valueCommon; } else if(key=='3'){ stroke(0,255,255,50); valueB=valueCommon; } else if(key=='4'){ background(255); } } ////////////////////////////////////////////////////// fill(255); rect(5,290,100,80); fill(100); text ("red:"+valueR,10,320); text ("green:" +valueG ,10,340); text ("blue:"+ valueB ,10,360); ///////////////////////////////////////////////////// valueCommon++; strokeWeight(delta/5); rect(mouseX,mouseY,dx,dy); line(mouseX,mouseY,centerX,centerY); } else { mouseFlag = true; } /////////////////////////////////////////////////////// dx = mouseX - pmouseX; dy = mouseY - pmouseY; delta = sqrt(dx*dx + dy*dy); dx = mouseX - pmouseX; dy = mouseY - pmouseY; angle = atan2(dy,dx)-PI/2; ////////////////////////////////////////////////////// } }