Standard
Class Standard_Embossed

Object
  extended by common:Generic
      extended by common:Formula
          extended by Standard:Standard_Embossed

class 
Formula:Standard_Embossed

Object version of the Embossed* formulas in Standard.ufm which allows any fractal formula to be used. Creates 3D "embossed" lighting effects when combined with the Emboss coloring algorithm in Standard.ucl. Note: Periodicity checking needs to be off. Originally written by Kerry Mitchell.


Ultra Fractal Source

Toggle UF Source Code Display

 class Standard_Embossed(common.ulb:Formula) {
 ;
 ; Object version of the Embossed* formulas in Standard.ufm which allows any
 ; fractal formula to be used. Creates 3D "embossed" lighting effects when
 ; combined with the Emboss coloring algorithm in Standard.ucl.
 ; Note: Periodicity checking needs to be off.
 ;
 ; Originally written by Kerry Mitchell.
 ;
 public:
   func Standard_Embossed(Generic pparent)
     Formula(pparent)
     fHelper[0] = new @helperClass(this)
     fHelper[1] = new @helperClass(this)
   endfunc
 
   complex func Init(complex pz)
     float theta=(90-@lightangle)*pi/180.0
     float size=@sizefac*0.0065/#magn
     dr=size*(cos(theta)+flip(sin(theta)))
     fHelper[0].Init(pz - dr)
     fHelper[1].Init(pz + dr)
     fIteration = 0
     fRMin = 1e20
     m_BailedOut = false
     return pz
   endfunc
 
   complex func Iterate(complex pz)
     ; We can't use the pz value because we need to keep track of two z values.
     fIteration = fIteration + 1
     complex z1 = fHelper[0].Iterate()
     complex z2 = fHelper[1].Iterate()
     if fHelper[0].IsBailedOut()
       z1 = z2  ; Return second z orbit instead of first.
       m_BailedOut = fHelper[1].IsBailedOut()
     endif
     if m_BailedOut || fIteration == #maxiter
       return fHelper[0].GetResult() + flip(fHelper[1].GetResult())
     else
       ; Return z to keep periodicity checking working. This is a trick that's
       ; not in the original Embossed formulas, but I borrowed it from Damien's
       ; Slope formulas because it's such a good idea -FS.
       return z1
     endif
   endfunc
 
   ; Accessor functions for the helper class.
   
   int func getIteration()
     return fIteration
   endfunc
 
   bool func updateRMin(const float r)
     if r < fRMin
       fRMin = r
       return true
     else
       return false
     endif
   endfunc
 
 private:
   Standard_EmbossedHelper fHelper[2]
   int fIteration
   float fRMin
 
 default:
   title = "Embossed"
   helpfile = "Uf*.chm"
   helptopic = "Html/formulas/standard/embossed.html"
   heading
     text = "Tip: Use with the Emboss coloring algorithm, and select one of the \
             Linear drawing methods."
   endheading
   Standard_EmbossedHelper param helperClass
     selectable = false
   endparam
   param lightangle
     caption="Light Angle"
     default=0.0
     hint="Angle of apparent light source, in degrees. With 0, the light \
           comes from above. Positive values give clockwise rotation."
   endparam
   param sizefac
     caption="Contour Size"
     default=1.0
     hint="Specifies the relative size of the contour bands. Larger values \
           give thicker bands."
     exponential = true
   endparam
   complex param p_power ; Hide p_power from Formula
     visible = false
   endparam
 }
 


Constructor Summary
Standard_Embossed()
           
Standard_Embossed(Generic pparent)
           
 
Method Summary
 int getIteration()
          Accessor functions for the helper class.
 complex Init(complex pz)
          Set up for a sequence of values
 complex Iterate(complex pz)
          Produce the next value in the sequence
 boolean updateRMin(float r)
           
 
Methods inherited from class common:Formula
GetLowerBailout, GetPrimaryExponent, GetUpperBailout, IsBailedOut
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

Standard_Embossed

public Standard_Embossed(Generic pparent)

Standard_Embossed

public Standard_Embossed()
Method Detail

Init

public complex Init(complex pz)
Description copied from class: Formula
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 Formula
Parameters:
pz - seed value for the sequence; for a normal fractal formula, this will be #pixel
Returns:
first value in the sequence; this corresponds to #z in a fractal formula

Iterate

public complex Iterate(complex pz)
Description copied from class: Formula
Produce 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.

Overrides:
Iterate in class Formula
Parameters:
pz - previous value in the sequence; corresponds to #z in a fractal formula. Note that you should always use this value for computing the next iteration, rather than a saved value, as the calling code may modify the returned value before passing it back to the next Iterate() call.
Returns:
the next value in the sequence

getIteration

public int getIteration()
Accessor functions for the helper class.


updateRMin

public boolean updateRMin(float r)