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.
No comments:
Post a Comment