清除图形的另一种方法 [英] Alternative approach to clearing graphics
问题描述
我一直在使用 cleardevice()清除图形...但它会创建几个问题
i have been using cleardevice() to clear the graphics ... but it creates several problems
一个背景,但我必须清除一些特定的元素,然后我必须使用另一个用户定义函数 drawb()它绘制背景和同时 cleardevice
创建了很多问题
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 )
推荐答案
一旦绘制一行,没有真正的方法来删除它(除非您使用 XOR模式!)。但是,有一些事情你可以做。你可以渲染页面中的所有行,但存储在那里。然后,在另一个页面中,你渲染一切,包括行。
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.
例如:
setactivepage(0);
// draw stuff, including background
setactivepage(1);
// draw stuff, including background and line
setvisualpage(0); // no line visible
setvisualpage(1); // line visible
此外,如果要使用背景重置屏幕,执行 cleardevice()
,因为 drawb()
覆盖了每个像素ayway。
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.
这篇关于清除图形的另一种方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!