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
No comments:
Post a Comment