[racket] Using big-bang with picts

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Feb 17 17:25:14 EST 2014

Thanks, I pushed a fix -- Matthias



On Feb 17, 2014, at 2:44 PM, Robby Findler <robby at eecs.northwestern.edu> wrote:

> Oh, yes: that's effectively a bitmap -> image coercion. That's probably a better thing to put than what I did in my diff.
> 
> Robby
> 
> 
> On Mon, Feb 17, 2014 at 1:41 PM, Spencer Florence <florence at ccs.neu.edu> wrote:
> I've run into this before. The way we solved it was to rotate bitmaps my 0 degrees: Its silly, but it works. 
> 
> So
> 
> (define (world->image p)
>   (rotate (pict->bitmap p))
> 
> 
> On Mon, Feb 17, 2014 at 2:38 PM, Robby Findler <robby at eecs.northwestern.edu> wrote:
> This does look like a bug in 2htdp/universe, tho. 
> 
> Looking at the universe code, it is not dealing with the case that it gets a bitmap% object. 2htdp/image's image? predicate accepts those. Probably a diff something along these lines is the right fix (warning, untested!)
> 
> ☕  git diff .
> diff --git a/pkgs/htdp-pkgs/htdp-lib/2htdp/private/world.rkt b/pkgs/htdp-pkgs/htdp-lib/2htdp/private/world.rkt
> index 103ca45..98d46ff 100644
> --- a/pkgs/htdp-pkgs/htdp-lib/2htdp/private/world.rkt
> +++ b/pkgs/htdp-pkgs/htdp-lib/2htdp/private/world.rkt
> @@ -232,7 +232,10 @@
>        ;; Image -> Void
>        ;; show the image in the visible world
>        (define/public (show pict0)
> -        (define pict (add-game-pad pict0))
> +        (define pict1 (if (is-a? pict0 bitmap%)
> +                          (make-object bitmap-snip% pict0)
> +                          pict0))
> +        (define pict (add-game-pad pict1))
>          (send visible begin-edit-sequence)
>          (send visible lock #f)
>          (let ([s (send visible find-first-snip)]
> 
> 
> 
> On Mon, Feb 17, 2014 at 12:40 PM, Jens Axel Søgaard <jensaxel at soegaard.net> wrote:
> Hi All,
> 
> Is there a way to use big-bang with picts?
> In other words, how can I convert a pict into something that big-bang
> will display?
> 
> The attempt below fails with this error:
> 
>     collects/racket/private/class-internal.rkt:4387:0: send: no such method
>     method name: copy
>     class name: bitmap%
> 
> #lang racket
> (require pict (only-in 2htdp/universe big-bang on-tick to-draw))
> 
> (define (world->image w)
>   (pict->bitmap (circle w)))
> 
> (big-bang 100
>           [on-tick add1]
>           [to-draw world->image])
> 
> 
> --
> Jens Axel Søgaard
> 
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
> 
> 
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
> 
> 
> 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



Posted on the users mailing list.