rgb method

Color rgb()

Convert to RGB based Color.

Implementation

Color rgb() {
  final num c = (1 - (2 * lightness - 1).abs()) * saturation,
      h2 = hue / 60,
      x = c * (1 - (h2 % 2 - 1).abs()),
      m = lightness - c / 2;
  num r = 0, g = 0, b = 0;
  if (h2 < 1) { r = c; g = x; }
  else if (h2 < 2) { r = x; g = c; }
  else if (h2 < 3) { g = c; b = x; }
  else if (h2 < 4) { g = x; b = c; }
  else if (h2 < 5) { r = x; b = c; }
  else { r = c; b = x; }
  return Color((r + m) * 255, (g + m) * 255, (b + m) * 255, alpha);
}