colorFromHue static method

Color colorFromHue(
  1. double alpha,
  2. double hue,
  3. double chroma,
  4. double secondary,
  5. double match,
)

Same as colourFromHue but returns a Flutter Color instead of a Colour. Used internally where the Flutter type is needed directly.

Implementation

static Color colorFromHue(
  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 Color.fromARGB(
    (alpha * 0xFF).round(),
    ((red + match) * 0xFF).round(),
    ((green + match) * 0xFF).round(),
    ((blue + match) * 0xFF).round(),
  );
}