Here is an animated version of the default.es from StructureSynth in ruby-processing. Mac or windows users might want to experiment with OPENGL rendering, as this sketch exposes errors in processing P3D, I see odd missing pixels from time to time. If you don't like the holes remove the smooth, personally I prefer the holes to the glitchty non-smooth (it is a known issue with current versions of processing with both P2D and P3D renderers, something to do with tessellation algorithms). The test_free library is as in previous post.
Nest the library as follows:-
library/test_free/test_free.rb in the folder containing the sketch
For instructions for installing ruby-processing follow the first link in the blog header.
# full_screen.rb
# An animation of default.es
# the StructureSynth default script
load_libraries :test_free
full_screen
attr_reader :xrot, :yrot, :zrot
def setup_the_spiral
@spiral = ContextFree.define do
rule :default do
split do
R1 :brightness => 1
rewind
R2 :brightness => 1
end
end
rule :R1 do
sphere :brightness => 1
R1 :size => 0.99, :x => 0.25, :rz => 6, :ry => 6
end
rule :R2 do
sphere :brightness => 1
R2 :size => 0.99, :x => -0.25, :rz => 6, :ry => 6
end
end
end
def setup
render_mode P3D
smooth
@xrot = 0.01
@yrot = 0
@zrot = 0
setup_the_spiral
end
def draw
background 0
lights
smooth_rotation(6.7, 7.3)
@spiral.render :default, :start_x => 0, :start_y => 0, :start_z => -50, :size => height/350,
:stop_size => 0.2, :color => [0, 0.8, 0.8], :rx => xrot, :ry => yrot, :rz => zrot
end
##
# Generate a vector whose components change smoothly over time in the range [ 0, 1 ].
# Each component uses a Math.sin() function to map the current time in milliseconds somewhere
# in the range [ 0, 1 ].A 'speed' factor is specified for each component.
#
def smooth_vector(s1, s2)
mills = millis * 0.00003
y = 0.5 * Math.sin(mills * s1) + 0.5
z = 0.5 * Math.sin(mills * s2) + 0.5
vec = [y, z]
end
##
# Rotate the current coordinate system.
# Uses smooth_vector() to smoothly animate the rotation.
#
def smooth_rotation(s1, s2)
r1 = smooth_vector(s1, s2)
@yrot = (2.0 * Math::PI * r1[0])
@zrot = (2.0 * Math::PI * r1[1])
end
Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0
Saturday, 11 September 2010
Subscribe to:
Post Comments (Atom)
Followers
Blog Archive
-
▼
2010
(73)
-
▼
September
(15)
- Basic Hair Example SunflowAPIAPI just using jruby
- Basic Hair Example SunflowAPIAPI in ruby processing
- 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
- I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2
No comments:
Post a Comment