toRGB method

List<int> toRGB()

Implementation

List<int> toRGB() {
  double r;
  double g;
  double b;

  final double h = _bound(this.h * 360, 360.0);
  final double s = _bound(this.s * 100, 100.0);
  final double l = _bound(this.l * 100, 100.0);

  if (s == 0.0) {
    r = g = b = l;
  } else {
    final q = l < 0.5 ? l * (1.0 + s) : l + s - l * s;
    final p = 2 * l - q;
    r = _hue2rgb(p, q, h + 1 / 3);
    g = _hue2rgb(p, q, h);
    b = _hue2rgb(p, q, h - 1 / 3);
  }
  return [r, g, b].map((e) => (e * 255).round()).toList();
}