Approximate Cesàro fractal loosely based on mariojan C++ version.
load_library 'context_free'
def setup_the_triangle
@triangle = ContextFree.define do
class << self
define_method(:wedge) do |some_options| # thin triangle
size, options = *get_shape_values(some_options)
rot = options[:rotation]
rotate(rot) if rot
super.triangle(-0.03 * size, 0, 0, -size, 0.03 * size, 0)
rotate(-rot) if rot
end
end
rule :tri do
wedge :y => -0.5
split do
[90, -90, 180, 0].each do |rot|
rewind
tri :y => 0.66667, :rotation => rot, :size => 0.5, :set_brightness => 1, :set_saturation => 1, :set_alpha => 1
rewind
end
end
end
rule :four do
split do
4.times do |i|
split do
tri :rotation => 90 * i
rewind
end
end
end
end
rule :cesaro do
four :rotation => 45
end
end
end
def setup
size 400, 400
setup_the_triangle
no_stroke
color_mode HSB, 1.0
smooth
draw_it
end
def draw_it
background 0, 0.1, 0.1, 1.0
@triangle.render :cesaro, :size => height * 1.05, :stop_size => 3, :start_y => height/2, :start_x => width/2, :color => [0, 0.8, 0.8, 0.2]
end
Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0
Wednesday, 16 June 2010
Cesàro fractal using ruby processing context free DSL.
Labels:
cesaro,
context free,
DSL,
ruby processing
Subscribe to:
Post Comments (Atom)
Followers
Blog Archive
-
▼
2010
(73)
-
▼
June
(6)
- Cesàro fractal using ruby processing context free ...
- Exploring Dynamic Randomness in ruby-processing co...
- Towards an Escher Bird Tiling (Ruby processing con...
- Weird Flower Ruby Processing Context Free DSL
- Alhambra Tiling Ruby Processing Context Free DSL
- Red Dwarf (Ruby Processing Context Free DSL)
-
▼
June
(6)
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