Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Erasing Scribbles

 
Eric Chang
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So let's say I have a Java application that allows for the drawing of scribbles. However, the way I store the scribbles in memory is by turning the scribble into line segments and storing the two points of each line segment (thereby not actually storing every single pixel coordinate into memory).
Now, I have to be able to erase that scribble...does anyone have any fancy ideas on how this can be done within Java that is efficient. I've thought about turning the scribble back into it's pixel-by-pixel form and working from there, but it seems like the refreshing and redrawing of it is pretty inefficient and quite flickery.
I'm open to suggestions from those that might have a much better idea on this than I do.
Thanks!
 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see two approaches to this

1) Remove the line segment(s) which were "erased"
2) If the user is provided an "eraser" whenever he updates the canvas (draw/erase) etc, update the line segments

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic