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

Thursday 3 June 2010

Red Dwarf (Ruby Processing Context Free DSL)


load_library 'context_free'

def setup_the_red_dwarf
  @red_dwarf = ContextFree.define do
  
    rule :red_dwarf do  
      5.times do |i|
        angle :rotation => 72
      end    
    end
  
    rule :angle do
      110.times do |i|
        triangle :size => 1.01, :rotation => i, :y => -1, :alpha => 0.1
      end
    end
  
  end
end

def setup
  size 600, 600
  smooth
  setup_the_red_dwarf
  draw_it
end

def draw
  # do nothing
end

def draw_it
  background 0
  @red_dwarf.render :red_dwarf,
               :start_x => width/2, :start_y => height/2,
               :size => height/1.5, :color => [0.01, 1, 1, 0.1]
end

def mouse_clicked
  draw_it
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