Skip to content
This repository
Browse code

Added triangle to library and tri.rb to test it

	new file:   samples/tri.rb
	modified:   context_free.rb
	deleted:    samples/creature.png
	modified:   samples/sun.png
  • Loading branch information...
commit 4a4ec215cfb5240eccbf950df22db27a9d229e99 1 parent 4d11d1e
authored August 21, 2009

Showing 1 changed file with 50 additions and 0 deletions. Show diff stats Hide diff stats

  1. 50  samples/tri.rb
50  samples/tri.rb
... ...
@@ -0,0 +1,50 @@
  1
+# dark_star.rb ruby-processing
  2
+load_library 'context_free'
  3
+
  4
+def setup_the_sun
  5
+        @sun = ContextFree.define do
  6
+                rule :start do
  7
+                        rot = 0
  8
+                        split do
  9
+                                3.times do
  10
+                                        legs :rotation => rot
  11
+                                        rot += 80
  12
+                                        rewind
  13
+                                end
  14
+                                legs :rotation => 360
  15
+                        end
  16
+                end
  17
+                rule :legs do
  18
+			triangle                       
  19
+                        legs :rotation => 1, :y => 0.1,
  20
+                        :size => 0.965, :color => [0.22, 0.15], :alpha => 0.5
  21
+                end
  22
+        end
  23
+end
  24
+                
  25
+def setup
  26
+        size 600, 600
  27
+        setup_the_sun
  28
+        no_stroke
  29
+        color_mode HSB, 1.0
  30
+        smooth
  31
+        draw_it
  32
+        save_frame("sun.png")
  33
+end
  34
+
  35
+
  36
+def draw
  37
+        # Do nothing.
  38
+end
  39
+
  40
+
  41
+def draw_it
  42
+        background 1.0
  43
+        @sun.render :start, :size => height/7,  :stop_size => 0.8,
  44
+        :start_x => width/2, :start_y => height/2 
  45
+end
  46
+
  47
+
  48
+def mouse_clicked
  49
+        draw_it
  50
+end

0 notes on commit 4a4ec21

Please sign in to comment.
Something went wrong with that request. Please try again.