qualpal 3.3.0
Loading...
Searching...
No Matches
qualpal.h
Go to the documentation of this file.
1
41#pragma once
42
43#include <map>
44#include <optional>
45#include <qualpal/colors.h>
46#include <qualpal/metrics.h>
47#include <vector>
48
53namespace qualpal {
54
64{
65 HSL,
66 LCHab
67};
68
80{
81public:
85 Qualpal() = default;
86
93 Qualpal& setInputRGB(const std::vector<colors::RGB>& colors);
94
101 Qualpal& setInputHex(const std::vector<std::string>& colors);
102
109 Qualpal& setInputPalette(const std::string& palette_name);
110
121 Qualpal& setInputColorspace(const std::array<double, 2>& h_lim,
122 const std::array<double, 2>& s_or_c_lim,
123 const std::array<double, 2>& l_lim,
124 ColorspaceType space = ColorspaceType::HSL);
125
135 Qualpal& setCvd(const std::map<std::string, double>& cvd_params);
136
143
150
158
166 Qualpal& setColorspaceSize(std::size_t n_points);
167
175 std::vector<colors::RGB> generate(std::size_t n);
176
185 std::vector<colors::RGB> extend(const std::vector<colors::RGB>& palette,
186 std::size_t n);
187
188private:
189 std::vector<colors::RGB> selectColors(
190 std::size_t n,
191 const std::vector<colors::RGB>& fixed_palette = {});
192
193 std::vector<colors::RGB> rgb_colors_in;
194
195 std::vector<std::string> hex_colors;
196
197 std::string palette;
198
199 std::array<double, 2> h_lim = { 0, 360 };
200 std::array<double, 2> s_or_c_lim = { 0, 1 };
201 std::array<double, 2> l_lim = { 0, 1 };
202 std::size_t n_points = 1000;
203
207 enum class Mode
208 {
209 NONE,
210 RGB,
211 HEX,
212 PALETTE,
213 COLORSPACE
214 } mode = Mode::NONE;
215
216 std::map<std::string, double> cvd;
217 std::optional<colors::RGB> bg;
219 double max_memory = 1;
220 ColorspaceType colorspace_input = ColorspaceType::HSL;
221};
222
223} // namespace qualpal
Builder for qualitative color palette generation.
Definition qualpal.h:80
Qualpal & setInputRGB(const std::vector< colors::RGB > &colors)
Set input colors from a vector of RGB values.
Qualpal & setColorspaceSize(std::size_t n_points)
Set the number of points in the colorspace grid for HSL and LCHab input.
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).
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 & setBackground(const colors::RGB &bg_color)
Set the background color for palette generation.
Qualpal()=default
Default constructor. Initializes with no input source.
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.
RGB color representation with values in [0,1] range.
Definition colors.h:92
Color representation classes.
Color difference metrics for qualpal.
MetricType
Supported color difference metrics for palette generation and analysis.
Definition metrics.h:91
@ CIEDE2000
CIEDE2000 (Delta E 2000) color difference.
Qualitative color palette generation library.
Definition analyze.h:21
ColorspaceType
Supported cylindrical color spaces for input colors.
Definition qualpal.h:64