|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object common:Generic common:Coloring common:DirectColoring
class
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.
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 |
---|
public DirectColoring(Generic pparent)
pparent
- a reference to the object creating the new object; typically, 'this'public DirectColoring()
Method Detail |
---|
public void Init(complex pz, complex ppixel)
This function will be called at the beginning of each sequence of values (e.g. at the beginning of each fractal orbit).
Init
in class Coloring
pz
- first value for the sequence; for a normal coloring formula, this will be #zppixel
- seed value for the sequence; for a normal coloring formula, this will be #pixelpublic void Iterate(complex pz)
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.
Iterate
in class Coloring
pz
- next value in the sequence; corresponds to #z in a coloring formulapublic color Result(complex pz)
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.
Result
in class Coloring
public boolean IsSolid()
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.
IsSolid
in class Coloring
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |