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

Thursday, 15 April 2010

Another funky random sketch with perlin noise

Heres a processing sketch I found over at biothing.org that I've given the ruby treatment.



##################################################
# amp_zoom_in.rb
# adapted from a sketch at http://www.biothing.org
##################################################
attr_reader :col, :a, :b, :c, :k, :amp, :time

def setup()
  size(320, 240, P3D)
  color_mode(RGB, 1.0)
  frame_rate(4)
  load_pixels()
  @time = 0
  @k = 0
end

def draw()
  @time += 0.1   #step ahead in time with each frame
  #now go through each pixel in the window:

  (0...width).each do |x|
    (0...height).each do |y|
      #create values with trig functions, noise, etc acting on x,y and time.  
      #experiment with how these values are modulating over time.

      @a = dist(x,y,width/2,height/2)
      @b=(cos(x/360.0 + time)).abs          # frequency larger # means less
      @c = noise(y/180.0*cos(time/20.0))    # inteference larger # means less

      @amp = k                              # amplitude

      @col = color((cos(a/120.0 + b + c * 10.0).abs)) * amp  
      #combine values into a color somehow.  again the possibilities are limitless
      set(x, y, col)
    end
  end
  update_pixels()
  @k += 1
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