Library Examples
Generate a palette from HSL color space.
#include <qualpal.h>
Builder for qualitative color palette generation.
std::vector< colors::RGB > generate(std::size_t n)
Generate a qualitative color palette with the configured options.
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).
Five colors from the HSL color space
Select colors considering color vision deficiency:
Qualpal & setInputPalette(const std::string &palette_name)
Set input colors from a named palette.
Qualpal & setCvd(const std::map< std::string, double > &cvd_params)
Set color vision deficiency simulation parameters.
Four colors from ColorBrewer Set2 palette with deuteranomaly simulation
Here we design a CVD-friendly version of the "ColorBrewer:Set2"
palette for a black background, selecting 3 colors.
.
setCvd({ {
"tritan", 0.2 }, {
"deutan", 0.5 } })
.generate(3);
Qualpal & setBackground(const colors::RGB &bg_color)
Set the background color for palette generation.
Three colors from ColorBrewer Set2 palette with tritanomaly and deuteranomaly simulation on black background
Generate a palette from custom RGB colors:
colors::RGB("#e41a1c"),
colors::RGB("#377eb8"),
colors::RGB("#4daf4a"),
colors::RGB("#984ea3"),
colors::RGB("#ff7f00"),
});
Qualpal & setInputRGB(const std::vector< colors::RGB > &colors)
Set input colors from a vector of RGB values.
Three colors from given RGB input
Generate a palette using a predefined palette:
Four colors from the Pokemon Porygon palette
Command Line Examples
Generate 5 colors from HSL color space:
qualpal -n 5 -i colorspace "-170:60" "0:0.7" "0.2:0.8"
Five colors from the HSL color space
Select 2 colors from hex values:
qualpal -n 2 "#ff0000" "#00ff00" "#0000ff"
Two colors from hex RGB input
Output palette as comma-delimited values:
qualpal -n 4 --output-delim comma "#ff0000" "#00ff00" "#0000ff" "#ffff00"
#ff0000,#0000ff,#00ff00,#ffff00
Analyze a palette for color difference:
qualpal analyze --input hex "#ff0000" "#00ff00" "#0000ff"
Color Difference Matrix (ciede2000 metric):
Colors analyzed: 3
Colors:
Idx Hex MinDist
0 #ff0000 52.88
1 #00ff00 83.19
2 #0000ff 52.88
Color Difference Matrix:
0 1 2
0 0.00 86.61 52.88
1 86.61 0.00 83.19
2 52.88 83.19 0.00
Generate palette for a dark background
qualpal -n 2 --background "#000000" "#e41a1c" "#377eb8" "#4daf4a" "#984ea3"
Two colors from given RGB input optimized for black background
Simulate color vision deficiency (CVD)
qualpal -n 4 --deutan 0.7 "#e41a1c" "#377eb8" "#4daf4a" "#984ea3"
Four colors from given RGB input with deuteranomaly simulation
Improve an existing palette and select subset
qualpal -n 3 -i palette "ColorBrewer:Set2" -b "#000000" --deutan 0.5 --tritan 0.2
Three colors from ColorBrewer Set2 palette with tritanomaly and deuteranomaly simulation on black background
A soothing pastel palette, generated from a HSL color space:
qualpal -n 5 -i colorspace "20:300" "0.3:0.7" "0.7:0.9"
Extend an existing palette:
qualpal -n 4 -i hex "#4daf4a" "#984ea3" "#ff7f00" "#ffff33" --extend "#e41a1c" "#377eb8"
A fixed palette of red and blue extended with four colors from given RGB input