qualpal 2.3.0
Loading...
Searching...
No Matches
qualpal::Qualpal Class Reference

Builder for qualitative color palette generation. More...

#include <qualpal.h>

Public Member Functions

 Qualpal ()=default
 Default constructor. Initializes with no input source.
 
QualpalsetInputRGB (const std::vector< colors::RGB > &colors)
 Set input colors from a vector of RGB values.
 
QualpalsetInputHex (const std::vector< std::string > &colors)
 Set input colors from a vector of hex color strings.
 
QualpalsetInputPalette (const std::string &palette_name)
 Set input colors from a named palette.
 
QualpalsetInputColorspace (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.
 
QualpalsetCvd (const std::map< std::string, double > &cvd_params)
 Set color vision deficiency simulation parameters.
 
QualpalsetBackground (const colors::RGB &bg_color)
 Set the background color for palette generation.
 
QualpalsetMetric (metrics::MetricType metric)
 Set the color difference metric to use.
 
QualpalsetMemoryLimit (double gb)
 Set the maximum memory limit (in GB) for color difference matrix.
 
QualpalsetColorspaceSize (std::size_t n_points)
 Set the number of points in the colorspace grid for HSL input.
 
std::vector< colors::RGBgenerate (std::size_t n)
 Generate a qualitative color palette with the configured options.
 
std::vector< colors::RGBextend (const std::vector< colors::RGB > &palette, std::size_t n)
 Extend an existing palette by adding n new colors.
 

Detailed Description

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().

Definition at line 61 of file qualpal.h.

Member Function Documentation

◆ extend()

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.

Parameters
paletteExisting palette (RGB colors) to keep fixed.
nSize of the new palette to generate, which includes the existing palette.
Returns
Vector of palette + n new RGB colors.

◆ generate()

std::vector< colors::RGB > qualpal::Qualpal::generate ( std::size_t  n)

Generate a qualitative color palette with the configured options.

Parameters
nNumber of colors to generate.
Returns
Vector of n selected RGB colors.
Exceptions
std::runtime_errorif no input source is configured.
std::invalid_argumentfor invalid configuration.

◆ setBackground()

Qualpal & qualpal::Qualpal::setBackground ( const colors::RGB bg_color)

Set the background color for palette generation.

Parameters
bg_colorRGB background color.
Returns
Reference to this object for chaining.

◆ setColorspaceSize()

Qualpal & qualpal::Qualpal::setColorspaceSize ( std::size_t  n_points)

Set the number of points in the colorspace grid for HSL input.

Parameters
n_pointsNumber of points to sample in the colorspace grid.
Returns
Reference to this object for chaining.
Exceptions
std::invalid_argumentif n_points <= 0.

◆ setCvd()

Qualpal & qualpal::Qualpal::setCvd ( const std::map< std::string, double > &  cvd_params)

Set color vision deficiency simulation parameters.

Parameters
cvd_paramsMap of {"protanomaly"|"deutananomaly"|"tritanomaly" -> severity [0,1]}.
Returns
Reference to this object for chaining.

◆ setInputColorspace()

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.

Parameters
h_limHue range in degrees [-360, 360].
s_limSaturation range [0, 1].
l_limLightness range [0, 1].
spaceColorspace type
Returns
Reference to this object for chaining.
Exceptions
std::invalid_argumentfor invalid ranges.

◆ setInputHex()

Qualpal & qualpal::Qualpal::setInputHex ( const std::vector< std::string > &  colors)

Set input colors from a vector of hex color strings.

Parameters
colorsVector of hex color strings (e.g., "#ff0000").
Returns
Reference to this object for chaining.
Exceptions
std::invalid_argumentif any hex string is invalid.

◆ setInputPalette()

Qualpal & qualpal::Qualpal::setInputPalette ( const std::string &  palette_name)

Set input colors from a named palette.

Parameters
palette_namePalette name in the format "Package:Palette".
Returns
Reference to this object for chaining.
Exceptions
std::invalid_argumentif the palette name is invalid.

◆ setInputRGB()

Qualpal & qualpal::Qualpal::setInputRGB ( const std::vector< colors::RGB > &  colors)

Set input colors from a vector of RGB values.

Parameters
colorsVector of RGB colors to use as input.
Returns
Reference to this object for chaining.

◆ setMemoryLimit()

Qualpal & qualpal::Qualpal::setMemoryLimit ( double  gb)

Set the maximum memory limit (in GB) for color difference matrix.

Parameters
gbMemory limit in gigabytes.
Returns
Reference to this object for chaining.
Exceptions
std::invalid_argumentif gb <= 0.

◆ setMetric()

Qualpal & qualpal::Qualpal::setMetric ( metrics::MetricType  metric)

Set the color difference metric to use.

Parameters
metricMetric type (e.g., DIN99d).
Returns
Reference to this object for chaining.

The documentation for this class was generated from the following file: