Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
… is a library for Ruby-Processing that allows you to draw context-free sketches using a small declarative DSL. You can define rules which call one another probabilistically. The following block of code is the complete definition for drawing a fractal fern [samples/fern.rb] :
@fern = ContextFree.define do rule :start do fern :rotation => 50, :hue => 0.8 end rule :fern do circle :size => 0.75, :rotation => -10 split do fern :size => 0.92, :y => -2, :rotation => -5, :hue => 0.85 rewind fern :size => 0.5, :y => -2, :rotation => 90 rewind fern :size => 0.5, :y => -2, :rotation => -90 end end end
With a little processing glue, produces:
There are several other samples — tree.rb, city.rb, and vine.rb — if you have one to contribute, please do.