Reputation: 61
i have been using cleardevice() to clear the graphics ... but it creates several problems
for eg .. i create a background but i have to clear some specific elements , then i have to use another user defined function drawb() which draws the background and simultaneously cleardevice(); creating a lot of problems
line(x,y,x1,y1); //suppose this line is to be erased
//but using cleardevice even clears the background
cleardevice();
drawb(); //to draw board or background
so i want to know an alternative approach(an approach to clear only the line not the background) (if it exists )
Upvotes: 1
Views: 6227
Reputation: 11
You can first take the image before drawing the line by getimage()
and put that image on the line whenever you want to hide your image
This will not change your background and not flick it. putimage()
can put the image.
Upvotes: 1
Reputation: 5123
Once a line is drawn, there is no real way to remove it (except if you are drawing using XOR mode!). However, there are some thing you could do. You could render everything but the line in a page and store it there. Then, in another page you render everything, including the line. So if you want to undo the line, you just switch the page back.
An example:
setactivepage(0);
// draw stuff, including background
setactivepage(1);
// draw stuff, including background and line
setvisualpage(0); // no line visible
setvisualpage(1); // line visible
Also, if you want to reset the screen with a background, there is no need to do a cleardevice()
, since the drawb()
overwrites every pixel ayway.
Upvotes: 2