Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0
Saturday, 24 April 2010
Moire patterns from custom bar shape Context free DSL
#########################
# donut.rb inspired by Lekkere donut by marksmit
# uses a custom vbar terminal
#########################
load_library 'context_free'
def setup_the_moire
@moire = ContextFree.define do
############ Begin defining custom terminal, a proportional vertical bar
class << self
define_method(:vbar) do |some_options|
size, options = *self.get_shape_values(some_options)
w = some_options[:w]|| 0.1 # default vbar width is 0.1
ratio = w * size
rot = options[:rotation]
rect_mode(CENTER)
rotate(rot) if rot
rect(-0.5 * ratio, -0.5 * size, 0.5 * ratio, 0.5 * size)
rotate(-rot) if rot
end
end
########### End definition of custom terminal 'vbar'
rule :donut do
split do
360.times do
ring :brightness => 1, :rotation => 1
end
end
end
rule :ring do
rot = 2
split do
30.times do |i|
element :brightness => 1, :rotation => rot * i
rewind
end
end
end
rule :element do
vbar :size => 10, :w => 0.005, :brightness => 1
end
end
end
def setup
size 400, 400
background 255, 255, 0
smooth
no_stroke
setup_the_moire
draw_it
end
def draw_it
@moire.render :donut, :start_x => width/2, :start_y => height/2,
:size => height/15, :stop_size => 1, :color => [0, 1, 1]
end
Labels:
context free,
custom shape,
DSL,
ruby processing
Subscribe to:
Post Comments (Atom)
Followers
Blog Archive
-
▼
2010
(73)
-
▼
April
(10)
- Using the Voronoi library in ruby processing
- Moire patterns from custom bar shape Context free DSL
- Faux barcode using ruby-processing Context Free DSL
- Adding a custom terminal in ruby-processing contex...
- How to Draw a Tree in Processing
- Terse Code to use file chooser in Ruby Processing
- Another funky random sketch with perlin noise
- An Translation Exercise (Very Clever Pseudo 3D Ani...
- Live Editing Ruby-Processing from jEdit
- Plasma fractal (and carpet)
-
▼
April
(10)
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