summaryrefslogtreecommitdiffstats
path: root/Smoke/colormap.c
diff options
context:
space:
mode:
Diffstat (limited to 'Smoke/colormap.c')
-rw-r--r--Smoke/colormap.c55
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;