colourFromHue static method
Constructs a Colour from hue, chroma, secondary component, and match offset values. This is the core algorithm that maps HSL/HSV parameters back to RGB.
Implementation
static Colour colourFromHue(
double alpha,
double hue,
double chroma,
double secondary,
double match,
) {
final (double red, double green, double blue) = switch (hue) {
< 60.0 => (chroma, secondary, 0.0),
< 120.0 => (secondary, chroma, 0.0),
< 180.0 => (0.0, chroma, secondary),
< 240.0 => (0.0, secondary, chroma),
< 300.0 => (secondary, 0.0, chroma),
_ => (chroma, 0.0, secondary),
};
return Colour.fromColor(
Color.fromARGB(
(alpha * 0xFF).round(),
((red + match) * 0xFF).round(),
((green + match) * 0xFF).round(),
((blue + match) * 0xFF).round(),
),
);
}