common
Class DirectColoring

Object
  extended by common:Generic
      extended by common:Coloring
          extended by common:DirectColoring
Direct Known Subclasses:
Basic, DMJ_OrbitTrapsDirect, MMF_MixedLighting, MMF_MultiLayerBase, MT_ConvolutionColoring, MT_SpriteTrap, REB_ExponentialSmoothing, REB_FibersThings, REB_GeneralSmoothing, REB_ImageTrapsColoring, REB_LightingDirect, Standard_DirectOrbitTraps

class 
Coloring:DirectColoring

Direct Coloring base class.

This is a generic coloring class. Its purpose is to take a sequence of points and reduce it to an explicit color. This gradient index can then be assigned to #color or or used in any other fashion.

If you are migrating an existing coloring formula to a Coloring-derived class, the process is fairly straightforward. Any variables you set in your global: section that are used elsewhere in your formula should be declared in your protected: section. Move the code from your global: section into the constructor. Move the code from your init: section into the Init() function. Move the code from your loop: section into the Iterate() function. Move the code from your final: section into the Result() function.


Ultra Fractal Source

Toggle UF Source Code Display

 class DirectColoring(Coloring) {
   ; Direct Coloring base class.
   ; <p>
   ; This is a generic coloring class. Its purpose is to take
   ; a sequence of points and reduce it to an explicit color.
   ; This gradient index can then be assigned to #color or
   ; or used in any other fashion.
   ; <p>
   ; If you are migrating an existing coloring formula to a
   ; Coloring-derived class, the process is fairly straightforward.
   ; Any variables you set in your global: section that are used
   ; elsewhere in your formula should be declared in your protected:
   ; section. Move the code from your global: section into the
   ; constructor. Move the code from your init: section into the
   ; Init() function. Move the code from your loop: section into the
   ; Iterate() function. Move the code from your final: section
   ; into the Result() function.
   
 public:
   ; Constructor
   ;
   ; @param pparent a reference to the object creating the new object; typically, 'this'
   func DirectColoring(Generic pparent)
     Coloring.Coloring(pparent)
   endfunc
   
   ; Set up for a sequence of values
   ; <p>
   ; This function will be called at the beginning of each
   ; sequence of values (e.g. at the beginning of each fractal
   ; orbit).
   ;
   ; @param pz first value for the sequence; for a normal coloring formula, this will be #z
   ; @param ppixel seed value for the sequence; for a normal coloring formula, this will be #pixel
   func Init(complex pz, complex ppixel)
     Coloring.Init(pz, ppixel)
   endfunc
   
   ; Process the next value in the sequence
   ; <p>
   ; As long as the sequence has not bailed out, this function
   ; will be continually called to produce sequence values. Note
   ; that such processing generally will not know in advance
   ; precisely how long the sequence is, and should be prepared
   ; to deal with sequences of arbitrary length.
   ; <p>
   ; Your coloring may determine at some point that a solid color
   ; should be used rather than an index value.
   ;
   ; @param pz next value in the sequence; corresponds to #z in a coloring formula
   func Iterate(complex pz)
     m_Iterations = m_Iterations + 1
   endfunc
   
   ; Produce a resulting color index after a sequence is finished
   ; <p>
   ; This corresponds to the final: section in a coloring formula.
   ; Once it is called, no further calls to Iterate() should be
   ; made without calling Init() first.
   ;
   ; @return the gradient index (corresponding to #index in a coloring formula)
   color func Result(complex pz)
     return rgb(0,0,0)
   endfunc
   
   ; Test whether the sequence produced a solid-color value rather than an index. 
   ; <p>
   ; This test is usually fairly complex and should be done as part of
   ; Iterate() or Result(), with the result saved in m_Solid. This function
   ; can then be left as the base class implementation, which just returns
   ; the value of that flag.
   ;
   ; @return whether the sequence produced a solid-color value
   bool func IsSolid()
     return m_Solid
   endfunc
   
 protected:
 
 default:
   int param v_directcoloring
     caption = "Version (DirectColoring)"
     default = 100
     hint = "This version parameter is used to detect when a change has been made to the formula that is incompatible with the previous version. When that happens, this field will reflect the old version number to alert you to the fact that an alternate rendering is being used."
     visible = @v_directcoloring < 100
   endparam
 }
 


Constructor Summary
DirectColoring()
           
DirectColoring(Generic pparent)
          Constructor
 
Method Summary
 void Init(complex pz, complex ppixel)
          Set up for a sequence of values
 boolean IsSolid()
          Test whether the sequence produced a solid-color value rather than an index.
 void Iterate(complex pz)
          Process the next value in the sequence
 color Result(complex pz)
          Produce a resulting color index after a sequence is finished
 
Methods inherited from class common:Coloring
GetPixel, IsGradient
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

DirectColoring

public DirectColoring(Generic pparent)
Constructor

Parameters:
pparent - a reference to the object creating the new object; typically, 'this'

DirectColoring

public DirectColoring()
Method Detail

Init

public void Init(complex pz,
                 complex ppixel)
Set up for a sequence of values

This function will be called at the beginning of each sequence of values (e.g. at the beginning of each fractal orbit).

Overrides:
Init in class Coloring
Parameters:
pz - first value for the sequence; for a normal coloring formula, this will be #z
ppixel - seed value for the sequence; for a normal coloring formula, this will be #pixel

Iterate

public void Iterate(complex pz)
Process the next value in the sequence

As long as the sequence has not bailed out, this function will be continually called to produce sequence values. Note that such processing generally will not know in advance precisely how long the sequence is, and should be prepared to deal with sequences of arbitrary length.

Your coloring may determine at some point that a solid color should be used rather than an index value.

Overrides:
Iterate in class Coloring
Parameters:
pz - next value in the sequence; corresponds to #z in a coloring formula

Result

public color Result(complex pz)
Produce a resulting color index after a sequence is finished

This corresponds to the final: section in a coloring formula. Once it is called, no further calls to Iterate() should be made without calling Init() first.

Overrides:
Result in class Coloring
Returns:
the gradient index (corresponding to #index in a coloring formula)

IsSolid

public boolean IsSolid()
Test whether the sequence produced a solid-color value rather than an index.

This test is usually fairly complex and should be done as part of Iterate() or Result(), with the result saved in m_Solid. This function can then be left as the base class implementation, which just returns the value of that flag.

Overrides:
IsSolid in class Coloring
Returns:
whether the sequence produced a solid-color value