SPH
|
Represents a color palette, used for mapping arbitrary number to a color. More...
#include <Palette.h>
Classes | |
struct | Point |
Public Member Functions | |
Palette ()=default | |
Palette (const Palette &other) | |
Palette (Palette &&other)=default | |
Palette & | operator= (const Palette &other) |
Palette & | operator= (Palette &&other)=default |
Palette (Array< Point > &&controlPoints, const PaletteScale scale) | |
Creates a color palette given control points and their colors. More... | |
Interval | getInterval () const |
Returns the interval for which the palette is defined. More... | |
void | setInterval (const Interval &newRange) |
PaletteScale | getScale () const |
Returns the scale of the palette. More... | |
Rgba | operator() (const float value) const |
Returns the color mapped to given number. More... | |
Palette | transform (Function< Rgba(const Rgba &)> func) const |
Returns the palette with colors modified by generic transform. More... | |
float | relativeToPalette (const float value) const |
Converts a relative position to an absolute position on a palette. More... | |
float | paletteToRelative (const float value) const |
Inverse transform to relativeToPalette. More... | |
Outcome | loadFromStream (std::istream &ifs) |
Loads the palette from given input stream. More... | |
Outcome | loadFromFile (const Path &path) |
Loads the palette from given .csv file. More... | |
Outcome | saveToStream (std::ostream &ofs, const Size lineCnt=256) const |
Saves the palettes into given output stream. More... | |
Outcome | saveToFile (const Path &path, const Size lineCnt=256) const |
Saves the palette to a .csv file. More... | |
Represents a color palette, used for mapping arbitrary number to a color.
|
default |
Palette::Palette | ( | const Palette & | other | ) |
Definition at line 58 of file Palette.cpp.
|
default |
Palette::Palette | ( | Array< Point > && | controlPoints, |
const PaletteScale | scale | ||
) |
Creates a color palette given control points and their colors.
For linear and hybrid scale, controls points can be both positive or negative numbers, for logarithmic scale only positive numbers (and zero) are allowed. Control points must be passed in increasing order.
Definition at line 70 of file Palette.cpp.
Interval Palette::getInterval | ( | ) | const |
Returns the interval for which the palette is defined.
Values outside the interval will be mapped to the colors at the boundary of the interval.
Definition at line 90 of file Palette.cpp.
PaletteScale Palette::getScale | ( | ) | const |
Returns the scale of the palette.
Definition at line 107 of file Palette.cpp.
Loads the palette from given .csv file.
Definition at line 200 of file Palette.cpp.
Outcome Palette::loadFromStream | ( | std::istream & | ifs | ) |
Rgba Palette::operator() | ( | const float | value | ) | const |
Returns the color mapped to given number.
Definition at line 111 of file Palette.cpp.
Definition at line 63 of file Palette.cpp.
float Palette::paletteToRelative | ( | const float | value | ) | const |
Inverse transform to relativeToPalette.
Definition at line 162 of file Palette.cpp.
float Palette::relativeToPalette | ( | const float | value | ) | const |
Converts a relative position to an absolute position on a palette.
The relative position is in interval <0, 1>, the absolute position is given by the control points of the palette. For linear palette, this function is simply scaling of the interval, for logarithmic and hybrid palettes it also transforms the input value by the corresponding function.
Definition at line 141 of file Palette.cpp.
Saves the palette to a .csv file.
Definition at line 221 of file Palette.cpp.
Saves the palettes into given output stream.
Definition at line 205 of file Palette.cpp.
void Palette::setInterval | ( | const Interval & | newRange | ) |
Definition at line 95 of file Palette.cpp.
Returns the palette with colors modified by generic transform.
Definition at line 133 of file Palette.cpp.