rgb method

Color rgb()

Convert to RGB based Color.

Implementation

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