Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0
Showing posts with label flower. Show all posts
Showing posts with label flower. Show all posts
Thursday, 6 May 2010
A Simple flower using ruby processing context free DSL
#########################################
# A Simple context free DSL flower
# flower.rb after leaf.cfdg by apoc
#########################################
load_library 'context_free'
def setup_the_flower
@petal= ContextFree.define do
rule :flower do
circle :size => 5.0, :hue => 0.1, :saturation => 1.0, :brightness => 1.0, :alpha => 0.6
split do
12.times do |i|
petal :rotation => 30*i, :brightness => 1.0
rewind
end
end
end
rule :petal do
split do
petal_border :y => -17.5, :rotation => -30
rewind
petal_border :y => -17.5, :flip => true, :rotation => 330
end
end
rule :petal_border do
circle :size => 0.75, :hue => 0.1, :saturation => 0.8, :brightness => 0.2
petal_border :y => 0.1, :rotation => 0.17, :size => 0.995
end
end
end
def setup
size 400, 400
color_mode HSB, 1.0
background 0.1, 0.2, 0.8
smooth
setup_the_flower
draw_it
end
def draw_it
@petal.render :flower, :start_x => width/2, :start_y => height/2,
:size => height/40
end
Labels:
context free,
DSL,
flower
Tuesday, 10 November 2009
Flower in ruby-processing DSL
# flower.rb ruby-processing
load_library 'context_free'
ROT = 180*(Math.sqrt(5) - 1)
def setup_the_flower
@flower = ContextFree.define do
@rot = 0
@pet = 0
rule :start do
flower :brightness => 1.0
end
rule :flower do
@rot += ROT
@rot = @rot % 360
split do
petal :brightness => 1.0, :saturation => 0.5
rewind
flower :rotation => @rot, :size => 0.99, :hue => 0.15
rewind
end
end
rule :petal do
@pet += 15
split do
triangle :x => 4.1, :rotation => @pet
rewind
petal :size => 0.995, :alpha => 0.4, :brightness => 0.5
#rewind
end
end
end
end
def setup
size 800, 800
setup_the_flower
smooth
draw_it
save_frame("flower.png")
end
def draw
# Do nothing.
end
def draw_it
background 60, 0, 0
@flower.render :start, :size => width*0.8, :stop_size => 2,
:start_x => width/2, :start_y => height/2
end
load_library 'context_free'
ROT = 180*(Math.sqrt(5) - 1)
def setup_the_flower
@flower = ContextFree.define do
@rot = 0
@pet = 0
rule :start do
flower :brightness => 1.0
end
rule :flower do
@rot += ROT
@rot = @rot % 360
split do
petal :brightness => 1.0, :saturation => 0.5
rewind
flower :rotation => @rot, :size => 0.99, :hue => 0.15
rewind
end
end
rule :petal do
@pet += 15
split do
triangle :x => 4.1, :rotation => @pet
rewind
petal :size => 0.995, :alpha => 0.4, :brightness => 0.5
#rewind
end
end
end
end
def setup
size 800, 800
setup_the_flower
smooth
draw_it
save_frame("flower.png")
end
def draw
# Do nothing.
end
def draw_it
background 60, 0, 0
@flower.render :start, :size => width*0.8, :stop_size => 2,
:start_x => width/2, :start_y => height/2
end
Labels:
DSL,
flower,
ruby-processing
Subscribe to:
Posts (Atom)
Followers
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

