Android Question removing a certain color from Canvas

hanyelmehy

Active Member
Licensed User
Longtime User
is there any way to removing a certain color from Canvas
for example if we draw two lines with different color on Canvas (lines may interact in some points) ,how to clear just one line ,because using Transparent color well erase both lines
 

eurojam

Well-Known Member
Licensed User
Longtime User
you can draw the line again with transparent color and the other lines with their color - save it in a map or list before, as your own type with coordinates, color and linewidth...just an idea
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
As far as I know there is no way to do what you are asking, there isn't an "undo" draw function.

You would need to create two or more canvas objects (CanLine1, CanLine2, etc.) then draw the subsequent canvas images onto the first, e.g. draw on CanLine1, then draw on CanLine2, then draw then entire CanLine2 onto CanLine1.

When you need to "erase" you would modify each canvas as needed and re-render the composite image again.
 
Upvote 0

DPaul

Active Member
Licensed User
Longtime User
1. redrawing is an option
2. if you know the ARGB(1) value of the color, and the ARGB(2) of the canvas, you can replace (1) by (2) by scanning it as a bitmap
3. The caveat would be at intersections: what is drawn on top of what. Gaps may occur that need to be filled.
Paul
 
Upvote 0

hanyelmehy

Active Member
Licensed User
Longtime User
Thanks for all answers
its something like painting application ,i already try save line path information and multi canvas layer ,and get pixel method ,these methods works but not perfect and slow specially get pixel
 
Last edited:
Upvote 0
Top