[plt-scheme] playing with image internals

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Tue Apr 20 12:27:22 EDT 2010

Start with

(require mrlib/image-core)
(require 2htdp/private/image-more)
(require 2htdp/private/img-err)
(require scheme/gui)

(define tri (triangle 30 "solid" "orange"))
(define w (image-width tri))
(define h (image-height tri))
(define bm (make-object bitmap% w h))
(define bmdc (make-object bitmap-dc% bm))

Now, in Interactions, type
(render-image (rectangle w h "solid" "purple") bmdc 0 0)
(to-img bm)
and it shows a purple rectangle, as I would expect.

Next, in Interactions, type
(render-image tri bmdc 0 0)
(to-img bm)
and not only does it show an orange triangle on a purple background, but the PREVIOUS output in the Interactions pane (which was a purple rectangle) retroactively becomes an orange triangle on a purple background.  to-image mutates [the record of] the past!

It's not really a bug, as this is all internal stuff that one wouldn't normally be using in Interactions, but it's weird and amusing.

Stephen Bloch
sbloch at adelphi.edu

Posted on the users mailing list.