;;; Scheme Recursive Art Contest Entry ;;; ;;; Please do not include your name or personal info in this file. ;;; ;;; Title: Let there be night ;;; ;;; Description: ;;; When the moon has risen and everything is quiet, ;;; start your computer and start to write, ;;; because the best code is composed at night. (define (draw) ;;; Draws three perfectly balanced binary trees. ;;; -Big tree: Height of 12 with 4095 nodes and 2048 leaves ;;; -Mid tree: Height of 10 with 1023 nodes and 512 leaves ;;; -Small tree: Height of 9 with 511 nodes and 256 leaves ;variables (define angle 20) (define factor 1.2) (define start-length 105) (define tree-colors (list "#004C00" "#005E00" "#007000" "#008200" "#009400" "#00A600" "#00B700" "#00C900" "#00DB00" "#00ED00" "#00FF00")) (define leaf-color "#FF0000") (define background-colors (list "#000000" "#0C0C0F" "#18181E" "#24242D" "#30303C" "#3C3C4B" "#49495A" "#555569" "#616178" "#6D6D87")) (define moon-color "#EFEFEF") (define lambda-color "#606060") (define heigth 690) (define width 1320) (define moon-radius 80) (define (get-color s i) (cond ((null? s) nil) ((= i 0) (car s)) (else (get-color (cdr s) (- i 1))) ) ) (define (draw-picture length level max-level leaf-radius) (cond ((> level max-level) (rt 90) (fd leaf-radius) (lt 90) (color leaf-color) (begin_fill) (circle leaf-radius) (end_fill) (rt 90) (bk leaf-radius) (lt 90) (color (get-color tree-colors (- level 1))) (pu) (bk (* factor length)) (pd) ) (else (color (get-color tree-colors level)) (lt angle) (fd length) (draw-picture (/ length factor) (+ level 1) max-level leaf-radius) (rt (* 2 angle)) (fd length) (draw-picture (/ length factor) (+ level 1) max-level leaf-radius) (lt angle) (if (> level 0) (color (get-color tree-colors (- level 1))) ) (pu) (bk (* factor length)) (pd) ) ) ) (define (draw-moon) (pu) (rt 90) (fd (- (/ width 2) 60)) (lt 90) (fd (- heigth moon-radius 40)) (pd) (color moon-color) (begin_fill) (circle moon-radius) (end_fill) ;lambda start (pu) (fd 37) (lt 90) (fd 95) (pd) (color lambda-color) (rt 180) (fd 10) (rt 70) (fd 25) (rt 45) (fd 50) (bk 50) (lt 45) (fd 50) (lt 90) (fd 10) (pu) (bk 10) (rt 90) (bk 75) (lt 70) (fd 85) (lt 90) (bk 37) ;lambda end (bk (- heigth moon-radius 40)) (lt 90) (fd (- (/ width 2) 60)) (rt 90) (pd) ) (define (draw-background level) (cond ((= level 10) (pu) (bk heigth) (pd) ) (else (color (get-color background-colors level)) (begin_fill) (fd (/ heigth 10)) (rt 90) (fd width) (rt 90) (fd (/ heigth 10)) (rt 90) (fd width) (rt 90) (end_fill) (pu) (fd (/ heigth 10)) (pd) (draw-background (+ level 1)) ) ) ) (define (draw-frame) (color "#000000") (fd heigth) (rt 90) (fd width) (rt 90) (fd heigth) (rt 90) (fd width) (bk (/ width 2)) (rt 90) ) ;setup (speed 0) (ht) (pu) (bk (/ heigth 2)) (lt 90) (fd (/ width 2)) (rt 90) (draw-background 0) (draw-frame) (draw-moon) (pu) (lt 90) (fd 195) (rt 90) ;big tree (pd) (color (get-color tree-colors 0)) (fd (* factor start-length)) (draw-picture start-length 0 10 2) (pu) (lt 90) (fd 90) (rt 90) ;small tree (pd) (color (get-color tree-colors 0)) (fd (* factor (/ start-length 2.1))) (draw-picture (/ start-length 2.1) 0 7 1) (pu) (rt 90) (fd 710) (lt 90) ;mid tree (pd) (color (get-color tree-colors 0)) (fd (* factor (/ start-length 1.9))) (draw-picture (/ start-length 1.9) 0 8 1) (exitonclick)) ; Please leave this last line alone. You may add additional procedures above ; this line. (draw)