Class: Fractals::Fractal
- Inherits:
-
Renderers::Base
- Object
- Renderers::Base
- Fractals::Fractal
- Defined in:
- lib/fractals.rb
Overview
The Fractal base class.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#args ⇒ Object
A Hash of arguments used in the fractal’s expression.
-
#c ⇒ Object
The complex number seed.
-
#expression ⇒ Object
The fractal’s expression as a block.
Attributes inherited from Renderers::Base
#algorithm, #bailout, #height, #last_iteration, #magnification, #max_iterations, #set_color, #theme, #width
Instance Method Summary collapse
-
#initialize(c, args, &expression) ⇒ Fractal
constructor
Sets the default property values.
-
#iterate(n) ⇒ Object
Iterates the fractal’s expression n times yielding the iteration number and result.
Methods inherited from Renderers::Base
acts_as_renderer, #in_set?, #render, #renderer=, #where_is?
Constructor Details
#initialize(c, args, &expression) ⇒ Fractal
Sets the default property values.
46 47 48 49 |
# File 'lib/fractals.rb', line 46 def initialize(c, args, &expression) @c, @args, @expression = c, args, expression super() end |
Instance Attribute Details
#args ⇒ Object
A Hash of arguments used in the fractal’s expression.
39 40 41 |
# File 'lib/fractals.rb', line 39 def args @args end |
#c ⇒ Object
The complex number seed.
37 38 39 |
# File 'lib/fractals.rb', line 37 def c @c end |
#expression ⇒ Object
The fractal’s expression as a block.
41 42 43 |
# File 'lib/fractals.rb', line 41 def expression @expression end |
Instance Method Details
#iterate(n) ⇒ Object
Iterates the fractal’s expression n times yielding the iteration number and result.
53 54 55 56 57 58 59 |
# File 'lib/fractals.rb', line 53 def iterate(n) @args[:z] = @args[:c] n.times do |i| @expression.call(@args) yield i, @args[:z] end end |