Web Analytics Made Easy - Statcounter
Skip to content

Class SBDPaletteDiverging#

ClassList > SBDPaletteDiverging

The SBDPaletteDiverging class is a base class for diverging color palettes.More...

  • #include <SBDPaletteDiverging.hpp>

Inherits the following classes: SBDPalette

Inherited by the following classes: SBDPaletteDivergingHCL

Public Types inherited from SBDPalette#

See SBDPalette

Type Name
enum PaletteType
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)

Public Functions#

Type Name
SBDPaletteDiverging ()
Default constructor.
SBDPaletteDiverging (int hue1, int hue2, int chroma1=50, int maximumChroma=50, int luminance1=70, int luminance2=70, float chromaPower=1.0f, float luminancePower=1.0f, float neutralPoint=0.5f, std::string name=std::string(""), bool reverse=false)
Builds a diverging palette with the given parameters.
SBDPaletteDiverging (const SBDPaletteDiverging & otherColorPalette)
Copy constructor.
virtual SBDPaletteDiverging * clone () override const
Clones the color palette.
int getChroma1 () const
Returns the starting value for the second coordinate.
float getChromaPower () const
Returns the power of the intensity value for the computation of the second coordinate.
virtual void getColor (float * color, float value) override const
Computes sRGB color color based on this palette for the given intensity valuevalue which should be in the range [0.0, 1.0].
virtual void getColorInPaletteColorSpace (float * color, float value) override const
Computes color coordinates color in this palette's color space for the given intensity valuevalue which should be in the range [0.0, 1.0].
int getHue1 () const
Returns the starting value for the first coordinate.
int getHue2 () const
Returns the end value for the first coordinate.
int getLuminance1 () const
Returns the starting value for the third coordinate.
int getLuminance2 () const
Returns the end value for the third coordinate.
float getLuminancePower () const
Returns the power of the intensity value for the computation of the third coordinate.
int getMaximumChroma () const
Returns the max value for the second coordinate for the triangular trajectory.
float getNeutralPoint () const
Returns the neutral point position.
virtual PaletteType getType () override const
Returns the type of the color palette.
virtual bool isEqual (const SBDPalette & other) override const
Returns whether this palette is equal to other .
virtual bool isSerializable () override const
Returns true __
virtual void serialize (SBCSerializer * serializer, const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER, const SBVersionNumber & classVersionNumber=SBVersionNumber(1, 0, 0)) override const
Serializes the palette.
void setChroma (int chroma1, int maximumChroma, float chromaPower=1.0f)
Sets the parameters for the second coordinate.
void setChroma1 (int chroma1)
Sets the starting value for the second coordinate.
void setChromaPower (float chromaPower)
Sets the power of the intensity value for the computation of the second coordinate, the power should be greater than 0.
void setHue (int hue1, int hue2)
Sets the parameters for the first coordinate.
void setHue1 (int hue1)
Sets the starting value for the first coordinate.
void setHue2 (int hue2)
Sets the end value for the first coordinate.
void setLuminance (int luminance1, int luminance2, float luminancePower=1.0f)
Sets the parameters for the third coordinate.
void setLuminance1 (int luminance1)
Sets the starting value for the third coordinate.
void setLuminance2 (int luminance2)
Sets the end value for the third coordinate.
void setLuminancePower (float luminancePower)
Sets the power of the intensity value for the computation of the third coordinate, the power should be greater than 0.
void setMaximumChroma (int maximumChroma)
Sets the max value for the second coordinate for the triangular trajectory, if it is less the chroma1 orchroma2 then it is not used and the linear trajectory is computed.
void setNeutralPoint (float neutralPoint)
Sets the neutral point position, should be in the range [0.0, 1.0].
virtual std::string toPythonCode () override const
Returns the string representation of the object that can be used to reconstruct it in Python.
virtual void unserialize (SBCSerializer * serializer, const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER, const SBVersionNumber & classVersionNumber=SBVersionNumber(1, 0, 0)) override
Unserializes the palette.
virtual ~SBDPaletteDiverging ()
Destructor.

Public Functions inherited from SBDPalette#

See SBDPalette

Type Name
SBDPalette ()
Default constructor for HSV color palette.
SBDPalette (bool reverse)
Constructor for HSV color palette with reverse flag.
virtual SBDPalette * clone () const
Clones the palette.
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 valuevalue 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 valuevalue which should be in the range [0.0, 1.0].
const std::string & getName () const
Returns the palette's name.
bool getReverseFlag () const
Returns the reverse flag - whether the color palette is mirrored or not.
virtual PaletteType getType () const
Returns the type of the color palette.
std::string getTypeString (bool humanReadable=false) const
Returns the string representation of the color palette type.
virtual bool isEqual (const SBDPalette & other) const
Returns whether this palette is equal to other .
virtual bool isSerializable () const
Returns true __
bool operator!= (const SBDPalette & other) const
Inequality operator.
bool operator== (const SBDPalette & other) const
Equality operator.
virtual void serialize (SBCSerializer * serializer, const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER, const SBVersionNumber & classVersionNumber=SBVersionNumber(1, 0, 0)) const
Serializes the document.
void setName (const std::string & name)
Sets the palette's name to name .
void setReverseFlag (bool b)
Sets the reverse flag - whether to mirror or not the color palette.
virtual std::string toPythonCode () const
Returns the string representation of the object that can be used to reconstruct it in Python.
virtual void unserialize (SBCSerializer * serializer, const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER, const SBVersionNumber & classVersionNumber=SBVersionNumber(1, 0, 0))
Unserializes the document.
virtual ~SBDPalette ()
Destructor.

Public Static Functions inherited from SBDPalette#

See SBDPalette

Type Name
std::string getTypeString (PaletteType paletteType, bool humanReadable=false)
Returns the string representation of the color palette type paletteType .
float getValueAlongLinearTrajectory (float y1, float y2, float power, float x)
Returns a value along the "linear" trajectory.
float getValueAlongTriangularTrajectory (float y1, float ymax, float y2, float power, float x)
Returns a value along "triangular" trajectory.

Protected Attributes#

Type Name
int chroma1
The starting value for the second coordinate.
float chromaPower
The power of the intensity value for the computation of the second coordinate, the power should be greater than 0.0.
int hue1
The starting value for the first coordinate.
int hue2
The end value for the first coordinate.
int luminance1
The starting value for the third coordinate.
int luminance2
The end value for the third coordinate.
float luminancePower
The power of the intensity value for the computation of the third coordinate, the power should be greater than 0.0.
int maximumChroma
The max value for the second coordinate for the triangular trajectory, if it is less the chroma1 orchroma2 then it is not used and the linear trajectory is computed.
float neutralPoint
The neutral point position, should be in the range [0.0, 1.0].

Protected Attributes inherited from SBDPalette#

See SBDPalette

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

Detailed Description#

A diverging palette is constructed in a 3D color coordinate space with coordinates named Hue, Chroma, and Luminance. The diverging palette can be represented as two sequential palettes: one to the left (left arm) and another one to the right (right arm) from the diverging point (neutral point).

The value for Hue is constant for both arms:

  • hue = hue1 for the left arm (the intensity value less or equal than neutralPoint);
  • hue = hue2 for the right arm (the intensity value greater than neutralPoint).

In each arms the Chroma value changes from chroma1 to 0.0 through maximumChroma (if present and if maximumChroma > chroma1) in the same way as in the sequential palette.

In each arms the Luminance value changes from luminance1 to luminance2 as in the sequential palette.

Short name: SBPaletteDiverging

Public Functions Documentation#

function SBDPaletteDiverging [1/3]#

Default constructor.

SBDPaletteDiverging::SBDPaletteDiverging () 

Constructs a diverging palette with default parameters.

Initializes the palette with default hue, chroma, luminance, neutral point, and an empty name.


function SBDPaletteDiverging [2/3]#

Builds a diverging palette with the given parameters.

SBDPaletteDiverging::SBDPaletteDiverging (
    int hue1,
    int hue2,
    int chroma1=50,
    int maximumChroma=50,
    int luminance1=70,
    int luminance2=70,
    float chromaPower=1.0f,
    float luminancePower=1.0f,
    float neutralPoint=0.5f,
    std::string name=std::string(""),
    bool reverse=false
) 

Constructs a diverging palette with the specified parameters.

Parameters:

  • hue1 The hue value for the left arm (intensity <= neutral point).
  • hue2 The hue value for the right arm (intensity > neutral point).
  • chroma1 The starting chroma value for the left arm.
  • maximumChroma The maximum chroma value for the triangular trajectory.
  • luminance1 The starting luminance value for the left arm.
  • luminance2 The ending luminance value for the right arm.
  • chromaPower The power applied to the chroma coordinate.
  • luminancePower The power applied to the luminance coordinate.
  • neutralPoint The position of the neutral point in the range [0.0, 1.0].
  • name The optional name for the palette.
  • reverse If true, the palette is reversed.

function SBDPaletteDiverging [3/3]#

Copy constructor.

SBDPaletteDiverging::SBDPaletteDiverging (
    const SBDPaletteDiverging & otherColorPalette
) 

Constructs a new diverging palette as a copy of an existing one.

Parameters:

  • otherColorPalette The source palette to copy from.

function clone#

Clones the color palette.

virtual SBDPaletteDiverging * SBDPaletteDiverging::clone () override const

Creates a deep copy of this palette.

Returns:

A pointer to a new SBDPaletteDiverging instance that is a copy of this object.

Implements SBDPalette::clone


function getChroma1#

Returns the starting value for the second coordinate.

int SBDPaletteDiverging::getChroma1 () const

Retrieves the starting chroma value for the left arm.

Returns:

The chroma1 value.


function getChromaPower#

Returns the power of the intensity value for the computation of the second coordinate.

float SBDPaletteDiverging::getChromaPower () const

Retrieves the chroma power factor.

Returns:

The chromaPower value.


function getColor#

Computes sRGB color color based on this palette for the given intensity valuevalue which should be in the range [0.0, 1.0].

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

Computes an sRGB color for a given intensity value using this palette.

Parameters:

  • color Pointer to an array (size >= 3) where the resulting sRGB color will be stored.
  • value The intensity value in the range [0.0, 1.0] for which to compute the color.

Implements SBDPalette::getColor


function getColorInPaletteColorSpace#

Computes color coordinates color in this palette's color space for the given intensity valuevalue which should be in the range [0.0, 1.0].

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

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

Parameters:

  • color Pointer to a float array that will receive the hue, chroma, and luminance values.
  • value The intensity value for which to compute the color coordinates, expected to be within [0.0, 1.0], where 1 corresponds to the full intensity.

Computes the color coordinates in this palette's color space for a given intensity value.

This method fills the provided array with the hue, chroma, and luminance values corresponding to the specified intensity. The intensity should be in the range [0.0, 1.0]. The resulting coordinates are stored in color[0] (hue), color[1] (chroma), and color[2] (luminance).

Implements SBDPalette::getColorInPaletteColorSpace


function getHue1#

Returns the starting value for the first coordinate.

int SBDPaletteDiverging::getHue1 () const

Retrieves the hue value for the left arm of the palette.

Returns:

The hue1 value.


function getHue2#

Returns the end value for the first coordinate.

int SBDPaletteDiverging::getHue2 () const

Retrieves the hue value for the right arm of the palette.

Returns:

The hue2 value.


function getLuminance1#

Returns the starting value for the third coordinate.

int SBDPaletteDiverging::getLuminance1 () const

Retrieves the starting luminance value for the left arm.

Returns:

The luminance1 value.


function getLuminance2#

Returns the end value for the third coordinate.

int SBDPaletteDiverging::getLuminance2 () const

Retrieves the ending luminance value for the right arm.

Returns:

The luminance2 value.


function getLuminancePower#

Returns the power of the intensity value for the computation of the third coordinate.

float SBDPaletteDiverging::getLuminancePower () const

Retrieves the luminance power factor.

Returns:

The luminancePower value.


function getMaximumChroma#

Returns the max value for the second coordinate for the triangular trajectory.

int SBDPaletteDiverging::getMaximumChroma () const

Retrieves the maximum chroma value used for the triangular trajectory.

Returns:

The maximumChroma value.


function getNeutralPoint#

Returns the neutral point position.

float SBDPaletteDiverging::getNeutralPoint () const

Retrieves the neutral point position.

Returns:

The neutralPoint value in the range [0.0, 1.0].


function getType#

Returns the type of the color palette.

virtual PaletteType SBDPaletteDiverging::getType () override const

Retrieves the type identifier of this palette.

Returns:

The PaletteType enumeration value representing a diverging palette.

Implements SBDPalette::getType


function isEqual#

Returns whether this palette is equal to other .

virtual bool SBDPaletteDiverging::isEqual (
    const SBDPalette & other
) override const

Checks whether this palette is equal to another palette.

Parameters:

  • other The palette to compare with.

Returns:

true if all parameters of both palettes are equal; otherwise false.

Implements SBDPalette::isEqual


function isSerializable#

Returns true __

virtual bool SBDPaletteDiverging::isSerializable () override const

Determines whether this palette supports serialization.

Returns:

true, indicating the palette can be serialized.

Implements SBDPalette::isSerializable


function serialize#

Serializes the palette.

virtual void SBDPaletteDiverging::serialize (
    SBCSerializer * serializer,
    const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER,
    const SBVersionNumber & classVersionNumber=SBVersionNumber (1, 0, 0)
) override const

Serializes the palette to the provided serializer.

Parameters:

  • serializer The serializer used to write the palette data.
  • sdkVersionNumber The version number of the SDK.
  • classVersionNumber The version number of the class.

Implements SBDPalette::serialize


function setChroma#

Sets the parameters for the second coordinate.

void SBDPaletteDiverging::setChroma (
    int chroma1,
    int maximumChroma,
    float chromaPower=1.0f
) 

Sets the chroma parameters for the palette.

Parameters:

  • chroma1 The starting chroma value.
  • maximumChroma The maximum chroma value for the triangular trajectory.
  • chromaPower The chroma power factor.

function setChroma1#

Sets the starting value for the second coordinate.

void SBDPaletteDiverging::setChroma1 (
    int chroma1
) 

Sets the starting chroma value for the left arm.

Parameters:

  • chroma1 The new chroma1 value.

function setChromaPower#

Sets the power of the intensity value for the computation of the second coordinate, the power should be greater than 0.

void SBDPaletteDiverging::setChromaPower (
    float chromaPower
) 

Sets the chroma power factor, clamped to a non‑negative value.

Parameters:

  • chromaPower The new chroma power factor.

function setHue#

Sets the parameters for the first coordinate.

void SBDPaletteDiverging::setHue (
    int hue1,
    int hue2
) 

Sets the hue values for both arms of the palette.

Parameters:

  • hue1 The hue value for the left arm.
  • hue2 The hue value for the right arm.

function setHue1#

Sets the starting value for the first coordinate.

void SBDPaletteDiverging::setHue1 (
    int hue1
) 

Sets the hue value for the left arm of the palette.

Parameters:

  • hue1 The new hue1 value.

function setHue2#

Sets the end value for the first coordinate.

void SBDPaletteDiverging::setHue2 (
    int hue2
) 

Sets the hue value for the right arm of the palette.

Parameters:

  • hue2 The new hue2 value.

function setLuminance#

Sets the parameters for the third coordinate.

void SBDPaletteDiverging::setLuminance (
    int luminance1,
    int luminance2,
    float luminancePower=1.0f
) 

Sets the luminance parameters for the palette.

Parameters:

  • luminance1 The starting luminance value.
  • luminance2 The ending luminance value.
  • luminancePower The luminance power factor.

function setLuminance1#

Sets the starting value for the third coordinate.

void SBDPaletteDiverging::setLuminance1 (
    int luminance1
) 

Sets the starting luminance value for the left arm.

Parameters:

  • luminance1 The new luminance1 value.

function setLuminance2#

Sets the end value for the third coordinate.

void SBDPaletteDiverging::setLuminance2 (
    int luminance2
) 

Sets the ending luminance value for the right arm.

Parameters:

  • luminance2 The new luminance2 value.

function setLuminancePower#

Sets the power of the intensity value for the computation of the third coordinate, the power should be greater than 0.

void SBDPaletteDiverging::setLuminancePower (
    float luminancePower
) 

Sets the luminance power factor, clamped to a non‑negative value.

Parameters:

  • luminancePower The new luminance power factor.

function setMaximumChroma#

Sets the max value for the second coordinate for the triangular trajectory, if it is less the chroma1 orchroma2 then it is not used and the linear trajectory is computed.

void SBDPaletteDiverging::setMaximumChroma (
    int maximumChroma
) 

Sets the maximum chroma value for the triangular trajectory.

Parameters:

  • maximumChroma The new maximum chroma value.

function setNeutralPoint#

Sets the neutral point position, should be in the range [0.0, 1.0].

void SBDPaletteDiverging::setNeutralPoint (
    float neutralPoint
) 

Sets the neutral point position, clamped to the range [0.0, 1.0].

Parameters:

  • neutralPoint The desired neutral point position.

function toPythonCode#

Returns the string representation of the object that can be used to reconstruct it in Python.

virtual std::string SBDPaletteDiverging::toPythonCode () override const

Generates a Python code snippet that reconstructs this palette.

Returns:

A string containing the Python constructor call with the current palette parameters.

Implements SBDPalette::toPythonCode


function unserialize#

Unserializes the palette.

virtual void SBDPaletteDiverging::unserialize (
    SBCSerializer * serializer,
    const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER,
    const SBVersionNumber & classVersionNumber=SBVersionNumber (1, 0, 0)
) override

Deserializes the palette from the provided serializer.

Parameters:

  • serializer The serializer used to read the palette data.
  • sdkVersionNumber The version number of the SDK.
  • classVersionNumber The version number of the class.

Implements SBDPalette::unserialize


function ~SBDPaletteDiverging#

Destructor.

virtual SBDPaletteDiverging::~SBDPaletteDiverging () 

Destroys the diverging palette and releases any associated resources.


Protected Attributes Documentation#

variable chroma1#

The starting value for the second coordinate.

int SBDPaletteDiverging::chroma1;


variable chromaPower#

The power of the intensity value for the computation of the second coordinate, the power should be greater than 0.0.

float SBDPaletteDiverging::chromaPower;


variable hue1#

The starting value for the first coordinate.

int SBDPaletteDiverging::hue1;


variable hue2#

The end value for the first coordinate.

int SBDPaletteDiverging::hue2;


variable luminance1#

The starting value for the third coordinate.

int SBDPaletteDiverging::luminance1;


variable luminance2#

The end value for the third coordinate.

int SBDPaletteDiverging::luminance2;


variable luminancePower#

The power of the intensity value for the computation of the third coordinate, the power should be greater than 0.0.

float SBDPaletteDiverging::luminancePower;


variable maximumChroma#

The max value for the second coordinate for the triangular trajectory, if it is less the chroma1 orchroma2 then it is not used and the linear trajectory is computed.

int SBDPaletteDiverging::maximumChroma;


variable neutralPoint#

The neutral point position, should be in the range [0.0, 1.0].

float SBDPaletteDiverging::neutralPoint;