Heighway Dragon

canvasfractals

The Heighway dragon (also known as the Harter–Heighway dragon or the Jurassic Park dragon) was first investigated by NASA physicists John Heighway, Bruce Banks, and William Harter. It was described by Martin Gardner in his Scientific American column Mathematical Games in 1967. It is a self-similar fractal curve, which can be approximated by recursive methods such as Lindenmayer systems. See https://github.com/rm-hull/lindenmayer-systems for examples of other fractal curves

1 Apr 2013 by rm-hull
rm-hull/5285431
heighways-dragon.cljs
(ns lindenmayer-systems.demo
  (:use [turtle.core :only [draw!]]
        [turtle.renderer.canvas :only [->canvas]]
        [enchilada :only [ctx canvas]]
        [jayq.core :only [show]]))
          
(def dragon-seq
  "Unfolding the dragon"
  (letfn [(seq0 [x y] 
            (lazy-seq (cons (flatten x) (seq0 [x :right 90 y :fwd 20] [:fwd 20 x :left 90 y]))))]
    (seq0 [] [])))

(show canvas)

(draw! (->canvas ctx) (nth dragon-seq 13) [800 600])