Commit 5c7526cf authored by devill.tamachan's avatar devill.tamachan

コード整理

parent a20f91d1
...@@ -74,9 +74,13 @@ COLORREF ...@@ -74,9 +74,13 @@ COLORREF
hsv2rgb(hsv_t* hsv) hsv2rgb(hsv_t* hsv)
{ {
BYTE r, g, b; BYTE r, g, b;
if(hsv->hue < 0)hsv->hue=0;
else if(hsv->hue > 360*HUE_DEGREE-1)hsv->hue = 360*HUE_DEGREE-1;
r = g = b = hsv->value;
if(hsv->saturation == 0) { if(hsv->saturation == 0) {
r = g = b = hsv->value; //r = g = b = hsv->value;
} else { } else {
int h = hsv->hue; int h = hsv->hue;
int s = hsv->saturation; int s = hsv->saturation;
...@@ -87,16 +91,16 @@ hsv2rgb(hsv_t* hsv) ...@@ -87,16 +91,16 @@ hsv2rgb(hsv_t* hsv)
if(i & 1) { if(i & 1) {
int q = (256*60*HUE_DEGREE*v - h*s*v + 60*HUE_DEGREE*s*v*i) / (256*60*HUE_DEGREE); int q = (256*60*HUE_DEGREE*v - h*s*v + 60*HUE_DEGREE*s*v*i) / (256*60*HUE_DEGREE);
switch(i) { switch(i) {
case 1: r = q; g = v; b = p; break; case 1: r = q; b = p; break;
case 3: r = p; g = q; b = v; break; case 3: r = p; g = q; break;
case 5: r = v; g = p; b = q; break; case 5: g = p; b = q; break;
} }
} else { } else {
int t = (256*60*HUE_DEGREE*v + h*s*v - 60*HUE_DEGREE*s*v*(i+1)) / (256*60*HUE_DEGREE); int t = (256*60*HUE_DEGREE*v + h*s*v - 60*HUE_DEGREE*s*v*(i+1)) / (256*60*HUE_DEGREE);
switch(i) { switch(i) {
case 0: r = v; g = t; b = p; break; case 0: g = t; b = p; break;
case 2: r = p; g = v; b = t; break; case 2: r = p; b = t; break;
case 4: r = t; g = p; b = v; break; case 4: r = t; g = p; break;
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment