[plt-scheme] 2htdp/image Images in Slideshow

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri May 28 18:56:05 EDT 2010

Fixed (specific to Mac) for the next version.

At Fri, 28 May 2010 16:55:04 -0500, Robby Findler wrote:
> This appears to be a bug in the handling of 'smoothed drawing mode.
> Below is an example program that illustrates the bug.
> 
> #lang racket/gui
> 
> (define (draw c dc)
>   (send dc set-origin 159.0 -1.0)
>   (let ([new-region (new region% [dc dc])]
>         [path (new dc-path%)])
>     (send path move-to 0 0)
>     (send path line-to 100 0)
>     (send path line-to 100 100)
>     (send path line-to 0 100)
>     (send new-region set-path path 462 334)
>     (send dc set-clipping-region new-region)
>     (send dc draw-rectangle 462 334 100 100)
>     (let* ([path (new dc-path%)]
>            [ew 20]
>            [eh 20]
>            [θ 0]
>            [color "red"]
>            [mode 'solid])
>       (send path ellipse 0 0 20 20)
>       (send dc set-smoothing 'smoothed) ;;; remove this line and it draws
>       (send dc draw-path path 512 384))))
> 
> (define f2 (new frame% [label ""]))
> (define c2 (new canvas%
>                 [parent f2]
>                 [min-width 1000]
>                 [min-height 500]
>                 [paint-callback draw]))
> (send f2 show #t)
> 
> 
> On Fri, May 28, 2010 at 3:21 PM, Nadeem Abdul Hamid <nadeem at acm.org> wrote:
> > This image->pict function doesn't seem to work with place-image when 
> embedded in a slide. When I use it in the interactions pane, it does produce 
> the expected pict, but when it renders the slide below, all I get is an empty 
> scene....
> >
> >
> > #lang slideshow
> >
> > (require (prefix-in im: 2htdp/image))
> > (require mrlib/image-core)
> >
> > (define (image->pict img)
> >  (dc (λ (dc dx dy) (render-image img dc dx dy))
> >     (im:image-width img)
> >     (im:image-height img)))
> >
> > (slide
> >  (image->pict (im:place-image
> >               (im:circle 10 "solid" "red") 50 50
> >               (im:empty-scene 100 100))))
> >
> >
> >
> >
> >
> >
> > On May 25, 2010, at 4:59 PM, Robby Findler wrote:
> >
> >> You can do this:
> >>
> >> #lang scheme
> >> (require slideshow slideshow/code)
> >>
> >> (require (prefix-in im: 2htdp/image)
> >>         mrlib/image-core)
> >>
> >> (define (image->pict img)
> >>  (dc (λ (dc dx dy) (render-image img dc dx dy))
> >>      (im:image-width img)
> >>      (im:image-height img)))
> >>
> >> (slide
> >> (hbl-append (code (rectangle 15 25 "solid" "blue"))
> >>             (t "=>")
> >>             (image->pict (im:rectangle 15 25 "solid" "blue"))))
> >>
> >> I see that render-image isn't documented, tho. Apologies for that.
> >>
> >> Robby
> >>
> >> On Tue, May 25, 2010 at 2:45 PM, Nadeem Abdul Hamid <nadeem at acm.org> wrote:
> >>>
> >>> How can one embed images generated using 2htdp/image into a slideshow? Is 
> there an easy tweak to make something like this work:
> >>>
> >>> (require (prefix-in im: 2htdp/image))
> >>> (slide
> >>>  (hbl-append (code (rectangle 15 25 "solid" "blue")) (t "=>")  
> (im:rectangle 15 25 "solid" "blue"))
> >>>  )
> >>>
> >>> --- nadeem
> >>>
> >>>
> >>> _________________________________________________
> >>>  For list-related administrative tasks:
> >>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> >>>
> >
> >
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.