Loading...
Searching...
No Matches
SBDPalette Class Reference

The SBDPalette class is a base class for color palettes. More...

Public Types

enum class  PaletteType {
  Custom ,
  Qualitative ,
  Sequential ,
  Diverging ,
  FlexibleDiverging
}
 

Palette parameters

PaletteType paletteType
 The palette's type.
 
std::string * name
 The palette's name.
 
bool reverseFlag
 Reverse flag: if true, then the palette is reversed/mirrored.
 

Constructors and destructors

 SBDPalette ()
 Default constructor.
 
virtual ~SBDPalette ()
 

Serialization

virtual bool isSerializable () const
 Returns true.
 
virtual void serialize (SBCSerializer *serializer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER, const SBVersionNumber &classVersionNumber=SBVersionNumber(1, 0, 0)) const
 Serializes the document.
 
virtual void unserialize (SBCSerializer *serializer, const SBVersionNumber &sdkVersionNumber=SB_SDK_VERSION_NUMBER, const SBVersionNumber &classVersionNumber=SBVersionNumber(1, 0, 0))
 Unserializes the document.
 

Clone function

virtual SBDPaletteclone () const
 Clones the palette.
 

Palette info

PaletteType getType () const
 Returns the type of the color palette.
 
void setType (SBDPalette::PaletteType paletteType)
 Sets the type of the color palette.
 
const std::string & getName () const
 Returns the palette's name.
 
void setName (const std::string &name)
 Sets the palette's name to name.
 
bool getReverseFlag () const
 Returns the reverse flag - whether the color palette is mirrored or not.
 
void setReverseFlag (bool b)
 Sets the reverse flag - whether to mirror or not the color palette.
 

Palette functions

SBColor getColor (float value) const
 Returns SBColor based on the palette and an intensity value value.
 
virtual void getColor (float *color, float value) const
 Computes RGB color color based on the palette and an intensity value value which should be in the range [0.0, 1.0].
 
virtual void getColorInPaletteColorSpace (float *color, float value) const
 Computes color coordinates color in this palette's color space for the given intensity value value which should be in the range [0.0, 1.0].
 

Useful functions

static float getValueAlongLinearTrajectory (float y1, float y2, float power, float x)
 Returns a value along the "linear" trajectory.
 
static float getValueAlongTriangularTrajectory (float y1, float ymax, float y2, float power, float x)
 Returns a value along "triangular" trajectory.
 

Detailed Description

This class is a base class for color palettes in SAMSON. Please refer to this page for more information. The default implementation describes the HSV (Hue, Saturation, Value) color palette.

See also
Color schemes

Member Enumeration Documentation

◆ PaletteType

enum class SBDPalette::PaletteType
strong

The three different types of palettes (qualitative, sequential, and diverging) are all constructed by combining three different types of trajectories (constant, linear, triangular) for the three different coordinates in the given color space (e.h.: hue H, chroma C, luminance L)

Enumerator
Custom 

An undefined type - a custom color palette which does not fall into any of other categories.

Qualitative 

A qualitative color palette type - for coding categorical information, i.e., where no particular ordering of categories is available and every color should receive the same perceptual weight.

Sequential 

A sequential color palette type - for coding ordered/numeric information, i.e., going from high to low (or vice versa).

Diverging 

A diverging color palette type - for coding ordered/numeric information around a central neutral value, i.e., where colors diverge from neutral to two extremes.

FlexibleDiverging 

A flexible diverging color palette type - for coding ordered/numeric information around a central neutral value, i.e., where colors diverge from neutral to two extremes.

Member Function Documentation

◆ clone()

◆ getColor() [1/2]

void SBDPalette::getColor ( float *  color,
float  value 
) const
virtual

SBDPalette::getColor - Computes RGB color color based on the palette and an intensity value value.

Parameters
color- an array for color coordinates (float[3]).
value- an intensity value based on which the resulting color is computed, the intensity value should be in range [0.0, 1.0] where 1 corresponds to the full intensity.

Reimplemented in SBDPaletteDiverging, SBDPaletteDivergingHCL, SBDPaletteFlexibleDivergingHCL, SBDPaletteQualitative, SBDPaletteQualitativeHCL, SBDPaletteSequential, and SBDPaletteSequentialHCL.

◆ getColor() [2/2]

SBColor SBDPalette::getColor ( float  value) const

SBDPalette::getColor - Returns SBColor based on the palette and an intensity value value.

Parameters
value- an intensity value based on which the resulting color is computed, the intensity value should be in range [0.0, 1.0] where 1 corresponds to the full intensity.

◆ getColorInPaletteColorSpace()

void SBDPalette::getColorInPaletteColorSpace ( float *  color,
float  value 
) const
virtual

SBDPalette::getColorInPaletteColorSpace - Computes color coordinates color in this palette's color space for the given intensity value value.

Parameters
color- an array for color coordinates (float[3]).
value- an intensity value based on which the resulting color is computed, the intensity value should be in range [0.0, 1.0] where 1 corresponds to the full intensity.

Reimplemented in SBDPaletteDiverging, SBDPaletteDivergingHCL, SBDPaletteFlexibleDivergingHCL, SBDPaletteQualitative, SBDPaletteQualitativeHCL, SBDPaletteSequential, and SBDPaletteSequentialHCL.

◆ getValueAlongLinearTrajectory()

float SBDPalette::getValueAlongLinearTrajectory ( float  y1,
float  y2,
float  power,
float  x 
)
static

SBDPalette::getValueAlongLinearTrajectory - Returns the value corresponding to x along the "linear" trajectory starting.

Parameters
y1- the start of the trajectory
y2- the end of the trajectory
power- a power parameter for the value x; if the power is equal to 1.0 the trajectory is linear, else it is a power-transformed curve
x- a value, should be in the range [0.0, 1.0].
Returns
The value along the "linear" trajectory

◆ getValueAlongTriangularTrajectory()

float SBDPalette::getValueAlongTriangularTrajectory ( float  y1,
float  ymax,
float  y2,
float  power,
float  x 
)
static

SBDPalette::getValueAlongTriangularTrajectory - Returns the value corresponding to x along the "triangular" trajectory starting.

Parameters
y1- the start of the trajectory
ymax- the max value on the trajectory that defines the triangular shape. If it is smaller than y1 or y2 then it defaults to the linear trajectory between y1 and y2.
y2- the end of the trajectory
power- a power parameter for the value x; if the power is equal to 1.0 the trajectories that constitute the triangular trajectory are linear, else they are power-transformed curves
x- a value, should be in the range [0.0, 1.0].
Returns
The value along the "triangular" trajectory

◆ isSerializable()

◆ serialize()

void SBDPalette::serialize ( SBCSerializer serializer,
const SBVersionNumber sdkVersionNumber = SB_SDK_VERSION_NUMBER,
const SBVersionNumber classVersionNumber = SBVersionNumber(1, 0, 0) 
) const
virtual

◆ unserialize()

void SBDPalette::unserialize ( SBCSerializer serializer,
const SBVersionNumber sdkVersionNumber = SB_SDK_VERSION_NUMBER,
const SBVersionNumber classVersionNumber = SBVersionNumber(1, 0, 0) 
)
virtual