Binary branching - fractal

The Scheme code (in part):
(define (fractal phase r w n k)
  (if (> n 0)
      (let* ((theta (* phase pi/3))
             (x (* r (cos theta)))
             (y (* r (sin theta)))
             (r (* r k)))
        (set-line-width w
          (overlay (segment (vec x y))
                   (at x y (fractal (phase+1 phase)
                                    r (* w k) (- n 1) k))
                   (at x y (fractal (phase-1 phase)
                                    r (* w k) (- n 1) k)))))
      null-box))

(define (make-fractal r w n)
  (let* ((k 0.618)
	 (box (overlay (fractal 0 r w n k)
		       (fractal 2 r w n k)
		       (fractal 4 r w n k))))
    (draw-to-file-for-png "fractal" box)))

(define pi (acos -1))
(define pi/3 (/ pi 3))
(define (phase+1 phase) (if (= phase 5) 0 (+ phase 1)))
(define (phase-1 phase) (if (= phase 0) 5 (- phase 1)))

(make-fractal (* points-per-inch 1.5) 2 9)

Creative
								Commons
								License
Fractal tree (image and code) by Jonathan A. Rees is licensed under a Creative Commons Attribution 3.0 Unported License.
Based on a work at mumble.net.
back to visuals