Web Analytics Made Easy - Statcounter
Skip to content

Class SBDPaletteDiscrete#

ClassList > SBDPaletteDiscrete

The SBDPaletteDiscrete class is a specialized class for creating discrete color palettes.More...

  • #include <SBDPaletteDiscrete.hpp>

Inherits the following classes: SBDPalette

Public Types inherited from SBDPalette#

See SBDPalette

Type Name
enum PaletteType

Public Functions#

Type Name
SBDPaletteDiscrete ()
Default constructor.
SBDPaletteDiscrete (const std::vector< SBColor > & colors, std::string name=std::string(""), bool reverse=false)
Construct a discrete palette based on colors .
SBDPaletteDiscrete (const SBDPaletteDiscrete & otherColorPalette)
Copy constructor.
virtual SBDPaletteDiscrete * clone () override const
Clones the color palette.
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].
const std::vector< SBColor > & getColors () const
Returns the vector of colors used in the color palette.
SBColor getCycledColor (int value) const
Returns SBColor based on the palette and a value value that will be cycled to be within the range [0, number of colors in the palette].
virtual void getCycledColor (float * color, int value) const
Computes RGB color color based on the palette and a valuevalue that will be cycled to be within the range [0, number of colors in the palette].
size_t getNumberOfColors () const
Returns the number of colors in the color palette.
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 document.
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)) override
Unserializes the document.
virtual ~SBDPaletteDiscrete ()

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
Non-equality 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 ()

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
std::vector< SBColor > * colors

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#

This class extends the SBDPalette class, allowing for the creation of discrete color palettes. Discrete palettes are defined by a list of distinct colors, typically used for categorical data.

The discrete palettes allows you to cycle through its colors through SBDPaletteDiscrete::getCycledColor.

Short name: SBPaletteDiscrete

Public Functions Documentation#

function SBDPaletteDiscrete [1/3]#

Default constructor.

SBDPaletteDiscrete::SBDPaletteDiscrete () 


function SBDPaletteDiscrete [2/3]#

Construct a discrete palette based on colors .

SBDPaletteDiscrete::SBDPaletteDiscrete (
    const std::vector< SBColor > & colors,
    std::string name=std::string(""),
    bool reverse=false
) 


function SBDPaletteDiscrete [3/3]#

Copy constructor.

SBDPaletteDiscrete::SBDPaletteDiscrete (
    const SBDPaletteDiscrete & otherColorPalette
) 


function clone#

Clones the color palette.

virtual SBDPaletteDiscrete * SBDPaletteDiscrete::clone () override const

Implements SBDPalette::clone


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 SBDPaletteDiscrete::getColor (
    float * color,
    float value
) override const

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

Parameters:

  • color - an array for color coordinates with the size equal to 4.
  • 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.

Implements SBDPalette::getColor


function getColors#

Returns the vector of colors used in the color palette.

const std::vector< SBColor > & SBDPaletteDiscrete::getColors () const


function getCycledColor [1/2]#

Returns SBColor based on the palette and a value value that will be cycled to be within the range [0, number of colors in the palette].

SBColor SBDPaletteDiscrete::getCycledColor (
    int value
) const

SBDPaletteDiscrete::getCycledColor - Returns SBColor based on the palette and a value value.

Parameters:

  • value - an integer value based on which the resulting color is computed, the value will be cycled to be within the range [0, number of colors in the palette]

function getCycledColor [2/2]#

Computes RGB color color based on the palette and a valuevalue that will be cycled to be within the range [0, number of colors in the palette].

virtual void SBDPaletteDiscrete::getCycledColor (
    float * color,
    int value
) const

SBDPaletteDiscrete::getCycledColor - Computes RGB color color based on the palette and a value value.

Parameters:

  • color - an array for color coordinates with the size equal to 4.
  • value - an integer value based on which the resulting color is computed, the value will be cycled to be within the range [0, number of colors in the palette]

function getNumberOfColors#

Returns the number of colors in the color palette.

size_t SBDPaletteDiscrete::getNumberOfColors () const


function getType#

Returns the type of the color palette.

virtual PaletteType SBDPaletteDiscrete::getType () override const

Implements SBDPalette::getType


function isEqual#

Returns whether this palette is equal to other .

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

Implements SBDPalette::isEqual


function isSerializable#

Returns true.

virtual bool SBDPaletteDiscrete::isSerializable () override const

Implements SBDPalette::isSerializable


function serialize#

Serializes the document.

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

Implements SBDPalette::serialize


function toPythonCode#

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

virtual std::string SBDPaletteDiscrete::toPythonCode () const

Implements SBDPalette::toPythonCode


function unserialize#

Unserializes the document.

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

Implements SBDPalette::unserialize


function ~SBDPaletteDiscrete#

virtual SBDPaletteDiscrete::~SBDPaletteDiscrete () 

Protected Attributes Documentation#

variable colors#

std::vector<SBColor>* colors;