(define rotation->rgb (lambda (rotation color-scheme) (cond ;Existing code, from HW7. ((= 0 color-scheme) (rgb-new (* 128 (+ 1 (sin rotation))) (* 128 (+ 1 (cos rotation))) (* 128 (+ 1 (sin (- rotation pi)))))) ;Red, then green, then blue. Color wheel. ((= 1 color-scheme) (rgb-new (* 128 (+ 1 (sin (+ (* (/ 2 3) pi) rotation)))) (* 128 (+ 1 (sin rotation))) (* 128 (+ 1 (sin (- (* (/ 2 3) pi) rotation)))))) ;Complement of the color wheel ((= 2 color-scheme) (rgb-complement (rotation->rgb rotation 0))) ; All green from 0 to 255 ((= 3 color-scheme) (rgb-new 0 (* 128 (+ 1 (sin rotation))) 0)) ;All blue from 0 255 ((= 4 color-scheme) (rgb-new 0 0 (* 128 (+ 1 (sin rotation))))) ;Grayscale ((= 5 color-scheme) (rgb-new (* 128 (+ 1 (sin rotation))) (* 128 (+ 1 (sin rotation))) (* 128 (+ 1 (sin rotation))))) ;All red, from 0 to 255 ((= 6 color-scheme) (rgb-new (* 128 (+ 1 (sin rotation))) 0 0)) ;Fade from red to blue ((= 7 color-scheme) (rgb-new (* 128 (+ 1 (sin rotation))) 0 (* 128 (+ 1 (sin (+ rotation pi)))))) ;Darker Red ((= 8 color-scheme) (rgb-new (* 64 (+ 1 (sin rotation))) (* 128 (+ 1 (cos rotation))) (* 128 (+ 1 (sin (- rotation pi)))))) ;Phaseshift ((= 9 color-scheme) (rgb-phaseshift (rotation->rgb rotation 0))) ;Complete opposite of orig. sort of ((= 10 color-scheme) (rgb-new (* 128 (+ 1 (cos rotation))) (* 128 (+ 1 (sin rotation))) (* 128 (+ 1 (cos (- rotation pi))))))))) (define brushes-to-use (vector "Circle (03)" "Circle (05)" "Circle (07)" "Circle (09)" "Circle (11)" "Circle Fuzzy (03)" "Circle Fuzzy (05)" "Circle Fuzzy (07)" "Circle Fuzzy (09)" "Circle Fuzzy (11)" "Circle Fuzzy (13)" "square (10x10)" "square (10x10) blur" "square (20x20)" "square (20x20) blur" "square (5x5)" "square (5x5) blur")) (define rotation-calculate (lambda (rotation-pattern rotation) (cond ((= rotation-pattern 0) (cos (* 1.25 rotation))) ((= rotation-pattern 1) (sin (* 2.5 (+ 1.234 rotation)))) ((= rotation-pattern 2) (cos (- 2 (* (/ 2 3) rotation)))) ((= rotation-pattern 3) (cos (* 1.5 (+ 3 rotation)))) ((= rotation-pattern 4) (sin (* 2 (- 1 rotation)))) ((= rotation-pattern 5) (sin (cos (* 3 (+ 0.5 rotation))))) ((= rotation-pattern 6) (sin (* 1.25 (+ 2 rotation)))) ((= rotation-pattern 7) (cos (* pi (+ pi rotation))))))) (define image-draw-circle! (lambda (image col row radius width height) (image-select-ellipse! image selection-replace (* width (- col radius)) (* height (- row radius)) (* width (+ radius radius)) (* height (+ radius radius))) (image-stroke! image) (image-select-nothing! image))) (define draw-stamp! (lambda (image col row radius rotation color-scheme width height brush-to-use) (context-set-fgcolor! (rotation->rgb rotation color-scheme)) (context-set-brush! brush-to-use) (image-draw-circle! image col row radius width height))) (define draw-rolled! (lambda (image width height rotation col-rotation-pattern row-rotation-pattern color-scheme brush-to-use) (draw-stamp! image (+ .5 (* .3 (rotation-calculate col-rotation-pattern rotation))) (+ .5 (* .3 (rotation-calculate row-rotation-pattern rotation))) 0.1 rotation color-scheme width height brush-to-use))) (define roll-kernel! (lambda (image col row theta n step rotation col-rotation-pattern row-rotation-pattern color-scheme width height brush-to-use) (cond ((< step n) (draw-rolled! image width height rotation col-rotation-pattern row-rotation-pattern color-scheme brush-to-use) (roll-kernel! image col row theta n (+ step 1) (+ rotation theta) col-rotation-pattern row-rotation-pattern color-scheme width height brush-to-use))))) (define image-series (lambda (n width height) (context-set-bgcolor! (rotation->rgb (* (/ (modulo n 15) 14) pi 2) 0)) (let* ((brush-to-use (if (not (= n 666)) (vector-ref brushes-to-use (modulo n 17)) "Pepper")) (color-scheme (modulo n 11)) (row-rotation-pattern (modulo n 8)) (col-rotation-pattern (modulo n 7)) (steps (+ 25 (* 4 (modulo n 13)))) (image (image-new width height))) (image-show image) (display steps) (roll-kernel! image .5 .5 (/ pi 16) steps 0 0 col-rotation-pattern row-rotation-pattern color-scheme width height brush-to-use) (context-update-displays!) )))