float mxl, myl;
boolean startdr = false;
void setup() {
size( 400, 300 );
background(255);
}
void draw() {
// clear button
stroke(0); noFill(); strokeWeight(2);
rect(1, 1, 398, 298 );
noStroke(); fill(128, 128, 128);
rect(0, 0, 20, 20);
}
void mousePressed(){
if( mouseX <= 20 && mouseY <= 20 ){
background(255);
}else{
startdr = true;
mxl = mouseX; myl = mouseY;
}
}
void mouseDragged(){
if( startdr ){
noFill(); stroke(0); strokeWeight(3);
line( mxl, myl, mouseX, mouseY );
mxl = mouseX; myl = mouseY;
}
}
void mouseReleased(){
startdr = false;
} |