Qualpal API for generating qualitative color palettes.
This file defines the Qualpal class, which provides a builder-style interface for configuring and generating maximally distinct color palettes using perceptual color difference. The API supports multiple input formats, color vision deficiency simulation, and flexible configuration options.
.
setCvd({{
"protan", 0.5}, {
"deuter", 0.2}})
.setBackground("#ffffff")
{{0, 60}, {0.5, 1.0}, {0.3, 0.7}},
{{180, 240}, {0.5, 1.0}, {0.3, 0.7}}
}, qualpal::ColorspaceType::HSL);
auto palette3 =
std::vector<qualpal::colors::RGB> base{ "#ff0000", "#a9ef93", "#ffe302" };
Builder for qualitative color palette generation.
Qualpal & setInputRGB(const std::vector< colors::RGB > &colors)
Set input colors from a vector of RGB values.
Qualpal & setMetric(metrics::MetricType metric)
Set the color difference metric to use.
Qualpal & setInputPalette(const std::string &palette_name)
Set input colors from a named palette.
std::vector< colors::RGB > generate(std::size_t n)
Generate a qualitative color palette with the configured options.
Qualpal & setMemoryLimit(double gb)
Set the maximum memory limit (in GB) for color difference matrix.
Qualpal & setInputColorspace(const std::array< double, 2 > &h_lim, const std::array< double, 2 > &s_or_c_lim, const std::array< double, 2 > &l_lim, ColorspaceType space=ColorspaceType::HSL)
Set input colors by sampling a colorspace (HSL or LCHab).
Qualpal & setWhitePoint(WhitePoint wp)
Set the reference white point for color conversions.
std::vector< colors::RGB > extend(const std::vector< colors::RGB > &palette, std::size_t n)
Extend an existing palette by adding n new colors.
Qualpal & setInputColorspaceRegions(const std::vector< ColorspaceRegion > ®ions, ColorspaceType space=ColorspaceType::HSL)
Set input colors by sampling multiple regions in a colorspace.
Qualpal & setInputHex(const std::vector< std::string > &colors)
Set input colors from a vector of hex color strings.
Qualpal & setCvd(const std::map< std::string, double > &cvd_params)
Set color vision deficiency simulation parameters.
@ DIN99d
DIN99d color difference.
@ D50
Daylight 5000K {0.96422, 1.0, 0.82521}.