getRGBMap method
Returns a map with "r", "g", "b" keys that represents the rgb values of the color
Implementation
Map<String, int> getRGBMap() {
num percentSaturation = s / 100;
num percentLightness = l / 100;
num c = (1 - (2 * percentLightness - 1).abs()) * percentSaturation;
num x = c * (1 - ((h / 60) % 2 - 1).abs());
num m = percentLightness - c / 2;
num r, g, b;
if (h < 60) {
r = c;
g = x;
b = 0;
} else if (h < 120) {
r = x;
g = c;
b = 0;
} else if (h < 180) {
r = 0;
g = c;
b = x;
} else if (h < 240) {
r = 0;
g = x;
b = c;
} else if (h < 300) {
r = x;
g = 0;
b = c;
} else {
r = c;
g = 0;
b = x;
}
int red = ((r + m) * 255).round();
int green = ((g + m) * 255).round();
int blue = ((b + m) * 255).round();
return {"r": red, "g": green, "b": blue};
}