Here I describe how you can extend the ruby processing context free DSL. Previously I overrode the triangle method, but as Jeremy (Ashkenas) pointed out to me in a personal communication I could just as easily define a new terminal (this may lead to further experimentation).
load_library 'context_free'
def setup_the_spiral
@spiral= ContextFree.define do
############ Begin defining custom terminal, an isoceles triangle
class << self
define_method(:isoceles) do |some_options| # isoceles triangle
size, options = *self.get_shape_values(some_options)
rot = options[:rotation]
rotate(rot) if rot
super.triangle(-0.5 * size, -0.5 * size, -0.5 * size, 0.5 * size, 0.5 * size, 0.5 * size)
rotate(-rot) if rot
end
end
########### End definition of custom terminal 'isoceles'
rule :spiral do
isoceles :brightness => -1, :rotation => 90
spiral :rotation => 135, :size => 1/sqrt(2), :x => 1/sqrt(2)
end
end
end
I've added a white border using Gimp otherwise the image gets lost in my background.
Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0
Tuesday 20 April 2010
Adding a custom terminal in ruby-processing context-free DSL
Labels:
context free,
DSL,
isoceles triangle
Subscribe to:
Post Comments (Atom)
Followers
Blog Archive
-
▼
2010
(73)
-
▼
April
(10)
- Using the Voronoi library in ruby processing
- Moire patterns from custom bar shape Context free DSL
- Faux barcode using ruby-processing Context Free DSL
- Adding a custom terminal in ruby-processing contex...
- How to Draw a Tree in Processing
- Terse Code to use file chooser in Ruby Processing
- Another funky random sketch with perlin noise
- An Translation Exercise (Very Clever Pseudo 3D Ani...
- Live Editing Ruby-Processing from jEdit
- Plasma fractal (and carpet)
-
▼
April
(10)
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