kcc5
Class KCC_ColorMapBase

Object
  extended by common:Generic
      extended by common:GradientWrapper
          extended by kcc5:KCC_ColorMapBase
Direct Known Subclasses:
KCC_Alhambra8Map, KCC_Belvedere8Map, KCC_BlueSilver2Map, KCC_BlueWhite2Map, KCC_Bouquet8Map, KCC_Chill8Map, KCC_CloudNine8Map, KCC_ColorSwitch8Map, KCC_ColorWheel12Map, KCC_CyanMagenta2Map, KCC_CyanYellow2Map, KCC_Default12Map, KCC_Default16Map, KCC_Default24Map, KCC_Default8Map, KCC_EveningSky8Map, KCC_Fall8Map, KCC_Fantasia8Map, KCC_FloweringOrchard8Map, KCC_FourthOfJuly3Map, KCC_GenerateColorMap, KCC_GoldGreen2Map, KCC_GoldGreen8Map, KCC_GoldGreenAlt8Map, KCC_GoldSilver8Map, KCC_GoldSilverAlt8Map, KCC_GradientColors, KCC_LaTerra8Map, KCC_Mojave8Map, KCC_MorningSky8Map, KCC_Pastel8Map, KCC_PastelRainbow8Map, KCC_PurpleYellow2Map, KCC_PurpleYellow8Map, KCC_PurpleYellowAlt8Map, KCC_RedTan2Map, KCC_SantaFe8Map, KCC_Showtime8Map, KCC_Soleil8Map, KCC_Spring8Map, KCC_Summer8Map, KCC_Winter8Map

class 
GradientWrapper:KCC_ColorMapBase

Default base class for color map classes.

This class provides the base class for coloring options. It provides as a default an 8 range color map. It also provides functions for perturbing the map (changing the ordering of the ranges). This class does not have any user parameters for customizing the colors. For customizing, the user should use one of the classes extended from this class.


Ultra Fractal Source

Toggle UF Source Code Display

 class KCC_ColorMapBase( common.ulb:GradientWrapper ) {
 ; Default base class for color map classes.
 ; <p>
 ; This class provides the base class for coloring options.  It provides as a
 ; default an 8 range color map.  It also provides functions for perturbing
 ; the map (changing the ordering of the ranges).  This class does not have
 ; any user parameters for customizing the colors.  For customizing, the
 ; user should use one of the classes extended from this class.
 ;
 public:
   import "common.ulb"
 
   ; Constructor
   ; @param pparent = a reference to the object creating the new object; typically, 'this'
   func KCC_ColorMapBase( Generic pparent )
     GradientWrapper.GradientWrapper( pparent )
 
     colorOffset = @colorOffset
 
     ; Rearange the color map for the 8 Range Custom settings.
     if( @perturbRanges == "8 Range Custom" )
       perturb8RangeMap()
     endif
   endfunc
 
   color func getColorChannel( float pindex, int pchannel )
     pchannel = abs( (pchannel + colorOffset) % colorRanges )
     
     ; Adjust the range number (pchannel) if one of the perturb range settings
     ; is selected.
     if( @perturbRanges != "None" && @perturbRanges != "8 Range Custom" )
       pchannel = perturbRanges( pchannel )
     endif
     return blend( colorMap[pchannel,0], colorMap[pchannel,1], pindex )
   endfunc
 
   ; Perturb the color ranges.
   ; <p>
   ; Given a range number, return the value after perturbation.  This function
   ; is usually called from the getColorChannel() function to return the color
   ; range before assigning the color to the point.
   ;
   ; @param rangeNum The range number to perturb
   ; @return The perturbed range number
   int func perturbRanges( int rangeNum )
     if( colorRanges < 3 )
       return rangeNum
     endif
 
     if( @perturbRanges == "Even/Odd" )
       ; If range ordering is 0 1 2 3 4 5 6 7,
       ; then range selected becomes 0 2 4 6 1 3 5 7
       if( ( trunc( colorRanges / 2 ) * 2 ) == colorRanges )
         ; Number of ranges is even.
         if ( rangeNum < colorRanges / 2 )
           rangeNum = ( rangeNum + rangeNum ) % colorRanges
         else
           rangeNum = ( rangeNum + rangeNum + 1 ) % colorRanges
         endif
       else
         ; Number of ranges is odd.
         rangeNum = ( rangeNum + rangeNum ) % colorRanges
       endif
     elseif( @perturbRanges == "1st Half / 2nd Half" )
       ; If range ordering is 0 1 2 3 4 5 6 7,
       ; then range selected becomes 0 4 1 5 2 6 3 7
       if( ( trunc( rangeNum / 2 ) * 2 ) == rangeNum )
         ; rangeNum is even.
         rangeNum = rangeNum - trunc( rangeNum / 2 )
       else
         ; rangeNum is odd.
         rangeNum = rangeNum + trunc( ( colorRanges - rangeNum ) / 2 )
       endif
     elseif( @perturbRanges == "Checkerboard" )
       perturb8RangeMap()
     endif
 
     return rangeNum
   endfunc
 
   ; Perturb an 8 range color map.
   ; This function takes an 8 range color map and perburbs it according to
   ; the user specified perturbation.
   func perturb8RangeMap()
     if( colorRanges == 8 )
       ; If we are using 8 ranges, then take into account
       ; the rangeOrdering parameter.
       int range[8]
 
       int ordering = @rangeorder
       int i = 8
       while (i > 0)
          i = i - 1
          range[i] = ordering % 10
          ordering = trunc( ordering / 10.0 )
       endwhile
 
       ; Save the original order of the maps.
       color tempMap[8,2]
       tempMap[0,0] = colorMap[0,0], tempMap[0,1] = colorMap[0,1]
       tempMap[1,0] = colorMap[1,0], tempMap[1,1] = colorMap[1,1]
       tempMap[2,0] = colorMap[2,0], tempMap[2,1] = colorMap[2,1]
       tempMap[3,0] = colorMap[3,0], tempMap[3,1] = colorMap[3,1]
       tempMap[4,0] = colorMap[4,0], tempMap[4,1] = colorMap[4,1]
       tempMap[5,0] = colorMap[5,0], tempMap[5,1] = colorMap[5,1]
       tempMap[6,0] = colorMap[6,0], tempMap[6,1] = colorMap[6,1]
       tempMap[7,0] = colorMap[7,0], tempMap[7,1] = colorMap[7,1]
 
       ; Reorder the maps according to the rangeOrder parameter.
       colorMap[0,0] = tempMap[range[0]-1,0], colorMap[0,1] = tempMap[range[0]-1,1]
       colorMap[1,0] = tempMap[range[1]-1,0], colorMap[1,1] = tempMap[range[1]-1,1]
       colorMap[2,0] = tempMap[range[2]-1,0], colorMap[2,1] = tempMap[range[2]-1,1]
       colorMap[3,0] = tempMap[range[3]-1,0], colorMap[3,1] = tempMap[range[3]-1,1]
       colorMap[4,0] = tempMap[range[4]-1,0], colorMap[4,1] = tempMap[range[4]-1,1]
       colorMap[5,0] = tempMap[range[5]-1,0], colorMap[5,1] = tempMap[range[5]-1,1]
       colorMap[6,0] = tempMap[range[6]-1,0], colorMap[6,1] = tempMap[range[6]-1,1]
       colorMap[7,0] = tempMap[range[7]-1,0], colorMap[7,1] = tempMap[range[7]-1,1]
     endif
   endfunc
 
 protected:
   color startColor[8]
   color endColor[8]
   color colorMap[500,2]
   int colorsPerRange
   int colorRanges
   int colorOffset
 
 default:
   int param v_KCC_ColorMapBase
     caption = "Version (KCC_ColorMapBase)"
     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_KCC_ColorMapBase < 100
   endparam
 
   param perturbRanges
     caption = "Perturb Ranges"
     enum = "None" "Even/Odd" "1st Half / 2nd Half" "8 Range Custom" "Checkerboard"
     default = 0
     hint = "Modify the way the ranges are assigned to the elements. \
             'None' = Assign in Order (0 1 2 3 4 5 6 7); 'Even Odd' = \
             Assign Even Ranges, then Odd Ranges (0 2 4 6 1 3 5 7); \
             '1st Half / 2nd Half' = Assign from first half of range, \
             then 2nd half (0 4 1 5 2 6 3 7); '8 Range Custom' = Assign \
             the ordering by entering digits 1-8.  Only works for ranges \
             with 8 colors.  'Checkerboard' modifies the range based on \
             the '8 Range Custom' values each iteration.  It can produce \
             interesting results."
   endparam
 
   int param rangeOrder
     caption = "Range Order"
     default = 12345678
     min = 11111111
     max = 88888888
     hint = "Specify the color range ordering.  Use digits 1-8 to specify \
            the order the ranges will be used.  For example, to reverse \
            the ordering, specify 87654321.  To alternate, use 13572468. \
            If color map or preset is defined that does not contain exactly \
            8 ranges, then this parameter will not have any effect."
     visible = ((@perturbRanges == "8 Range Custom" || @perturbRanges == "Checkerboard") \
                 && @colorRanges == 8)
   endparam
 
   int param colorOffset
     caption = "Range Offset"
     default = 0
     min = 0
     max = 500
     hint = "This is used to rotate the color ranges.  The offset can \
             range from 0 to 500."
   endparam
 
   bool param customize
     caption = "Show/Customize"
     default = false
     hint = "Check to customize the selected color preset.  NOTE:  If you \
             modify the default values for any of the range(s), you cannot \
             get back to the default values for the range(s) you modify \
             unless you reload the UCL."
     visible = true
   endparam
 
   int param colorRanges
     caption = "# of Ranges"
     min = 1
     max = 8
     default = 8
   endparam
 }
 


Constructor Summary
KCC_ColorMapBase()
           
KCC_ColorMapBase(Generic pparent)
          Constructor
 
Method Summary
 color getColorChannel(float pindex, int pchannel)
          Lookup function supporting multiple channels By default, we use the UF gradient
 void perturb8RangeMap()
          Perturb an 8 range color map.
 int perturbRanges(int rangeNum)
          Perturb the color ranges.
 
Methods inherited from class common:GradientWrapper
getColor
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

KCC_ColorMapBase

public KCC_ColorMapBase(Generic pparent)
Constructor

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

KCC_ColorMapBase

public KCC_ColorMapBase()
Method Detail

getColorChannel

public color getColorChannel(float pindex,
                             int pchannel)
Description copied from class: GradientWrapper
Lookup function supporting multiple channels By default, we use the UF gradient

Overrides:
getColorChannel in class GradientWrapper

perturbRanges

public int perturbRanges(int rangeNum)
Perturb the color ranges.

Given a range number, return the value after perturbation. This function is usually called from the getColorChannel() function to return the color range before assigning the color to the point.

Parameters:
rangeNum - The range number to perturb
Returns:
The perturbed range number

perturb8RangeMap

public void perturb8RangeMap()
Perturb an 8 range color map. This function takes an 8 range color map and perburbs it according to the user specified perturbation.