;;;Lightweight entry for contest ;;; Grant Merrill and Taewook Ha ;;; cs61a-ay cs61a-af ;;; ;;;Title: Ooh, colors ;;; ;;; Summer is ending ;;;Color sprouts in trees above ;;;Oh go term starts now ;;; (speed 0) (define (pythagoras-tree length depth) (cond ((= depth 0) (color "#00EE00") (square-spiral length 15 10) ) (else (forward length) (left 45) (pythagoras-tree (sqr-root(/ (* length length) 2)) (- depth 1)) (right 90) (forward (sqr-root(/ (* length length) 2))) (pythagoras-tree (sqr-root(/ (* length length) 2)) (- depth 1)) (right 90) (forward (sqr-root(/ (* length length) 2))) (right 45) (forward length) (right 90) (forward length) (right 90) (color (color-helper depth)) (square-spiral length 15 10) ) ) ) (define (square-spiral length depth angle) (define (displace angle) (/ (tan angle) (+ 1 (tan angle))) ) (cond ((= depth 0) (forward length) (right 90) (forward length) (right 90) (forward length) (right 90) (forward length) (right 90) ) (else (forward (* length (displace angle))) (right angle) (square-spiral (sqr-root (+ (* (* length (displace angle)) (* length (displace angle))) (* (* length (abs (- 1 (displace angle)))) (* length (abs (- 1 (displace angle))))) ) ) (- depth 1) angle ) (left angle) (forward (- length (* length (displace angle)))) (right 90) (forward length) (right 90) (forward length) (right 90) (forward length) (right 90) ) ) ) (define (color-helper color-code) (cond ((= color-code 0) "#00EE00") ((= color-code 1) "#008000") ((= color-code 2) "#CDCD00") ((= color-code 3) "#FFC125") ((= color-code 4) "#FFA500") ((= color-code 5) "#FF4500") ((= color-code 6) "#FF3030") ((= color-code 7) "#FF8247") ((= color-code 8) "#C6E2FF") ((= color-code 9) "#9932CC") ((= color-code 10) "#C0FF3E") ((= color-code 11) "#FF9912") (else "#8B4513" ) ) ) (pythagoras-tree 200 12)