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

Friday 11 June 2010

Exploring Dynamic Randomness in ruby-processing context-free DSL

Here is a context free sketch that really needs to be run to appreciate it (links to library download at github above). I'm not sure why the bands don't fit edge to edge, still it does not spoil the effect. There is definitely an illusion of lateral movement with the colored bands, further owing to persistence of vision, the circles and squares seem to dissolve into each other.

load_library 'context_free'


def setup_the_streak

  @streak = ContextFree.define do

    rule :streak do
      split do
      10.times do |j|
        lines :y => j
        rewind
      end
      end
    end
    rule :lines do
      split do
      10.times do |i|
        tri :x => i
        rewind
      end
    end
    end
 
    rule :tri do
      square :size => 1.0, :color => [rand, 1.0, 1.0, 1.0]
    end
 
    rule :tri do
      circle :size => 1.0, :color => [rand, 1.0, 1.0, 1.0]
    end
  end

end

def setup
  size 600, 600
  color_mode HSB, 1.0
  setup_the_streak
  no_stroke
  smooth
  draw_it
end

def draw_it
  background 0.1
  @streak.render :streak, :size => height/9, :stop_size => 3, :start_y => 0, :start_x => 0
end

def draw
  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