Vector Drawings

Here are some scalable vector drawings made with Clojure. Only the stoke attribute of SVG is used. With drawing on plotters in mind.

The drawings are defined by rules. Some random variables are involved into the process.

The style is like computer-generated art created in the 1960s by Frieder Nake, Vera Molnar, A. Michael Noll and others.

Fibonacci sphere

(use 'grow.core)
(template-svg)

(grow
  (rule C
    (emit ["sphere"] :scale [(scale (/ 200 (v3-len (v3-set-z 0 (coord)))))])
  )

  (rule G
    (generator [C] (sphere-fibonacci 400 100))
  )
  
  (start G 99)
)

Dots and Squares

(use 'grow.core)
(template-svg)
(trait {:stroke-width 0.1 } )

(grow
  (def noise-sample 0.05)
  (def step-size 16)
  (def noise-scale (* 0.9 step-size))
  (def noise-move (* -0.5 noise-scale))
  
  (rule S
    (emit ["sphere"] :coord [(translate (v3-move noise-move
                                                 (v3-noise (coord) noise-sample noise-scale)))]
                     :scale [(scale (* 0.35 step-size))]
                     :color cBlack)
    (invoke S :scale [(scale 0.7)])
  )

  (rule C
    (emit ["cube"] :scale [(scale (* 0.8 step-size))]
                   :color cBlack)
    (invoke S)
  )

  (rule G
    (generator [C] (grid 11 11 1 step-size))
  )
  
  (start G 6)
)

Lines and noise

(use 'grow.core)
(template-svg)
(trait {:stroke-width 0.1 } )

(grow
  (def lines 125)
  (def segements 175)
  
  (rule P
    (emit ["line_point"])
  )

  (rule T
    (invoke P :coord [(translate 0 (noise (coord) 0.1 10) 0)])
  )

  (rule L
    (emit ["line_base"])
    (generator [T] (grid segements 1 1 1))
    (emit ["line_end"])
  )
  
  (rule G
    (generator [L] (grid 1 lines 1 1))
  )
  
  (start G 40)
)

Nested rectangles

(use 'grow.core)
(template-svg)
(trait {:stroke-width 0.1 } )

(grow
  (rule T
    (emit ["cube"] :scale  [(scale 16)])
    (if (or (rnd-boolean) (rnd-boolean))
      (invoke T :scale  [(scale 0.8)]
                :rotate [(rotate-z (rnd-gaussian (noise (coord) 0.05 0.1)))]))
  )

  (rule G
    (generator [T] (grid 11 11 1 18))
  )
  
  (start G 23)
)

OpArt spiral

(use 'grow.core)
(template-svg)

(grow
  (rule C
    (emit ["cube"] :scale [(scale (Math/log (v3-len (coord))))]
                   :color cBlack)
  )

  (rule G
    (generator [C] (spiral 400 0.25 mPi24 0))
  )
  
  (start G 99)
)

Software used