[racket] 2htdp/image Sierpinski

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Sun Oct 31 16:00:39 EDT 2010

On Oct 31, 2010, at 10:24 AM, Robby Findler wrote:

> Overall, tho, we'd like to be able to support this kind of thing, but
> we need to do a better job. As I'm writing this, I wonder if we could
> exploit the sharing in the image. In your example, there are only 11
> calls to 'square' that turn into those 42,000 different squares spread
> around. If we could detect and exploit the sharing somehow that could
> lead to a big speed up. (But this is just a half-formed thought;
> nothing may come of it.)

The "cache-bitmap" tweak I suggested might provide this.
    (local [(define sub (cache-bitmap (carpet (/ size 3) c))) ...]
        (overlay (square size "outline" c)
                        (above (beside sub sub sub)
                                      (beside sub ctr sub)
                                      (beside sub sub sub))))
After "sub" is rendered for the first time, its bitmap will be  
cached, then used seven more times.

Stephen Bloch
sbloch at adelphi.edu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20101031/09a4dde3/attachment.html>

Posted on the users mailing list.