[racket] update canvas image

From: 김태윤 (kty1104 at gmail.com)
Date: Wed Oct 27 07:55:26 EDT 2010

doesn't working properly means I can't update my canvas by this method
could 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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20101027/4cc5486d/attachment.html>

Posted on the users mailing list.