hslToRgb static method

void hslToRgb(
  1. Vector4 hslColor,
  2. Vector4 rgbColor
)

Convert hslColor from hue, saturation, and lightness (HSL) color model to the RGB color model and store it in rgbColor.

Implementation

static void hslToRgb(Vector4 hslColor, Vector4 rgbColor) {
  if (hslColor.y == 0.0) {
    rgbColor.setValues(hslColor.z, hslColor.z, hslColor.z, hslColor.a);
  } else {
    final q = hslColor.z < 0.5
        ? hslColor.z * (1.0 + hslColor.y)
        : hslColor.z + hslColor.y - hslColor.z * hslColor.y;
    final p = 2.0 * hslColor.z - q;

    final r = _hueToRgb(p, q, hslColor.x + 1.0 / 3.0);
    final g = _hueToRgb(p, q, hslColor.x);
    final b = _hueToRgb(p, q, hslColor.x - 1.0 / 3.0);

    rgbColor.setValues(r, g, b, hslColor.a);
  }
}