Browse files

Committer: Martin Prout <martin_p@lineone.net>

 Changes to be committed:
	modified:   context_free.rb
	new file:   samples/dragon.rb
  • Loading branch information...
1 parent ed79110 commit b915cbab5530a32a54771610e0f1590681eed76b Martin Prout committed with Nov 8, 2009
Showing with 41 additions and 1 deletion.
  1. +1 −1 context_free.rb
  2. +40 −0 samples/dragon.rb
View
2 context_free.rb
@@ -175,7 +175,7 @@ def render(rule_name, starting_values={})
@app.rect_mode CENTER
@app.ellipse_mode CENTER
@app.no_stroke
- @app.color_mode HSB, 1.0, 1.0, 1.0, 1.0
+ @app.color_mode HSB, 1.0
@app.translate @values[:start_x], @values[:start_y]
self.send(rule_name, {})
end
View
40 samples/dragon.rb
@@ -0,0 +1,40 @@
+# dragon.rb ruby-processing NB: :alpha is not implemented in vanilla ruby-processing
+load_library 'context_free'
+
+def setup_the_dragon
+ @dragon = ContextFree.define do
+ rule :start do
+ dragon :alpha => 1
+ end
+ rule :dragon do
+ square :hue => 0, :brightness => 1, :saturation => 1, :alpha => 0.01
+ split do
+ dragon :size => 1/Math.sqrt(2), :rotation => -45, :x => 0.25, :y => 0.25
+ rewind
+ dragon :size => 1/Math.sqrt(2), :rotation => 135, :x => 0.25, :y => 0.25
+ rewind
+ end
+ end
+ end
+end
+
+
+def setup
+ size 600, 400
+ setup_the_dragon
+ smooth
+ draw_it
+ save_frame("dragon.png")
+end
+
+
+def draw
+ # Do nothing.
+end
+
+
+def draw_it
+ background 255
+ @dragon.render :start, :size => width*0.8, :stop_size => 2,
+ :start_x => width/3, :start_y => height/3
+end

0 comments on commit b915cba

Please sign in to comment.