PdfColorHsl constructor
Creates an HSL color
Implementation
factory PdfColorHsl(double hue, double saturation, double lightness,
[double alpha = 1.0]) {
final chroma = (1.0 - (2.0 * lightness - 1.0).abs()) * saturation;
final secondary = chroma * (1.0 - (((hue / 60.0) % 2.0) - 1.0).abs());
final match = lightness - chroma / 2.0;
double red;
double green;
double blue;
if (hue < 60.0) {
red = chroma;
green = secondary;
blue = 0.0;
} else if (hue < 120.0) {
red = secondary;
green = chroma;
blue = 0.0;
} else if (hue < 180.0) {
red = 0.0;
green = chroma;
blue = secondary;
} else if (hue < 240.0) {
red = 0.0;
green = secondary;
blue = chroma;
} else if (hue < 300.0) {
red = secondary;
green = 0.0;
blue = chroma;
} else {
red = chroma;
green = 0.0;
blue = secondary;
}
return PdfColorHsl._(
hue,
saturation,
lightness,
alpha,
(red + match).clamp(0.0, 1.0),
(green + match).clamp(0.0, 1.0),
(blue + match).clamp(0.0, 1.0));
}