19#ifndef MiL_SVG_COLOR_BAND_H
20#define MiL_SVG_COLOR_BAND_H 1
59 color c = std::get<0>(cb);
60 ushort hn = std::get<1>(cb);
63 auto itr = std::find(spectrum.begin(), spectrum.end(), c);
64 if (itr == spectrum.end())
66 string m(
"collection::make_color_band_v1: color " +
to_string(c));
67 m +=
" not found in spectrum of size ";
68 m += std::to_string(spectrum.size());
69 throw std::runtime_error(
m);
71 const ulong offset = std::distance(spectrum.begin(), itr);
74 static std::mt19937_64 rg(std::random_device{}());
77 auto disti = std::uniform_int_distribution<>(0, hn - 1);
80 auto distr = std::uniform_real_distribution<>(0, 1);
84 for (
ushort i = 0; i < neededh; ++i)
93 double c1r = distr(rg);
94 double c2r = 2.0 - c1r;
96 cband.push_back(cgen);
108 const auto [ klro, sz ] = cb;
112 std::set<color_qi> uklrs;
113 for (
uint i = 0; i < sz; ++i)
118 std::cout <<
"colorband 1: " << std::to_string(uklrs.size()) << k::newline;
123 for (
uint i = 0; i < neededh; i++)
129 string m(
"make_color_band_v2:: colorband looping error" + k::newline);
130 m +=
"starting color: ";
132 m +=
"starting color band size: ";
133 m += std::to_string(sz) + k::newline;
134 std::cout <<
m << k::newline;
141 std::cout <<
"colorband 2: " << std::to_string(uklrs.size()) << k::newline;
143 color_qis cband(uklrs.begin(), uklrs.end());
145 std::reverse(cband.begin(), cband.end());
147 std::cout <<
"end colorband: " << std::to_string(sz) << k::newline;
178 const color c = std::get<0>(cb);
182 ret = gband_bw.back();
186 ret = gband_y.back();
190 ret = gband_o.back();
194 ret = gband_brown.back();
195 gband_brown.pop_back();
198 ret = gband_r.back();
202 ret = gband_g.back();
206 ret = gband_b.back();
210 ret = gband_p.back();
214 string m(
"next_in_color_band:: error");
218 throw std::runtime_error(
m);
constexpr colorband cband_b
constexpr colorband cband_y
color
Color enumerated as types.
unsigned short ushort
Base integer type: positive and negative, signed integral value.
const string to_string(const unit e)
std::tuple< color, ushort > colorband
Specific regions of spectrum as bands of color. Each band has a starting hue and a number of known go...
std::vector< color_qi > color_qis
Types for Color iteration and combinatorics.
color_qi next_color(const color_qi klr)
Loop through color array starting at position c. Iff klr is not found, return color::none as the next...
constexpr colorband cband_gray
color_qis make_color_band_v2(const colorband &cb, const ushort neededh)
Algorightm is HSV generation.
constexpr colorband cband_g
color_qf mutate_color_qf(const color_qf &k)
Return a variant on saturation/value only.
color_qis make_color_band(const colorband &cb, const ushort neededh)
Forwarding function.
color_qis make_color_band_v1(const colorband &cb, const ushort neededh, auto &spectrum)
auto & active_spectrum(const bool sortbyhuep=false)
Oklab https://bottosson.github.io/posts/oklab/.
constexpr colorband cband_r
constexpr colorband cband_o
constexpr colorband cband_yo
constexpr colorband cband_bw
Izzi palette-specific offsets for colorbands.
static const palette_qi< color_max_size - 4 > izzi_palette
Default colors for izzi.
constexpr colorband cband_brown
constexpr colorband cband_p
color_qi combine_color_qi(const color_qi &a, const double ad, const color_qi &b, const double bd)
bool color_qf_lt(const color_qf &k1, const color_qf &k2)
Forwarding function.
color_qi next_in_color_band(const colorband &cb, const ushort bandn=400)
Flip through color band colors.
color_qi to_color_qi() const
Back to RGB https://www.rapidtables.com/convert/color/hsv-to-rgb.html.
Color quantified as integral RGB components in the range [0,255]. aka like Scalar in OpenCV.