hsvToRgb static method
Convert hsvColor
from hue, saturation, and value (HSV) color model to
the RGB color model and store it in rgbColor
.
Implementation
static void hsvToRgb(Vector4 hsvColor, Vector4 rgbColor) {
final i = (hsvColor.x * 6.0).floor();
final f = hsvColor.x * 6.0 - i.toDouble();
final p = hsvColor.z * (1.0 - hsvColor.y);
final q = hsvColor.z * (1.0 - f * hsvColor.y);
final t = hsvColor.z * (1.0 - (1.0 - f) * hsvColor.y);
switch (i % 6) {
case 0:
rgbColor.setValues(hsvColor.z, t, p, hsvColor.a);
break;
case 1:
rgbColor.setValues(q, hsvColor.z, p, hsvColor.a);
break;
case 2:
rgbColor.setValues(p, hsvColor.z, t, hsvColor.a);
break;
case 3:
rgbColor.setValues(p, q, hsvColor.z, hsvColor.a);
break;
case 4:
rgbColor.setValues(t, p, hsvColor.z, hsvColor.a);
break;
case 5:
rgbColor.setValues(hsvColor.z, p, q, hsvColor.a);
break;
}
}