;;; HEAVY WEIGHT SUMBMISSION ;;;Taewook Ha and Grant Merrill ;;;cs61a-af cs61a-ay ;;;heavyweight competition (speed 0) (define (drawing-trees length depth segments) (cond ((= depth 0) (pythagoras-tree length 50) ) (else (pythagoras-tree length 50) (right 90) (forward length) (right (/ 360 segments)) (left 90) (drawing-trees length (- depth 1) segments) ) ) ) (define (pythagoras-tree length depth) (cond ((= depth 0) (color (color-helper depth)) (square-spiral length 20 10) ) (else (color (color-helper depth)) (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 (sierpinski length depth) (cond ((> depth 5) (sierpinski length 5) ) ((= depth 0) (forward (sqr-root (/ (* length length) 2) ) ) (right 90) (forward (sqr-root (/ (* length length) 2) ) ) (right 135) (forward length) (right 135) ) (else (sierpinski (/ length 2) (- depth 1)) (forward (/ (sqr-root (/ (* length length) 2) ) 2)) (sierpinski (/ length 2) (- depth 1)) (forward (/ (sqr-root (/ (* length length) 2) ) 2)) (right 90) (forward (sqr-root (/ (* length length) 2) )) (right 135) (forward (/ length 2)) (right 135) (sierpinski (/ length 2) (- depth 1)) (left 135) (forward (/ length 2)) (right 135) ) ) ) (define (sierpinski-tri-square length depth) (right 10) (sierpinski length depth) (left 45) (forward length) (right 135) (sierpinski length depth) (left 45) (forward length) (right 135) (sierpinski length depth) (left 45) (forward length) (right 135) (sierpinski length depth) (right 45) (left 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" ) ) ) (drawing-trees 1000 10 10)