Here's another ruby-processing context-free DSL example:-
# tunnel.rb ruby-processing
load_library 'context_free'
def setup_the_tunnel
@tunnel = ContextFree.define do
rule :start do
body :brightness => 1.0
end
rule :body do
square :brightness => 0.6
square :size => 0.996, :brightness => 0.3
body :size => 0.994, :rotation => 0.12
end
end
end
def setup
size 500, 500
setup_the_tunnel
color_mode HSB, 360, 1, 1
smooth
draw_it
save_frame("tunnel.png")
end
def draw
# Do nothing.
end
def draw_it
background 0
@tunnel.render :start, :size => height, :stop_size => 2,
:start_x => width/2, :start_y => height/2
end
No comments:
Post a Comment