SBPalette#

This class is a base class for color palettes.

The default implementation describes the HSV (Hue, Saturation, Value) color palette.

See also

Colorizing nodes

SAMSON SDK: SBDPalette

class samson.SBPalette(self: samson.SBPalette)#

Bases: pybind11_object

This class is a base class for color palettes.

Default constructor

class PaletteType(self: samson.SBPalette.PaletteType, value: int)#

Bases: pybind11_object

Members:

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.

Custom = <PaletteType.Custom: 0>#
Diverging = <PaletteType.Diverging: 3>#
FlexibleDiverging = <PaletteType.FlexibleDiverging: 4>#
Qualitative = <PaletteType.Qualitative: 1>#
Sequential = <PaletteType.Sequential: 2>#
property name#
property value#
clone(self: samson.SBPalette) samson.SBPalette#

Returns a copy of the color palette.

getColor(self: samson.SBPalette, x: float) samson.SBColor#

Returns SBColor based on the palette and an intensity value x which should be in the range [0.0, 1.0].

Parameters:

x (float) – An intensity value in the range [0.0, 1.0]

Returns:

A color.

Return type:

samson.SBColor

Examples

>>> palette = SBPaletteDefaultPalette.qualitativeHCLPastel
>>> color = palette.getColor(0.5)
>>> print(color)
[0.599446, 0.885390, 0.848834, 1.000000]
getColorInPaletteColorSpace(self: samson.SBPalette, x: float) list[float]#

Returns color coordinates in this palette’s color space for the given intensity value x value which should be in the range [0.0, 1.0].

Parameters:

x (float) – An intensity value in the range [0.0, 1.0]

Returns:

A color in the color space of the color palette.

Return type:

samson.SBColor

Examples

>>> palette = SBPaletteDefaultPalette.flexibleDivergingHCLCividis
>>> color = palette.getColorInPaletteColorSpace(0.75)
>>> print(color)
[75.0, 47.5, 72.0, 1.0]
getColorVector(self: samson.SBPalette, x: float) list[float]#

Returns RGB color in a float vector based on the palette and an intensity value x value which should be in the range [0.0, 1.0].

Parameters:

x (float) – An intensity value in the range [0.0, 1.0]

Returns:

An rgba color.

Return type:

list of 4 floats (rgba)

Examples

>>> palette = SBPaletteDefaultPalette.divergingHCLBlue2Red
>>> color = palette.getColorVector(1.0)
>>> print(color)
[0.5580056309700012, 0.025098808109760284, 0.23243436217308044, 1.0]
static getValueAlongLinearTrajectory(y1: float, y2: float, power: float, x: float) float#

Returns a value along the linear trajectory or a power-transformed curve. :param y1: The start of the trajectory :type y1: float :param y2: The end of the trajectory :type y2: float :param 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 :type power: float :param x: A value, should be in the range [0.0, 1.0]. :type x: float

Returns:

The value along the trajectory

Return type:

float

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

Returns a value along the triangular trajectory with linear or power-transformed curves.

Parameters:
  • y1 (float) – The start of the trajectory

  • ymax (float) – 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 (float) – The end of the trajectory

  • power (float) – 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 (float) – A value, should be in the range [0.0, 1.0].

Returns:

The value along the “triangular” trajectory

Return type:

float

Custom = <PaletteType.Custom: 0>#
Diverging = <PaletteType.Diverging: 3>#
FlexibleDiverging = <PaletteType.FlexibleDiverging: 4>#
Qualitative = <PaletteType.Qualitative: 1>#
Sequential = <PaletteType.Sequential: 2>#
property isSerializable#

Returns True when the class is serializable

property name#

The color palette’s name.

property reverseFlag#

The reverse flag - whether the color palette is mirrored or not.

property type#

The color palette’s type.