;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; NAME: fractal-examples.scm ;; ;; DESCRIPTION: An example of three cool fractals. Evaluate the ;; entire file, then manually evaluate the "demo-..." ;; for cool animations. ;; ;; AUTHOR: Dan Garcia - University of California at Berkeley ;; Copyright (C) Dan Garcia, 2001. All rights reserved. ;; ;; DATE: 2001-09-21 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;; ;; FRACTAL -- SYBASE LOGO ;;;;;;;;;;;;;;;;;;;;;;;;; (define *gr* (/ (+ 1 (sqrt 5)) 2)) (define (sybase P1 P2 n) (let ((PUL (coord P1 P2 (mP (/ -1 *gr*) 0))) (PUR (coord P1 P2 (mP (/ -1 *gr*) 1)))) (draw-poly-lineP P1 PUL PUR P2) (sh P1 P2 n))) (define (sh P1 P2 n) (draw-lineP P1 P2) (if (<= n 0) 'done (let* ((PM (coord P1 P2 (mP 0 (/ 1 *gr*)))) (PU (coord P1 PM (mP -1 1)))) (draw-arcP PM PU 90 20) (sh PU PM (- n 1))))) (define (demo-sybase) (grow-fractal (lambda (i) (sybase (addP *SW* (mP 10 10)) (addP *SE* (mP -10 10)) i)) 1 8)) ;; (demo-sybase) ;;;;;;;;;;;;;;;;;;;;; ;; FRACTAL -- BIGTREE ;;;;;;;;;;;;;;;;;;;;; ;; HOUSE (define (house BL BR TR TL C level) (draw-lineP BL TL) (draw-lineP BR TR) (if (= level 0) (begin (draw-line-toP C) (draw-line-toP TL)))) ;; DRAW-BIGTREE (define (draw-bigtree BL BR level) (let* ((TL (coord BL BR (mP -1/2 0))) (TR (coord BL BR (mP -1/2 1))) (C (coord BL BR (mP -1 1/2)))) (house BL BR TR TL C level) (if (<= level 0) 'done (begin (draw-bigtree TL C (- level 1)) (draw-bigtree C TR (- level 1)))))) (define (demo-bigtree) (grow-fractal (lambda (i) (draw-bigtree (avgP *S* (avgP *S* *SW*)) (avgP *S* (avgP *S* *SE*)) i)) 1 7)) ;; (demo-bigtree) ;;;;;;;;;;;;;;;;;;;; ;; FRACTAL -- FLOWER ;;;;;;;;;;;;;;;;;;;; ;;;;;;;;; ;; FLOWER ;;;;;;;;; (define (flower P1 P2 n) (draw-lineP P1 (avgP P1 P2)) (if (<= n 0) 'done (let ((M (avgP P1 P2)) (L (coord P1 P2 (mP -1/2 1/2))) (R (coord P1 P2 (mP 1/2 1/2)))) (flower M L (- n 1)) (flower M R (- n 1))))) (define (demo-flower) (grow-fractal (lambda (i) (flower *S* *N* i)) 1 7)) ;; (demo-flower)