[plt-scheme] About canvas class

François Michaudon f.michaudon at gmail.com
Mon Apr 27 03:19:59 EDT 2009


hi ,
What's the best between :

(define MY-CANVAS%
  (class canvas%
    (init-field
     (buff (make-object bitmap% 1000 1000))
     (Dbuffer  (new bitmap-dc% [bitmap buff ] ))
     (bitmap1 (make-object bitmap% "test.jpg")))

    (inherit get-dc)
    (define/override (refresh)
      (send Dbuffer clear)
      (send Dbuffer draw-bitmap bitmap1 0 0 'solid )
      (send (get-dc) draw-bitmap Dbuffer 0 0))

    (define/override (on-paint) (send this refresh))
    (super-new)))

or like this:

(define buff (make-object bitmap% 1000 1000))
(define Dbuffer  (new bitmap-dc% (bitmap buff)))
(define bitmap1 (make-object bitmap% "test.jpg"))

(define canvas  (new canvas%
                     (parent FRAME)
                     (paint-callback (λ (c dc)
                                       (send Dbuffer clear)
                                       (send Dbuffer draw-bitmap bitmap1 0 0
'solid )
                                       (send dc draw-bitmap Dbuffer 0 0)))))



I get the same result, but whicth method I must use ?
What is the most conventional?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.cs.brown.edu/pipermail/plt-scheme/attachments/20090427/9afb096e/attachment.html


More information about the plt-scheme mailing list