[plt-scheme] Nifty assignment help

From: Todd O'Bryan (toddobryan at gmail.com)
Date: Tue Mar 10 10:33:49 EDT 2009

Hey all,

Christopher Stone from Harvey Mudd College presented a nifty
assignment that I'd love to use with my students:

http://nifty.stanford.edu/2009/stone-random-art/

The idea is that you create random functions that have domain ([-1,
1], [-1, 1]) and range [-1, 1]. You map the domain values to x and y
and the range values to a color, plot the results, and get very cool
designs.

What I need are functions with the following contracts:

;; draw-grayscale: Integer (Integer[0, size] Integer[0, size] ->
Integer[0, 255]) -> Image
;; consumes: the size in pixels of a square image,
;;                  a function that, given an x and y coordinate on the image,
;;                     produces a grayscale value
;; produces: the image
(define (draw-grayscale size plot-function)

;; draw-color: Integer
;;                 (Integer[0, size] Integer[0, size] -> Integer[0, 255])
;;                 (Integer[0, size] Integer[0, size] -> Integer[0, 255])
;;                 (Integer[0, size] Integer[0, size] -> Integer[0,
255]) -> Image
;; consumes: the size in pixels of a square image,
;;                  three functions that, given an x and y coordinate
on the image,
;;                     produce a color value
;; produces: the image
(define (draw-color size red-function green-function blue-function)

I could do these in the image teachpack using color-list->image, but I
suspect that would be remarkably slow.

Where should I look for a better way to do it?

Todd


Posted on the users mailing list.