;;; Scheme Recursive Art Contest Entry ;;; ;;; Please do not include your name or personal info in this file. ;;; ;;; Inspiration & Thx: https://www.zhihu.com/question/271643290/ ;;; ;;; Title: A Random Tree and Blossom ;;; ;;; Description: ;;; Plum blossoms from the bitter cold. ;;; 梅花香自苦寒来。 ;;; Does pseudorandom == random? (define (rand_seq s) (modulo (+ (* s 69069) 1) (expt 2 32))) (define (rand s) (cons-stream (/ (rand_seq s) (expt 2 32)) (rand (rand_seq s)))) (define a (rand 5201314)) (define (random) (set-car! a (car (cdr-stream a))) (set-cdr! a (cdr (cdr-stream a))) (car a) ) (define (tree n l hd) (pd) (define t (+ 0.25 (/ (cos (radians (+ hd 45))) 8))) (color (rgb t t t)) (branch (/ n 3) l) (cond ((> n 0) (define lb (+ 10 (* 15 (random)))) (define rb (+ 10 (* 15 (random)))) (define nl (* l (+ 0.7 (* (random) 0.25)))) (rt rb) (tree (- n 1) nl (+ hd rb)) (lt (+ lb rb)) (tree (- n 1) nl (- hd lb)) (rt lb) ) (else (rt 90) (define n (+ 0.5 (/ (cos (radians (- hd 45))) 4))) (color (rgb n (* n 0.4) (* n 0.4))) (circle 3) (lt 90) ) ) (cond ((> (random) 0.8) (pu) (define t (- hd 90)) (define angle (+ 90 (* (random) 40))) (seth angle) (define dis (+ 80 (* (random) 400))) (fd dis) (seth t) (pd) (rt 90) (define n (+ 0.5 (/ (cos (radians (- hd 135))) 4))) (color (rgb (+ 0.5 (* n 0.5)) (+ 0.2 (* n 0.2)) (+ 0.2 (* n 0.2)))) (circle 2) (lt 90) (pu) (define t (- hd 90)) (seth angle) (bk dis) (seth t) )) (pu) (bk l) ) (define (draw) (bgcolor (rgb 0.5 0.5 0.5)) (hideturtle) (tracer) ; (speed 0) (seth 0) (pu) (bk 330) (tree 12 100 90) ) (define (branch w l) (begin_fill) (fd l) (rt 90) (fd w) (rt 90) (fd l) (rt 90) (end_fill) (fd w) (rt 90) (fd l) ) (draw) ; Please leave this last line alone. You may add additional procedures above ; this line.