################################################################# # A non deterministic sketch run it until you get a result you like # uncomment "srand 5" to get a more deterministic result. It looked # pretty good on my linux box (however I'm not sure how universal the # random seeding is in jruby) ################################################################# require 'cf3' def setup_the_tree @tree = ContextFree.define do shape :trunk, 20 do # rule has a probability weighting of 20 circle size: 0.25, brightness: 0.5 # giving an actual probability = 0.952381 scraggle y: -0.1 # the minus is require by the upside down coordinate system end shape :trunk, 1 do # rule has a probability weighting of 1 branch size: 0.7 # giving an actual probability = 0.047619 end shape :trunk, 0.02 do # empty rule top stop early end shape :branch do split do # split is like a branch, rewind returns original context trunk rotation: 10 rewind trunk rotation: -10 end end shape :scraggle do # without an explicit weighting trunk rotation: 5 # probability of each scraggle rule end # is 0.5 shape :scraggle do trunk rotation: -5 end end end def setup size 600, 600 srand 5 smooth setup_the_tree background 255 # NB color mode here is "RGB 255", within context free definition draw_it # the color mode is "HSB 1.0", supports :hue, :saturation, :brightness save_frame "/home/tux/tree4.png" end def draw_it @tree.render :trunk, start_x: width/2, start_y: height * 0.9, stop_size: height/150, size: height/15 end
Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0
Tuesday, 18 December 2012
Context Free Tree in cf3ruby
Labels:
context free DSL,
ruby-cf3,
ruby-processing,
tree
Subscribe to:
Post Comments (Atom)
Followers
Blog Archive
-
▼
2012
(26)
-
▼
December
(17)
- Bezier Patch as a VBO (PShape)
- Bezier Patch in ruby-processing
- Rotating Arcs Sketch in Ruby Processing
- Context free sketch in regular ruby processing
- Exporting cf3ruby directly to 'large' pdf
- Context Free Tree in cf3ruby
- New context_free.rb (cf3ruby)
- MeshToVBO conversion ruby-processing
- Fix for ruby-processing context free
- What works what does not and may not
- Retained Shape (FBO) in Ruby Processing
- Creating a Mock Vanilla Processing Distribution
- Landscape shader in ruby-processing
- Fish-eye shader revisited with ruby-processing and...
- PShader Example in ruby-processing
- A 3D-texture example with my hacked ruby-processing
- Testing ruby-processing with processing-2.0
-
▼
December
(17)
About Me
- monkstone
- I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2
No comments:
Post a Comment