Thursday, 3 June 2010
Red Dwarf (Ruby Processing Context Free DSL)
load_library 'context_free'
def setup_the_red_dwarf
@red_dwarf = ContextFree.define do
rule :red_dwarf do
5.times do |i|
angle :rotation => 72
end
end
rule :angle do
110.times do |i|
triangle :size => 1.01, :rotation => i, :y => -1, :alpha => 0.1
end
end
end
end
def setup
size 600, 600
smooth
setup_the_red_dwarf
draw_it
end
def draw
# do nothing
end
def draw_it
background 0
@red_dwarf.render :red_dwarf,
:start_x => width/2, :start_y => height/2,
:size => height/1.5, :color => [0.01, 1, 1, 0.1]
end
def mouse_clicked
draw_it
end
No comments:
Post a Comment