(define distance-between (lambda (col1 row1 col2 row2) (sqrt (+ (* (abs (- col1 col2)) (abs (- col1 col2))) (* (abs (- row1 row2)) (abs (- row1 row2))))))) (define background-transform (lambda (image n) (let ((width (image-width image)) (height (image-height image))) (image-iterate! image (lambda (col row) (let ((cooler (rgb-new (* (modulo (quotient n 3) 256) (/ (min (sqrt (+ (* col col) (* row row))) (sqrt (+ (* (- width col) (- width col)) (* row row))) (sqrt (+ (* col col) (* (- height row) (- height row)))) (sqrt (+ (* (- width col) (- width col)) (* (- row height) (- row height))))) (sqrt (+ (* (/ width 2) (/ width 2)) (* (/ height 2) (/ height 2)))))) (* (modulo (quotient n 2) 256) (/ (min (sqrt (+ (* col col) (* row row))) (sqrt (+ (* (- width col) (- width col)) (* row row))) (sqrt (+ (* col col) (* (- height row) (- height row)))) (sqrt (+ (* (- width col) (- width col)) (* (- row height) (- row height))))) (sqrt (+ (* (/ width 2) (/ width 2)) (* (/ height 2) (/ height 2)))))) (* (modulo n 256) (/ (min (sqrt (+ (* col col) (* row row))) (sqrt (+ (* (- width col) (- width col)) (* row row))) (sqrt (+ (* col col) (* (- height row) (- height row)))) (sqrt (+ (* (- width col) (- width col)) (* (- row height) (- row height))))) (sqrt (+ (* (/ width 2) (/ width 2)) (* (/ height 2) (/ height 2))))))))) (cond ((>= (distance-between col row (* .25 width) (* .75 height)) (* .2 width (/ width height))) cooler) (else (rgb-complement cooler))))))))) (define make-spiral (lambda (image n) (let ((width (image-width image)) (height (image-height image)) (distance (/ (image-width image) 50))) (begin (define turtler (turtle-new image)) (turtle-teleport! turtler (* width .75) (* height .25)) (turtle-face! turtler 90) (turtle-down! turtler) (turtle-set-color! turtler (rgb-complement (rgb-new (modulo (quotient n 3) 256) (modulo (quotient n 2) 256) (modulo n 256)))) (let kernel ((count 0)) (cond ((>= count (+ 3 (modulo n 15))) image) (else (kernel (+ count 1)) (turtle-forward! turtler (* distance count 1.3)) (turtle-turn! turtler (+ (modulo n 70) 50))))))))) (define add-line (lambda (image n) (let ((width (image-width image)) (height (image-height image))) (begin (context-set-fgcolor! (rgb-darker (rgb-complement (rgb-new (* .9 (modulo (quotient n 3) 256)) (modulo (quotient n 2) 256) (* 1.1 (modulo n 256)))))) (image-draw-line! image 0 (* .2 height) (* .45 width) height) (image-draw-line! image 0 (* .2 height) (* .40 width) height) (image-draw-line! image 0 (* .2 height) (* .35 width) height))))) (define make-image (lambda (image n) (begin (background-transform image n) (make-spiral image n) (add-line image n))))