[racket] erasing a line?

From: John Riedl (riedl at cs.umn.edu)
Date: Thu Jun 30 21:46:21 EDT 2011

Robby:

Thank you for the feedback.

Overall the approach of drawing simultaneously onto the canvas dc and
the backing bitmap, and then when I need to erase a part of the canvas
just copying it over from the backing bitmap works.  The speed
improvement is lovely: at least a factor of 20 or so, and everything I
need for my application.

Two interesting problems that I ran into are:

1) The bitmap draw routines do not erase the rectangle they draw into.
 I don't know why.  I ended up erasing the rectangle "by hand" with
draw-rectangle with a transparent pen.  (I tried 'solid and 'opaque
styles.  My backing bitmap and canvas are all default for things like
monochrome? and alpha.)
2) The draw-rectangle draws a little too big of a rectangle,
presumably because of the outline it is drawing with the transparent
pen.  I had to make the draw-bitmap draw just a couple of extra pixels
to make the erase work.

The invalidate approach I've seen in other graphics frameworks does
this work for you: you issue an "invalidate" for a rectangle, and the
paint routine is called with the dimensions of that rectangle, and a
guarantee that the background is already erased.  I guess the above is
doing that "by hand", which is okay.

Thanks,
John


Posted on the users mailing list.