(define create-drawing (lambda (filename val1 val2 val3) (let* ((color (rgb.new (* val1 28) (* val2 28) (* val3 28))) ;;;since val1, val2, and val3 vary from 0 to 9, our rgb components will vary from 0 to 252 (which was as close to 255 as we could get using a whole number multiple) ;;;Note: the images will be greyscale if val1 = val2 = val3 (complement-color (rgb.complement color)) (plate-size (max 50 (* (+ val1 1) (+ val2 1)))) ;;;Because we didn't want a plate with size 0, we used the max function to make a plate with variable sizes, all of which are between 50 and 100. Note that, for any random selection of val1 and val2, there will be a disproportionate number of plates with size 50, since for all combinations of val1 and val2 where both of the values are <=6, we will end up with a plate with size 50--that is, a little over half of the time. (chop1-start-col 10) (chop1-start-row 20) (chop2-start-col 20) (chop2-start-row 10) (chop1-end-col (* 18 (+ val2 1))) (chop1-end-row (* 18 (+ val3 1))) (chop2-end-col (* 18 (+ val3 1))) (chop2-end-row (* 18 (+ val2 1))) (destination (open-output-file filename))) (if (not (output-port? destination)) (throw "create-drawing: Could not open output file" filename)) ;;;Draw plate, centered in the 200 x 200 image, either filled or stroked (if (odd? (+ val1 val2 val3)) (empty-circle.write destination color "Circle (03)" (- 100 (* 0.5 plate-size)) (- 100 (* 0.5 plate-size)) plate-size) (filled-circle.write destination color (- 100 (* 0.5 plate-size)) (- 100 (* 0.5 plate-size)) plate-size)) ;;;Draw chopsticks, with chop1 starting at (10, 20) and chop2 starting at (20, 10) (line.write destination complement-color "Circle (03)" chop1-start-col chop1-start-row chop1-end-col chop1-end-row) (line.write destination complement-color "Circle (03)" chop2-start-col chop2-start-row chop2-end-col chop2-end-row) (close-output-port destination) 'Success)))