Rgba.fromHsla constructor
Rgba.fromHsla(
- Hsla hsla
Implementation
factory Rgba.fromHsla(Hsla hsla) {
// Convert to Rgba.
// See site <http://easyrgb.com/index.php?X=MATH> for good documentation
// and color conversion routines.
var h = hsla.hue;
var s = hsla.saturation;
var l = hsla.lightness;
var a = hsla.alpha;
int r;
int g;
int b;
if (s == 0) {
r = (l * 255).round().toInt();
g = r;
b = r;
} else {
num var2;
if (l < 0.5) {
var2 = l * (1 + s);
} else {
var2 = (l + s) - (s * l);
}
var var1 = 2 * l - var2;
r = (255 * Rgba._hueToRGB(var1, var2, h + (1 / 3))).round().toInt();
g = (255 * Rgba._hueToRGB(var1, var2, h)).round().toInt();
b = (255 * Rgba._hueToRGB(var1, var2, h - (1 / 3))).round().toInt();
}
return Rgba(r, g, b, a);
}