Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0

Wednesday 23 September 2009

Tunnel a popular theme in context free

Here's another ruby-processing context-free DSL example:-

# tunnel.rb ruby-processing
load_library 'context_free'

def setup_the_tunnel
  @tunnel = ContextFree.define do
    rule :start do
      body :brightness => 1.0
    end
    rule :body do
      square :brightness => 0.6
      square :size =>  0.996, :brightness => 0.3
      body  :size =>  0.994, :rotation => 0.12
    end
  end
end


def setup
  size 500, 500
  setup_the_tunnel
  color_mode HSB, 360, 1, 1
  smooth
  draw_it
  save_frame("tunnel.png")
end


def draw
  # Do nothing.
end


def draw_it
  background 0
  @tunnel.render :start, :size => height,  :stop_size => 2,
        :start_x => width/2, :start_y => height/2
end



 

No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2