diff options
author | Oliver Schinagl <oliver@schinagl.nl> | 2008-01-03 17:04:42 (GMT) |
---|---|---|
committer | Oliver Schinagl <oliver@schinagl.nl> | 2008-01-03 17:04:42 (GMT) |
commit | 909340f9a5299194c582f9224f21f4f4daf56e51 (patch) | |
tree | 987fdc136590a23ad59ad984a2c47798bade24a0 /Smoke/colormap.c | |
parent | 8edd0c2ad477886571fe1d75219d5ca17255fdf0 (diff) | |
download | 2iv35-909340f9a5299194c582f9224f21f4f4daf56e51.zip 2iv35-909340f9a5299194c582f9224f21f4f4daf56e51.tar.gz 2iv35-909340f9a5299194c582f9224f21f4f4daf56e51.tar.bz2 |
cleanup and fixes
Diffstat (limited to 'Smoke/colormap.c')
-rw-r--r-- | Smoke/colormap.c | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/Smoke/colormap.c b/Smoke/colormap.c index 12b6f4b..392bbac 100644 --- a/Smoke/colormap.c +++ b/Smoke/colormap.c @@ -7,6 +7,7 @@ #include <rfftw.h> +#include "fluids.h" #include "funcs.h" #include "palette.h" @@ -32,6 +33,8 @@ static float colormap_clamp_min = 0.0f; static float colormap_clamp_max = 0.9999f; +static int colormap_autoscaling = FALSE; + static fftw_real *colormap_frame; @@ -138,21 +141,14 @@ float colormap_get_clamp_max(void) return colormap_clamp_max; } - -static float remap(float value) +void colormap_set_autoscaling(int autoscaling) { - value -= colormap_scale_min; - value /= (colormap_scale_max - colormap_scale_min); - - return value; + colormap_autoscaling = autoscaling; } -static float clamp(float value) +int colormap_get_autoscaling(void) { - if (value < colormap_clamp_min) value = colormap_clamp_min; - if (value > colormap_clamp_max) value = colormap_clamp_max; - - return value; + return colormap_autoscaling; } void colormap_set_frame(fftw_real *frame) @@ -166,6 +162,43 @@ fftw_real *colormap_get_frame(void) } + +void colormap_autoscale(void) +{ + if (colormap_autoscaling) { + int k; + float value, scale_min, scale_max; + + scale_min = scale_max = get_dataset(0); + colormap_scale_min = scale_min; + colormap_scale_max = scale_max; + + for (k = 1; k < DIM * DIM; k++) + { + value = get_dataset(k); + + if (scale_min > value) { colormap_scale_min = value; } + if (scale_max < value) { colormap_scale_max = value; } + } + } +} + +static float remap(float value) +{ + value -= colormap_scale_min; + value /= (colormap_scale_max - colormap_scale_min); + + return value; +} + +static float clamp(float value) +{ + if (value < colormap_clamp_min) value = colormap_clamp_min; + if (value > colormap_clamp_max) value = colormap_clamp_max; + + return value; +} + struct color4f colormap_get_color(float value) { struct color4f return_value; |