Object
Inherited by Fractal, Renderers::Base includes traits common to each of the rendering modules.
Includes the provided module. Use the renderer= method for setting the renderer at runtime.
# File lib/fractals/renderers.rb, line 81 def self.acts_as_renderer(renderer) include renderer end
Sets the default property values.
# File lib/fractals/renderers.rb, line 36 def initialize(bailout=2, max_iterations=50, algorithm=Algorithms::EscapeTime) @bailout, @max_iterations = bailout, max_iterations @algorithm = algorithm @width, @height = 300, 300 @magnification = 1.0 @theme, @set_color = Themes::Fire, [0, 0, 0] end
Determines if a complex coordinate lies within the fractal’s set.
# File lib/fractals/renderers.rb, line 45 def in_set?(c) @args[:c] = c iterate(@max_iterations) do |i, z| if z.abs > @bailout then @last_iteration = i return false end end return true end
Loops through each x, y value pair yielding the pair and its RGB color value as an array [R, G, B].
# File lib/fractals/renderers.rb, line 58 def render (0...@width).each do |x| (0...@height).each do |y| if !in_set?(where_is?(x, y)) then yield x, y, @theme.call(@algorithm.call(self)) else yield x, y, @set_color end end end end
Extends the Renderers::Base class with the provided module.
mandelbrot = Mandelbrot.new
mandelbrot.renderer = Renderers::RMagickRenderer
# File lib/fractals/renderers.rb, line 75 def renderer=(renderer) self.extend renderer end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.