Class SBDPalette#
The SBDPalette class is a base class for color palettes.More...
#include <SBDPalette.hpp>
Inherited by the following classes: SBDPaletteDiscrete, SBDPaletteDiverging, SBDPaletteFlexibleDivergingHCL, SBDPaletteQualitative, SBDPaletteSequential
Public Types#
| 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 |
|---|---|
| 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#
| 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::string * | name The palette's name. |
| bool | reverseFlag Reverse flag: if true, then the palette is reversed/mirrored. |
Detailed Description#
This class is a base class for color palettes in SAMSON.
Please refer to Color schemes for more information. The default implementation describes the HSV (Hue, Saturation, Value) color palette.
Short name: SBPalette
See also: Color schemes
Public Types Documentation#
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)
enum SBDPalette::PaletteType {
Custom = 0,
Qualitative = 1,
Sequential = 2,
Diverging = 3,
FlexibleDiverging = 4,
Discrete = 5
};
Public Functions Documentation#
function SBDPalette [1/2]#
Default constructor for HSV color palette.
Default constructor for SBDPalette.
Initializes the palette with the default name "HSV".
function SBDPalette [2/2]#
Constructor for HSV color palette with reverse flag.
Constructor for SBDPalette with a reverse flag.
Parameters:
reverseIf true, the palette is reversed/mirrored.
Initializes the palette and sets the reverse flag according to the given argument.
function clone#
Clones the palette.
Creates a deep copy of the palette.
Returns:
A pointer to a new SBDPalette that is a copy of this palette.
function getColor [1/2]#
Returns SBColor based on the palette and an intensity value value .
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.
Returns:
SBColor representing the color corresponding to the given intensity value.
function getColor [2/2]#
Computes RGB color color based on the palette and an intensity valuevalue which should be in the range [0.0, 1.0].
SBDPalette::getColor - Computes RGB color color based on the palette and an intensity value value.
Parameters:
color- an array for color coordinates with the size greater than or equal to 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.
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].
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 with the size greater than or equal to 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.
function getName#
Returns the palette's name.
Retrieves the name of the palette.
Returns:
A reference to the palette's name; if not set, returns a reference to an empty string.
function getReverseFlag#
Returns the reverse flag - whether the color palette is mirrored or not.
Returns the current reverse flag of the palette.
Returns:
true if the palette is reversed; false otherwise.
function getType#
Returns the type of the color palette.
Retrieves the type of the palette.
Returns:
The PaletteType value representing the type of this palette.
function getTypeString [1/2]#
Returns the string representation of the color palette type.
Returns a string representation of this palette's type.
Parameters:
humanReadableIf true, returns a human-readable string; otherwise returns the enum name.
Returns:
A string describing the palette type.
function isEqual#
Returns whether this palette is equal to other .
Checks whether this palette is equal to another palette.
Parameters:
otherThe palette to compare against.
Returns:
true if the palettes are equal in type, reverse flag, name, and class type; false otherwise.
function isSerializable#
Returns true __
Indicates whether the palette can be serialized.
Returns:
true if the palette is serializable; false otherwise.
function operator!=#
Inequality operator.
Inequality operator for SBDPalette.
Parameters:
otherThe palette to compare against.
Returns:
true if the palettes are not equal; false otherwise.
function operator==#
Equality operator.
Equality operator for SBDPalette.
Parameters:
otherThe palette to compare against.
Returns:
true if the palettes are equal; false otherwise.
function serialize#
Serializes the document.
virtual void SBDPalette::serialize (
SBCSerializer * serializer,
const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER,
const SBVersionNumber & classVersionNumber=SBVersionNumber (1, 0, 0)
) const
Serializes the palette's state to the given serializer.
Parameters:
serializerThe serializer used to write the palette data.sdkVersionNumberThe SDK version number used for versioned serialization.classVersionNumberThe class version number used for versioned deserialization.
Writes the palette's name, type, and reverse flag (if applicable) based on the SDK version.
function setName#
Sets the palette's name to name .
Sets the name of the palette.
Parameters:
nameThe new name for the palette.
function setReverseFlag#
Sets the reverse flag - whether to mirror or not the color palette.
Sets the reverse flag of the palette.
Parameters:
bThe new reverse flag value; true to reverse/mirror the palette,falseotherwise.
function toPythonCode#
Returns the string representation of the object that can be used to reconstruct it in Python.
Returns a Python code representation of the palette.
Returns:
A string containing Python code that reconstructs the palette.
function unserialize#
Unserializes the document.
virtual void SBDPalette::unserialize (
SBCSerializer * serializer,
const SBVersionNumber & sdkVersionNumber=SB_SDK_VERSION_NUMBER,
const SBVersionNumber & classVersionNumber=SBVersionNumber (1, 0, 0)
)
Deserializes the palette's state from the given serializer.
Parameters:
serializerThe serializer used to read the palette data.sdkVersionNumberThe SDK version number used for versioned deserialization.classVersionNumberThe class version number used for versioned deserialization.
Reads the palette's name, type, and reverse flag (if applicable) based on the SDK version.
function ~SBDPalette#
Destructor.
Destructor for SBDPalette.
Releases allocated resources associated with the palette.
Public Static Functions Documentation#
function getTypeString [2/2]#
Returns the string representation of the color palette type paletteType .
Returns a string representation of a given palette type.
Parameters:
paletteTypeThe PaletteType to convert to a string.humanReadableIf true, returns a human-readable string; otherwise returns the enum name.
Returns:
A string describing the specified palette type.
function getValueAlongLinearTrajectory#
Returns a value along the "linear" trajectory.
SBDPalette::getValueAlongLinearTrajectory - Returns the value corresponding to x along the "linear" trajectory starting.
Parameters:
y1- the start of the trajectoryy2- the end of the trajectorypower- a power parameter for the valuex; if the power is equal to 1.0 the trajectory is linear, else it is a power-transformed curvex- a value, should be in the range [0.0, 1.0].
Returns:
The value along the "linear" trajectory
function getValueAlongTriangularTrajectory#
Returns a value along "triangular" trajectory.
static float SBDPalette::getValueAlongTriangularTrajectory (
float y1,
float ymax,
float y2,
float power,
float x
)
SBDPalette::getValueAlongTriangularTrajectory - Returns the value corresponding to x along the "triangular" trajectory starting.
Parameters:
y1- the start of the trajectoryymax- the max value on the trajectory that defines the triangular shape. If it is smaller thany1ory2then it defaults to the linear trajectory betweeny1andy2.y2- the end of the trajectorypower- a power parameter for the valuex; if the power is equal to 1.0 the trajectories that constitute the triangular trajectory are linear, else they are power-transformed curvesx- a value, should be in the range [0.0, 1.0].
Returns:
The value along the "triangular" trajectory
Protected Attributes Documentation#
variable name#
The palette's name.
variable reverseFlag#
Reverse flag: if true, then the palette is reversed/mirrored.