dmj5
Class DMJ_Kaleidoscope

Object
  extended by common:Generic
      extended by common:Transform
          extended by common:UserTransform
              extended by dmj5:DMJ_Kaleidoscope

class 
UserTransform:DMJ_Kaleidoscope

Kaleidoscope transformation. (Ported from dmj.uxf:dmj-Kaleidoscope)


Ultra Fractal Source

Toggle UF Source Code Display

 class DMJ_Kaleidoscope(common.ulb:UserTransform) {
   ; Kaleidoscope transformation.
   ; (Ported from dmj.uxf:dmj-Kaleidoscope)
   
 public:
   import "common.ulb"
 
   func DMJ_Kaleidoscope(Generic pparent)
     UserTransform.UserTransform(pparent)
   endfunc
   
   func Init(complex pz)
     UserTransform.Init(pz)
     m_Rotation = (0,1) ^ (@p_angle / 90.0)
     m_Rotation2 = (0,1) ^ (@p_angle2 / 90.0)
   endfunc
   
   complex func Iterate(complex pz)
     m_Iterations = m_Iterations + 1
 
     ; apply per-iteration kaleidoscope
     if (!@p_symreset)
       pz = (pz - @p_symcenter) * m_Rotation
     else
       pz = (pz) * m_Rotation
     endif
     float d = cabs(pz)
     float r = atan2(pz)
     if (r < 0)        ; negative angle; we want 0 <= atan < 2pi
       r = r + #pi*2
     endif
     
     if (@p_symorder != 0.0)
       if (@p_symreflect < 3)          ; any actual kaleidoscopic mode
         r = r - floor(r * @p_symorder/#pi/2) * #pi*2/@p_symorder  ; base kaleidoscope
         ; for some modes, reflect this
         if (@p_symreflect == 0)        ; reflective
           if (r > #pi/@p_symorder)    ; more than halfway through
             r = #pi*2/@p_symorder - r  ; reflect
           endif
         elseif (@p_symreflect == 3)      ; right symmetry
           r = #pi*2/@p_symorder - r    ; reflect (always)
         endif
 
       elseif (@p_symreflect == 3)        ; slice only
         if (r > #pi*2/@p_symorder)
           r = 0
           m_Solid = true
         endif
       endif
       
       return (cos(r)*d + flip(sin(r)*d)) * m_Rotation2 + @p_symcenter
 
     else
       return pz
     endif
   endfunc
 
 protected:
   complex m_Rotation
   complex m_Rotation2
 
 default:
   title = "Kaleidoscope"
   
   int param v_dmj_kaleidoscope
     caption = "Version (DMJ_Kaleidoscope)"
     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_dmj_kaleidoscope < 100
   endparam
 
   float param p_symorder
     caption = "Symmetry Order"
     default = 8.0
     hint = "Indicates the number of reflected components. Use 0 to temporarily disable symmetry."
   endparam
   int param p_symreflect
     caption = "Symmetry Mode"
     default = 0
     enum = "reflective" "left" "right" "slice only"
     hint = "Style of symmetry.  Reflective will always be seamless; left and right may not be.  If Slice is selected, only the section that will be mirrored will be shown."
   endparam
   complex param p_symcenter
     caption = "Symmetry Center"
     default = #center
     hint = "Sets the center of symmetry."
   endparam
   bool param p_symreset
     caption = "Relocate to origin"
     default = false
     hint = "If checked, the resulting symmetric pattern will be relocated to the origin."
   endparam
   float param p_angle
     caption = "Pre-Symmetry Rotation"
     default = 0.0
     hint = "Sets how much to rotate the fractal (in degrees) before applying symmetry."
   endparam
   float param p_angle2
     caption = "Post-Symmetry Rotation"
     default = 0.0
     hint = "Sets how much to rotate the fractal (in degrees) after applying symmetry."
   endparam
 
 }
 


Constructor Summary
DMJ_Kaleidoscope()
           
DMJ_Kaleidoscope(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

DMJ_Kaleidoscope

public DMJ_Kaleidoscope(Generic pparent)

DMJ_Kaleidoscope

public DMJ_Kaleidoscope()
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