[racket] update canvas image

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Wed Oct 27 08:07:48 EDT 2010

So you want the refresh method?

Robby

On Wednesday, October 27, 2010, 김태윤 <kty1104 at gmail.com> wrote:
> doesn't working properly means I can't update my canvas by this methodcould somebody tell me how to update canvas with changed image? (when some function is evaluated)
>
> 2010/10/27  <kty1104 at gmail.com>
> hello~
> I am making map editor
> one of the editor's ability is select tile image from chip-set(kind of town map tile) image
> and circle the selected tile
> I made a following code  but I don't think that this is good way to update image and it doesn't working properly as well.
> could somebody give me an little advice?
>
> #lang scheme/gui
> (require 2htdp/image)
> (define pic dc<%>)
> (define chipset (make-object bitmap% "town.png" 'png))
> (define f (instantiate frame% ("map editor")))
> (define mcan%
>   (class canvas%
>
>     (override on-event on-paint)
>     (define on-paint
>       (λ () (send (send this get-dc) draw-bitmap chipset 0 0)))
>     (define on-event (λ (e)
>                        (send msg set-label
>                              (string-append (number->string (floor (/ (send e get-x) 16))) " "
>                                             (number->string (floor (/ (send e get-y) 16)))))
>                        (when (send e get-left-down)
>                          (begin (set! chipset (place-image (circle 8 "outline" "orange")
>                                                            (send e get-x)
>                                                            (send e get-y)
>                                                            chipset))
>                                 (send f refresh)));it doesn't seems to good way
>                        ))
>     (super-instantiate ())))
>
> (define mcan (new mcan% (parent f) (min-width (image-width chipset)) (min-height (image-height chipset))))
>
> (define msg (instantiate message% ("nothing so far" f)))
> (define tile-width-field (instantiate text-field% ("width") (init-value "16") (parent f) (stretchable-width #f)))
>
> (define tile-height-field (instantiate text-field% ("height") (init-value "16") (parent f) (stretchable-width #f)))
>
> (send f show #t)
>
>


Posted on the users mailing list.