summaryrefslogtreecommitdiffstats
path: root/Smoke/colormap.c
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2007-12-17 19:48:37 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2007-12-17 19:48:37 (GMT)
commit9363bc6887a7ffb9ea6c0f6a63a93c215e227502 (patch)
treedc5f962bdcc413a5bd4bff4d85c7842522a73fb3 /Smoke/colormap.c
parent1d771540b16ba07cb02be5490892465a2a5ab89a (diff)
download2iv35-9363bc6887a7ffb9ea6c0f6a63a93c215e227502.zip
2iv35-9363bc6887a7ffb9ea6c0f6a63a93c215e227502.tar.gz
2iv35-9363bc6887a7ffb9ea6c0f6a63a93c215e227502.tar.bz2
Added/splitted colormaps to a seperate file.
Diffstat (limited to 'Smoke/colormap.c')
-rw-r--r--Smoke/colormap.c131
1 files changed, 125 insertions, 6 deletions
diff --git a/Smoke/colormap.c b/Smoke/colormap.c
index 4fafe53..6cacb1b 100644
--- a/Smoke/colormap.c
+++ b/Smoke/colormap.c
@@ -3,12 +3,131 @@
#include <windows.h>
#endif
+#include "palette.h"
#include "colormap.h"
+#include "funcs.h"
+static int colormap_num_colors = COLOR_MAXCOLORS;
-#if 0
- if (autoscale)
- {
- vy = remap(vy);
- }
-#endif
+static int colormap = COLOR_BLACKWHITE;
+
+static int colormap_scaling = FALSE;
+
+static int colormap_clamping = FALSE;
+
+static float scale_min = 0.0f;
+
+static float scale_max = 1.0f;
+
+static float clamp_min = 0.0f;
+
+static float clamp_max = 0.9999f;
+
+
+
+void colormap_set_num_colors(int num_colors)
+{
+ colormap_num_colors = num_colors;
+}
+
+void colormap_set_map(int color_map)
+{
+ colormap = color_map;
+}
+
+void colormap_set_scaling(int scaling)
+{
+ colormap_scaling = scaling;
+}
+
+int colormap_get_scaling(void)
+{
+ return colormap_scaling;
+}
+
+void colormap_set_clamping(int clamping)
+{
+ colormap_clamping = clamping;
+}
+
+int colormap_get_clamping(void)
+{
+ return colormap_clamping;
+}
+
+void colormap_set_scale_min(float min_scale)
+{
+ if (colormap_scaling) {
+ scale_min = min_scale;
+ }
+}
+
+float colormap_get_scale_min(void)
+{
+ return scale_min;
+}
+
+void colormap_set_scale_max(float max_scale)
+{
+ if (colormap_scaling) {
+ scale_max = max_scale;
+ }
+}
+
+float colormap_get_scale_max(void)
+{
+ return scale_max;
+}
+
+void colormap_set_clamp_min(float min_clamp)
+{
+ if (colormap_clamping) {
+ clamp_min = min_clamp;
+ }
+}
+
+float colormap_get_clamp_min(void)
+{
+ return clamp_min;
+}
+
+void colormap_set_clamp_max(float max_clamp)
+{
+ if (colormap_clamping) {
+ clamp_max = max_clamp;
+ }
+}
+
+float colormap_get_clamp_max(void)
+{
+ return clamp_max;
+}
+
+
+static float remap(float value)
+{
+ value -= scale_min;
+ value /= (scale_max - scale_min);
+
+ return value;
+}
+
+static float clamp(float value)
+{
+ if (value < clamp_min) value = clamp_min;
+ if (value > clamp_max) value = clamp_max;
+
+ return value;
+}
+
+struct color4f colormap_get_color(float value)
+{
+ struct color4f return_value;
+
+ value = colormap_clamping ? clamp(value) : value;
+ value = colormap_scaling ? remap(value) : value;
+
+ return_value = set_palette(colormap, value, colormap_num_colors);
+
+ return return_value;
+}