common
Class TrapTransform

Object
  extended by common:Generic
      extended by common:Transform
          extended by common:UserTransform
              extended by common:TrapTransform

class 
UserTransform:TrapTransform

Basic move/rotate/size/stretch/skew trap shape transform.


Ultra Fractal Source

Toggle UF Source Code Display

 class TrapTransform(UserTransform) {
   ; Basic move/rotate/size/stretch/skew trap shape transform.
   
 public:
   func TrapTransform(Generic pparent)
     UserTransform.UserTransform(pparent)
   endfunc
 
   func Init(complex pz)
     UserTransform.Init(pz)
 
     m_Rotation = (0,1) ^ (@p_traprotation / 90.0)
     m_Skew = (0,1) ^ (@p_trapskew / 90.0)
     m_TrapCenter = @p_trapcenter
     if (@p_trapcentermoves)
       m_TrapCenter = m_TrapCenter + pz
     endif
   endfunc
 
   complex func Iterate(complex pz)
     m_Iterations = m_Iterations + 1
     
     ; apply per-iteration steps
     if (@p_trapdrift != (0,0))
       m_TrapCenter = m_TrapCenter + @p_trapdrift
     endif
     if (@p_traprotationstep != 0.0)
       m_Rotation = (0,1) ^ ((@p_traprotation + @p_traprotationstep*(m_Iterations-1)) / 90.0)
     endif
     if (@p_trapskewstep != 0.0)
       m_Skew = (0,1) ^ ((@p_trapskew + @p_trapskewstep*(m_Iterations-1)) / 90.0)
     endif
 
     ; apply offset and rotation and size
     pz = (pz - m_TrapCenter) * m_Rotation * recip(@p_trapscale)
     ; apply aspect
     if (@p_trapaspect != 1.0)
       pz = real(pz) + flip(imag(pz) * @p_trapaspect)
     endif
     ; apply skew
     pz = real(pz*m_Skew) + flip(imag(pz))
     
     return pz
   endfunc
   
 protected:
   complex m_Rotation
   complex m_Skew
   complex m_TrapCenter
 
 default:
   title = "Trap Position"
 
   int param v_traptransform
     caption = "Version (TrapTransform)"
     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_traptransform < 100
   endparam
   
   complex param p_trapcenter
     caption = "Trap Center"
     default = (0,0)
     hint = "This is the location of the trap in the complex plane."
   endparam
   bool param p_trapcentermoves
     caption = "Follows initial z"
     default = false
     hint = "If this is enabled, the trap center will follow the initial z location, offset by the Trap Center amount. The initial z location will be the same as the pixel in many circumstances, but may not be if you are using Trap Position in unusual ways."
   endparam
   complex param p_trapdrift
     caption = "Trap Drift"
     default = (0,0)
     hint = "This is the amount the trap center will move with each iteration."
   endparam
   float param p_trapscale
     caption = "Trap Scale"
     default = 1.0
     hint = "This can be used to resize the entire trap shape. This is different from adjusting the trap threshold because this resizes the complete trap evenly; adjusting the threshold may change the trap shape in unexpected ways (for some trap shapes). Use values smaller than 1.0 to shrink the trap shape, larger than 1.0 to enlarge it."
   endparam
   float param p_traprotation
     caption = "Rotation"
     default = 0.0
     hint = "This is the angle, in degrees, that the trap should be rotated."
   endparam
   float param p_traprotationstep
     caption = "Rotation Step"
     default = 0.0
     hint = "This is the angle, in degrees, that the trap will be rotated with each iteration."
   endparam
   float param p_trapskew
     caption = "Skew"
     default = 0.0
     hint = "This is the angle, in degrees, to skew the vertical axis of the trap shape."
   endparam
   float param p_trapskewstep
     caption = "Skew Step"
     default = 0.0
     hint = "This is the angle, in degrees, that the skew angle should be increased by with each iteration."
   endparam
   float param p_trapaspect
     caption = "Aspect Ratio"
     default = 1.0
     hint = "This is how square the trap is. You can distort the trap by using a value other than 1.0."
   endparam
 }
 


Constructor Summary
TrapTransform()
           
TrapTransform(Generic pparent)
           
 
Method Summary
 void Init(complex pz)
          Set up for a sequence of values
 complex Iterate(complex pz)
          Transform a single point within a sequence
 
Methods inherited from class common:Transform
IsSolid, IterateSilent
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

TrapTransform

public TrapTransform(Generic pparent)

TrapTransform

public TrapTransform()
Method Detail

Init

public void Init(complex pz)
Description copied from class: Transform
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). It will be called even if only one value is being transformed (e.g. a normal transformation formula). Use this to perform any setup that is exactly the same for each value in the sequence being transformed.

Overrides:
Init in class Transform
Parameters:
pz - the value representing the sequence; for a normal transformation formula use, this will be #pixel. In some cases this may differ from the first value passed to Iterate() if the calling code applies some other transformations.

Iterate

public complex Iterate(complex pz)
Description copied from class: Transform
Transform a single point within a sequence

After a sequence has been set up with Init(), this function will be called once for each value in the sequence. Note that all values in the sequence must be processed in order (they cannot be processed out of order). If the sequence contains only one value, Init() will still be called and then Iterate() will be called just once.

Overrides:
Iterate in class Transform
Parameters:
pz - the complex value to be transformed
Returns:
the transformed value