[plt-scheme] Re: MrEd - Animated canvas

From: Laurent (Ouaibou at gmail.com)
Date: Sat Mar 24 12:49:37 EDT 2007

Hi,

I have two new questions :

- To carry out my animation, i use a timer which calls a function
which refresh my canvas. If i use :

>(define (refresh canvas)
>  (send canvas refresh))
>
>(define TIMER-ANIMATION (new timer% (notify-callback (refresh canvas_2))))

This not perform, but if use this :

>(define (refresh)
>  (send canvas_2 refresh))

>(define TIMER-ANIMATION (new timer% (notify-callback refresh)))

It perform. I don't understand why.

- My second question :
The timer calls refresh who call paint-callback. In this method, i
draw the beater, the bricks and the balls of my wall-breaker.
However as my beater jerks at the time of displacement I wanted to use
a thread. But if I use a thread the beater flick.
I don't see why ?

>(define canvas_2
>  (new wb-canvas% (parent vpanel_2)
>       (min-width 630)
>       (style '(border no-autoclear))
>       (paint-callback
>        (lambda (canvas dc)
>          (reset-offscreen! canvas_2)
>          ;; On efface le buffer
>         (send OFFSCREEN-DC clear)
>          ;; On dessine les differents elements dans le buffer
>          (send OFFSCREEN-DC draw-bitmap bg 0 0)
>          (thread (lambda ()
>                    (draw-batte OFFSCREEN-DC)))
>          (draw-bricks OFFSCREEN-DC)
>          (draw-balls OFFSCREEN-DC)
>          ;; On copie l'image a l'écran
>          (send dc draw-bitmap OFFSCREEN-BM 0 0)))))

Thanks,
Laurent



Posted on the users mailing list.