diff options
author | Oliver Schinagl <oliver@schinagl.nl> | 2007-12-19 20:59:56 (GMT) |
---|---|---|
committer | Oliver Schinagl <oliver@schinagl.nl> | 2007-12-19 20:59:56 (GMT) |
commit | 5f1fc7b0711f51dd05077303f854c658ccd9dcba (patch) | |
tree | 7d519f704a04a8f25d3e5f14ce809a7d985c4581 /Smoke/colormap.c | |
parent | a60088999da4f44bf5885f431fe78eb87d643ae7 (diff) | |
download | 2iv35-5f1fc7b0711f51dd05077303f854c658ccd9dcba.zip 2iv35-5f1fc7b0711f51dd05077303f854c658ccd9dcba.tar.gz 2iv35-5f1fc7b0711f51dd05077303f854c658ccd9dcba.tar.bz2 |
Loads of splitting, gui templates added for other elements
Diffstat (limited to 'Smoke/colormap.c')
-rw-r--r-- | Smoke/colormap.c | 94 |
1 files changed, 4 insertions, 90 deletions
diff --git a/Smoke/colormap.c b/Smoke/colormap.c index efe0114..d9ede0f 100644 --- a/Smoke/colormap.c +++ b/Smoke/colormap.c @@ -5,6 +5,7 @@ #include <math.h> + #include "funcs.h" #include "palette.h" @@ -39,12 +40,12 @@ int colormap_get_num_colors(void) return colormap_num_colors; } -void colormap_set_map(int color_map) +void colormap_set_colormap(int colormap) { - colormap_colormap = color_map; + colormap_colormap = colormap; } -int colormap_get_map(void){ +int colormap_get_colormap(void){ return colormap_colormap; } @@ -133,93 +134,6 @@ static float clamp(float value) return value; } -void HSVtoRGB(float *r, float *g, float *b, float h, float s, float v) -{ - int i; - float f, p, q, t; - - if( s == 0 ) { - // achromatic (grey) - *r = *g = *b = v; - return; - } - - h /= 60; // sector 0 to 5 - i = floor(h); - f = h - i; // factorial part of h - p = v * (1 - s); - q = v * (1 - s * f); - t = v * (1 - s * (1 - f)); - - switch(i) { - case 0: - *r = v; - *g = t; - *b = p; - break; - case 1: - *r = q; - *g = v; - *b = p; - break; - case 2: - *r = p; - *g = v; - *b = t; - break; - case 3: - *r = p; - *g = q; - *b = v; - break; - case 4: - *r = t; - *g = p; - *b = v; - break; - default: // case 5: - *r = v; - *g = p; - *b = q; - break; - } - -} - -// r,g,b values are from 0 to 1 -// h = [0,360], s = [0,1], v = [0,1] -// if s == 0, then h = -1 (undefined) -void RGBtoHSV( float r, float g, float b, float *h, float *s, float *v ) -{ - float min, max, delta; - - min = MIN3(r, g, b); - max = MAX3(r, g, b); - *v = max; // v - - delta = max - min; - - if(max != 0) { - *s = delta / max; // s - } else { - // r = g = b = 0 // s = 0, v is undefined - *s = 0; - *h = -1; - return; - } - - if(r == max) { - *h = ( g - b ) / delta; // between yellow & magenta - } else if(g == max) { - *h = 2 + (b - r) / delta; // between cyan & yellow - } else { - *h = 4 + (r - g) / delta; // between magenta & cyan - } - *h *= 60; // degrees - if(*h < 0) { - *h += 360; - } -} struct color4f colormap_get_color(float value) { |