2016년 12월 6일 화요일

Clear line on canvas without clear canvas


A very simple question: I draw a colored line on a black canvas, how can to clear the line without clear all canvas (If I draw a black line, the background of canvas does not go back black), thanks.

--
You could try setting your PaintColor to 16777215 which is the 'none' color value.
then redraw the line in that color.
The problem with that is if you have one line crossing over another line, it will leave a hole in the other line.
Not good.
So I recommend that you store the DrawLine x1,y1,x2,y2 values in a list as you  draw the lines.
Then when you need to undo the last line drawn, clear the screen and redraw all lines in the list except the last one.
You can even simulate a redo as well.

--
Nothing change with "none color", with I redraw remains a not color black !

-- 
I think that does not work as it is just drawing a transparent line over an opaque line so has no effect.
I have tried another method that sets the color of the line to the canvas backgroundcolor to erase the line.
It will work if you have set the canvas backgroundcolor to anything but 'none'.

First the line is drawn at the specified color then it is erased by using linewidth + 1 for the size of the line.
If the original linewidth is used, a border is left for some reason.


-- 
Thank you very much.

--

댓글 없음:

댓글 쓰기