A somewhat optimized sketch, makes use of processing pixel array functionality, takes a little time to "warm-up". Original used P3D mode, probably should have been P2D (apparently better than default for pixel array type sketches)....
##################################################
# 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(640, 480, P2D)
color_mode(RGB, 1.0)
frame_rate(4)
load_pixels()
reset
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
begin
pixels[y * width + x] = col
rescue
reset
end
end
end
update_pixels()
@k += 1
end
def reset
@k = 0
@time = 0
end
Here is my blog in which I will describe my experiments with ruby-processing, find out more about ruby-processing at:- http://wiki.github.com/jashkenas/ruby-processing and http://github.com/jashkenas/context_free for the cfdg DSL (context-free-art)
Saturday, 30 October 2010
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2010
(73)
-
►
September
(15)
- Basic Hair Example SunflowAPIAPI just using jruby
- Basic Hair Example SunflowAPIAPI in ruby processin...
- SunflowAPIAPI in ruby processing
- A Staffordshire Knot Using Ruby Processing and A C...
- An Infinity Loop? With My 3D Context Free Library
- Revised 3D Context Free DSL Sketch, with Mouse Whe...
- A Mouse Wheel Listener in Ruby Processing
- 3D Context Free DSL Screen Saver?
- Translating the default.es to ruby processing DSL
- Testing the cube primitive in my context free DSL
- Experimental 3D Context Free DSL in ruby-processin...
- Using the control panel and Toxi Processing Libra...
- Tone map example of Gray-Scott diffusion using tox...
- Another Example of Using Toxi Processing Libraries...
- Using the Toxi Processing Libraries in ruby proces...
-
►
September
(15)
About Me
- monkstone
- Consolidating my online identity as monkstone. I am a 64 bit linux user and advocate of open source software, you can sometimes find me on the processing forum.

0 comments:
Post a Comment