;;; Scheme Recursive Art Contest Entry ;;; ;;; Please do not include your name or personal info in this file. ;;; ;;; Title: ;;; ;;; Description: ;;; (define (fibonacci n) ; Calculate 'nth' term of the Fibonacci sequence (if (< n 2) 1 (+ (fibonacci (- n 1)) (fibonacci (- n 2))) )) (define (golden-ratio n) ; Calculate the Golden Ratio using the 'nth' term of the Fibonacci sequence (/ (fibonacci (+ n 1)) (fibonacci n)) ) (define phi (golden-ratio 12)) ; The Golden Ratio correct to six significant figures (define (eye scale angle x y) ; Draw a single snake eye. (define factor (sin (radians angle))) (penup) (goto x (+ (* scale 2.18 factor) y)) (color (rgb 1 1 1)) (begin_fill) (pendown) (circle (- (/ scale 10))) (end_fill) (penup) (right 90) (color (rgb 0 0 0)) (begin_fill) (goto (- x (* scale .05 factor)) (+ (* scale 2.24 factor) y)) (circle (- (/ scale 10)) 90) (right 90) (circle (- (/ scale 10)) 90) (end_fill) ) (define (snake scale angle x y r g b count) ; The main snake drawing function. This recursively draws snakes and arranges ; them into a golden logarithmic spiral using the scale, starting angle, ; origin, and starting color as parameters. (cond ((equal? count 0) (penup) (goto 400 400)) (else (penup) (color (rgb r g b)) (begin_fill) (goto x y) (setheading angle) (pendown) (circle scale 90) (circle (* scale phi) 90) (left 135) (forward (/ (* scale phi) (sqrt 2))) (right 90) (forward (/ (* scale phi) (sqrt 2))) (left 135) (forward (/ scale phi)) (circle (- (/ scale (* 2 phi phi))) 180) (left 45); (forward (/ (/ scale phi) (sqrt 2))); (left 90) (forward (/ (/ scale phi) (sqrt 2))) (end_fill) (right 135) (eye scale angle x y) (define factor (sin (radians angle))) (snake (/ scale phi phi) (- angle) (- x (/ scale phi phi phi factor)) (+ y (* scale factor)) (- r .15) g (+ b .15) (- count 1) ) ) ) ) (define (draw) (speed 0) (bgcolor (rgb 0 0 0)) (snake 750 90 100 -600 1 .4 0 7) (exitonclick)) ; Please leave this last line alone. You may add additional procedures above ; this line. (draw)