[plt-dev] Re: [plt-scheme] scaling and rotating images using image.ss

 From: John Clements (clements at brinckerhoff.org) Date: Sat Nov 14 01:18:45 EST 2009 Previous message: [plt-dev] latest docs Next message: [plt-dev] Re: [plt-scheme] scaling and rotating images using image.ss Messages sorted by: [date] [thread] [subject] [author]

```On Sep 26, 2009, at 6:29 AM, Matthias Felleisen wrote:

>
>
> 1. htdp/world is deprecated, use 2htdp/universe instead.
>
> 2. we consider the pinhole approach to our image library as a
> mistake. To solve the problem Robby is working on 2htdp/image, a
> replacement for the image library. When it comes out (end of
> semester probably) it will support rotate and other such operations,
> plus comparisons will be much faster.

I'm surprised to say it, but right now I'm *really missing the pinhole*.

I'm trying to write a function in 2htdp/image that draws, say, 36
copies of a shape arranged in a big "circle" around a center.  With
pinholes, this was easy.  Move the pinhole way off to the left, then
rotate the thing around the pinhole by 10 degrees, 20 degrees, etc.
Overlay them all, and you're done. [*]

With the new approach, I'm finding this nearly impossible.  The
natural approach involves, for instance, putting the thing "beside" a
long horizontal space, and then rotating it.  The problem is that it
doesn't rotate about a fixed point.  To see the problem, consider this
program:

(require 2htdp/image)

(define a (beside (rectangle 150 2 "solid" "black") (ellipse 10 50
"solid" "purple")))

(overlay/places "middle" "middle"
(rotate  0 a)
(rotate 20 a)
(rotate 40 a)
(rotate 60 a))

The problem is that mapping a point in the pre-rotation shape to a
point in the post-rotation shape is hard.

...

After wrestling with this for quite a while, I have a solution of
sorts; you have to overlay the shape you want to rotate on a large
outline circle in such a way that the shape is entirely inside the
circle. Rotating this shape does not change the bounding box at all,
meaning that you can overlay them correctly. Needless to say,
computing the size of the circle required is a big pain.

E.G.:

(define b (overlay/xy (circle 200 "outline" "blue") 200 200 a))

(overlay
(rotate  0 b)
(rotate 20 b)
(rotate 40 b)
(rotate 60 b))

Am I missing something obvious?

John

[*] with the obvious caveat that the old version didn't rotate shapes
at all.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2484 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20091113/43b6e36f/attachment.p7s>
```

 Posted on the dev mailing list. Previous message: [plt-dev] latest docs Next message: [plt-dev] Re: [plt-scheme] scaling and rotating images using image.ss Messages sorted by: [date] [thread] [subject] [author]