Hi All,
I’ve got this code:
PGraphics myline;
PGraphics myrect;
void setup(){
background(#FFFFFF);
size(600,600);
myline=createGraphics(width,height);
myrect=createGraphics(width,height);
}
void draw(){
myrect.beginDraw();
myrect.rect(50,50,198,198);
myrect.endDraw();
myline.beginDraw();
myline.line(147,475,mouseX,mouseY);
myline.endDraw();
image(myrect,0,0);
image(myline,0,0);
}
void mousePressed()
{
myline.beginDraw();
myline.clear();
myline.endDraw();
}
What I want to do is clear all the lines as I press the mouse. The problem is only those part of the lines will be deleted which are above the rect. What should I do?