[plt-scheme] converting htdp/images to/from color-lists and transparency

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Mon Feb 8 14:46:19 EST 2010

I was just testing my picturing-programs teachpack against 4.2.4, and  
noticed that when I rotate an image (using my rotate-cw function,  
which is defined on old-style images using color-lists) the  
transparency changes.  Specifically, consider the following animation:

; place-on-pink : image -> image
(check-expect (place-on-pink calendar)
               (place-image calendar 100 40 (rectangle 150 200  
"solid" "pink")))
(check-expect (place-on-pink (triangle 30 "solid" "blue"))
               (place-image (triangle 30 "solid" "blue") 100 40  
(nw:rectangle 150 200 "solid" "pink")))
(define (place-on-pink pic)
   (place-image pic 100 40 (nw:rectangle 150 200 "solid" "pink")))

(big-bang calendar
           (on-draw place-on-pink)
           (on-tick rotate-cw 1/2))

The calendar picture initially shows up on a white rectangle against  
the pink background, but after the first tick event, all the white in  
the image becomes the background pink.  The same happens when the  
tick handler is reflect-horiz, but not when it's the identity  
function.  So I hypothesize that it's a side effect of doing an image- 
 >color-list and color-list->image.  Is there an easy explanation, or  
even better, an easy fix?

Stephen Bloch
sbloch at adelphi.edu

Posted on the users mailing list.