PdfColorHsl.fromRgb constructor
Creates an HSL color from red, green, and blue components
Implementation
factory PdfColorHsl.fromRgb(double red, double green, double blue,
[double alpha = 1.0]) {
final max = math.max(red, math.max(green, blue));
final min = math.min(red, math.min(green, blue));
final delta = max - min;
final hue = _getHue(red, green, blue, max, delta);
final lightness = (max + min) / 2.0;
// Saturation can exceed 1.0 with rounding errors, so clamp it.
final saturation = lightness == 1.0
? 0.0
: (delta / (1.0 - (2.0 * lightness - 1.0).abs())).clamp(0.0, 1.0);
return PdfColorHsl._(hue, saturation, lightness, alpha, red, green, blue);
}