qualpal 2.3.0
|
Builder for qualitative color palette generation. More...
#include <qualpal.h>
Public Member Functions | |
Qualpal ()=default | |
Default constructor. Initializes with no input source. | |
Qualpal & | setInputRGB (const std::vector< colors::RGB > &colors) |
Set input colors from a vector of RGB values. | |
Qualpal & | setInputHex (const std::vector< std::string > &colors) |
Set input colors from a vector of hex color strings. | |
Qualpal & | setInputPalette (const std::string &palette_name) |
Set input colors from a named palette. | |
Qualpal & | setInputColorspace (const std::array< double, 2 > &h_lim, const std::array< double, 2 > &s_lim, const std::array< double, 2 > &l_lim, ColorspaceType space=ColorspaceType::HSL) |
Set input colors by sampling HSL colorspace. | |
Qualpal & | setCvd (const std::map< std::string, double > &cvd_params) |
Set color vision deficiency simulation parameters. | |
Qualpal & | setBackground (const colors::RGB &bg_color) |
Set the background color for palette generation. | |
Qualpal & | setMetric (metrics::MetricType metric) |
Set the color difference metric to use. | |
Qualpal & | setMemoryLimit (double gb) |
Set the maximum memory limit (in GB) for color difference matrix. | |
Qualpal & | setColorspaceSize (std::size_t n_points) |
Set the number of points in the colorspace grid for HSL input. | |
std::vector< colors::RGB > | generate (std::size_t n) |
Generate a qualitative color palette with the configured options. | |
std::vector< colors::RGB > | extend (const std::vector< colors::RGB > &palette, std::size_t n) |
Extend an existing palette by adding n new colors. | |
Builder for qualitative color palette generation.
The Qualpal class allows step-by-step configuration of palette generation options. Users can set the input source (RGB, hex, palette name, or HSL colorspace), color vision deficiency simulation parameters, background color, color difference metric, and memory limit. The palette is generated by calling generate().
std::vector< colors::RGB > qualpal::Qualpal::extend | ( | const std::vector< colors::RGB > & | palette, |
std::size_t | n | ||
) |
Extend an existing palette by adding n new colors.
palette | Existing palette (RGB colors) to keep fixed. |
n | Size of the new palette to generate, which includes the existing palette. |
std::vector< colors::RGB > qualpal::Qualpal::generate | ( | std::size_t | n | ) |
Generate a qualitative color palette with the configured options.
n | Number of colors to generate. |
std::runtime_error | if no input source is configured. |
std::invalid_argument | for invalid configuration. |
Qualpal & qualpal::Qualpal::setBackground | ( | const colors::RGB & | bg_color | ) |
Set the background color for palette generation.
bg_color | RGB background color. |
Qualpal & qualpal::Qualpal::setColorspaceSize | ( | std::size_t | n_points | ) |
Set the number of points in the colorspace grid for HSL input.
n_points | Number of points to sample in the colorspace grid. |
std::invalid_argument | if n_points <= 0. |
Qualpal & qualpal::Qualpal::setCvd | ( | const std::map< std::string, double > & | cvd_params | ) |
Set color vision deficiency simulation parameters.
cvd_params | Map of {"protanomaly"|"deutananomaly"|"tritanomaly" -> severity [0,1]}. |
Qualpal & qualpal::Qualpal::setInputColorspace | ( | const std::array< double, 2 > & | h_lim, |
const std::array< double, 2 > & | s_lim, | ||
const std::array< double, 2 > & | l_lim, | ||
ColorspaceType | space = ColorspaceType::HSL |
||
) |
Set input colors by sampling HSL colorspace.
h_lim | Hue range in degrees [-360, 360]. |
s_lim | Saturation range [0, 1]. |
l_lim | Lightness range [0, 1]. |
space | Colorspace type |
std::invalid_argument | for invalid ranges. |
Qualpal & qualpal::Qualpal::setInputHex | ( | const std::vector< std::string > & | colors | ) |
Set input colors from a vector of hex color strings.
colors | Vector of hex color strings (e.g., "#ff0000"). |
std::invalid_argument | if any hex string is invalid. |
Qualpal & qualpal::Qualpal::setInputPalette | ( | const std::string & | palette_name | ) |
Set input colors from a named palette.
palette_name | Palette name in the format "Package:Palette". |
std::invalid_argument | if the palette name is invalid. |
Qualpal & qualpal::Qualpal::setInputRGB | ( | const std::vector< colors::RGB > & | colors | ) |
Set input colors from a vector of RGB values.
colors | Vector of RGB colors to use as input. |
Qualpal & qualpal::Qualpal::setMemoryLimit | ( | double | gb | ) |
Set the maximum memory limit (in GB) for color difference matrix.
gb | Memory limit in gigabytes. |
std::invalid_argument | if gb <= 0. |
Qualpal & qualpal::Qualpal::setMetric | ( | metrics::MetricType | metric | ) |
Set the color difference metric to use.
metric | Metric type (e.g., DIN99d). |