[racket] Drawing in the Canvas from outside

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Jan 28 13:14:03 EST 2015

For the record, here's an example of that technique.

At Tue, 27 Jan 2015 11:23:29 -0700, Matthew Flatt wrote:
> You can draw on the canvas from the outside using `get-dc`. Possibly,
> though, you're seeing your drawing erased when the canvas receives a
> refresh event from the window system.
> 
> See
> 
>  http://docs.racket-lang.org/gui/canvas___.html
> 
> for more about `on-paint` and the impermanence of drawing from the
> outside.
> 
> If you need to draw from the outside and there's not a good way to
> reconstruct the drawing at any time within `paint-callback`, then one
> common strategy is: Draw to a bitmap, copy the bitmap to the canvas
> whenever the bitmap content is changed, and also have `on-paint` copy
> the bitmap to the canvas.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: offscreen-example.rkt
Type: application/octet-stream
Size: 1572 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20150128/e0f27aa0/attachment.obj>

Posted on the users mailing list.