fix: ConvertHSVToRGB is effectively 100% matching (#70)

This commit is contained in:
Kai Kaufman 2023-07-02 04:02:05 -04:00 committed by GitHub
parent b91c7d436b
commit 0555e05756
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,10 +9,13 @@ void ConvertHSVToRGB(float h, float s, float v, float *r_out, float *b_out, floa
double v9; double v9;
double v12; double v12;
double v13; double v13;
double s_dbl = s;
if (s > 0.5f) if (s > 0.5f)
calc = (1.0f - v) * s + v; calc = (1.0f - v) * s + v;
else else
calc = (v + 1.0) * s; calc = (v + 1.0) * s_dbl;
if (calc <= 0.0) if (calc <= 0.0)
{ {
*g_out = 0.0f; *g_out = 0.0f;
@ -20,7 +23,7 @@ void ConvertHSVToRGB(float h, float s, float v, float *r_out, float *b_out, floa
*r_out = 0.0f; *r_out = 0.0f;
return; return;
} }
p = s * 2.0 - calc; p = s * 2.0f - calc;
hue_index = h * 6.0; hue_index = h * 6.0;
v9 = (h * 6.0 - (float)hue_index) * ((calc - p) / calc) * calc; v9 = (h * 6.0 - (float)hue_index) * ((calc - p) / calc) * calc;
v12 = p + v9; v12 = p + v9;