19#ifndef MiL_SVG_COLOR_BAND_H
20#define MiL_SVG_COLOR_BAND_H 1
58 color c = std::get<0>(cb);
59 ushort hn = std::get<1>(cb);
62 auto itr = std::find(spectrum.begin(), spectrum.end(), c);
63 if (itr == spectrum.end())
65 string m(
"collection::make_color_band_v1: color " +
to_string(c));
66 m +=
" not found in spectrum of size ";
67 m += std::to_string(spectrum.size());
68 throw std::runtime_error(
m);
70 const ulong offset = std::distance(spectrum.begin(), itr);
73 static std::mt19937_64 rg(std::random_device{}());
76 auto disti = std::uniform_int_distribution<>(0, hn - 1);
79 auto distr = std::uniform_real_distribution<>(0, 1);
83 for (
ushort i = 0; i < neededh; ++i)
92 double c1r = distr(rg);
93 double c2r = 2.0 - c1r;
95 cband.push_back(cgen);
107 const auto [ klro, sz ] = cb;
111 std::set<color_qi> uklrs;
112 for (
uint i = 0; i < sz; ++i)
117 std::cout <<
"colorband 1: " << std::to_string(uklrs.size()) << k::newline;
122 for (
uint i = 0; i < neededh; i++)
128 string m(
"make_color_band_v2:: colorband looping error" + k::newline);
129 m +=
"starting color: ";
131 m +=
"starting color band size: ";
132 m += std::to_string(sz) + k::newline;
133 std::cout <<
m << k::newline;
140 std::cout <<
"colorband 2: " << std::to_string(uklrs.size()) << k::newline;
142 color_qis cband(uklrs.begin(), uklrs.end());
144 std::reverse(cband.begin(), cband.end());
146 std::cout <<
"end colorband: " << std::to_string(sz) << k::newline;
177 const color c = std::get<0>(cb);
181 ret = gband_bw.back();
185 ret = gband_y.back();
189 ret = gband_o.back();
193 ret = gband_brown.back();
194 gband_brown.pop_back();
197 ret = gband_r.back();
201 ret = gband_g.back();
205 ret = gband_b.back();
209 ret = gband_p.back();
213 string m(
"next_in_color_band:: error");
217 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_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.
const color_qi to_color_qi()
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.