/*
5 * 2015 Alexei Boronine (
original idea, JavaScript implementation)
6 * 2015 Roger Tallada (Obj-C implementation)
7 * 2017 Martin Mitas (C implementation, based on Obj-C implementation)
8 * 2021 Massinissa Derriche (C++ implementation
for Inkscape, based on C implementation)
9 * 2023 Martin Owens (New
Color classes)
11 * Copyright (C) 2023 Authors
12 * Released under GNU GPL v2+, read the file
'COPYING' for more information.
29 std::array<Geom::Line, 6>
bounds;
32 double sub1 = (tl * tl * tl) / 1560896.0;
37 for (channel = 0; channel < 3; channel++) {
38 double m1 =
d65[channel][0];
39 double m2 =
d65[channel][1];
40 double m3 =
d65[channel][2];
42 for (t = 0; t < 2; t++) {
43 double top1 = (284517.0 * m1 - 94839.0 * m3) * sub2;
44 double top2 = (838422.0 * m3 + 769860.0 * m2 + 731718.0 * m1) * l * sub2 - 769860.0 * t * l;
45 double bottom = (632260.0 * m3 - 126452.0 * m2) * sub2 + 126452.0 * t;
47 bounds[channel * 2 + t].setCoefficients(top1, -bottom, top2);
63 double min_len = std::numeric_limits<double>::max();
67 auto intersections = line.intersect(ray);
68 if (intersections.empty()) {
71 double len = intersections[0].point().length();
73 if (
len >= 0 &&
len < min_len) {
88 double h = in_out[0] * 360;
89 double s = in_out[1] * 100;
90 double l = in_out[2] * 100;
94 if (l > 99.9999999 || l < 0.00000001) {
101 if (s < 0.00000001) {
117 double l = in_out[0];
118 double c = in_out[1];
119 double h = in_out[2];
123 if (l > 99.9999999 || l < 0.00000001) {
130 if (
c < 0.00000001) {
Two-dimensional point that doubles as a vector.
Straight ray from a specific point to infinity.
static void toLch(std::vector< double > &output)
Convert a color from the the HSLuv colorspace to the LCH colorspace.
static void fromLch(std::vector< double > &output)
Convert a color from the the LCH colorspace to the HSLuv colorspace.
static std::array< Geom::Line, 6 > get_bounds(double l)
Calculate the bounds of the Luv colors in RGB gamut.
static double max_chroma_for_lh(double l, double h)
Calculate the maximum in gamut chromaticity for the given luminance and hue.
const std::vector< double > d65[3]
Helper class to stream background task notifications as a series of messages.