#ifdef G_OS_WIN32 #define WIN32_LEAN_AND_MEAN 1 #include #endif #include #include #include "fluids.h" #include "funcs.h" #include "palette.h" #include "colormap.h" static int colormap_colormap = PALETTE_BLACKWHITE; static int colormap_num_colors = PALETTE_MAXCOLORS; static float colormap_alpha = 0.9f; static int colormap_scaling = FALSE; static int colormap_clamping = FALSE; static float colormap_scale_min = 0.0f; static float colormap_scale_max = 1.0f; static float colormap_clamp_min = 0.0f; static float colormap_clamp_max = 1.0f; static int colormap_autoscaling = FALSE; static fftw_real *colormap_frame; void colormap_set_num_colors(int num_colors) { colormap_num_colors = num_colors; } int colormap_get_num_colors(void) { return colormap_num_colors; } void colormap_set_colormap(int colormap) { colormap_colormap = colormap; } int colormap_get_colormap(void) { return colormap_colormap; } void colormap_set_alpha(float alpha) { colormap_alpha = alpha; } float colormap_get_alpha(void) { return colormap_alpha; } 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) { colormap_scale_min = min_scale; } } float colormap_get_scale_min(void) { return colormap_scale_min; } void colormap_set_scale_max(float max_scale) { if (colormap_scaling) { colormap_scale_max = max_scale; } } float colormap_get_scale_max(void) { return colormap_scale_max; } void colormap_set_clamp_min(float min_clamp) { if (colormap_clamping) { colormap_clamp_min = min_clamp; } } float colormap_get_clamp_min(void) { return colormap_clamp_min; } void colormap_set_clamp_max(float max_clamp) { if (colormap_clamping) { colormap_clamp_max = max_clamp; } } float colormap_get_clamp_max(void) { return colormap_clamp_max; } void colormap_set_autoscaling(int autoscaling) { colormap_autoscaling = autoscaling; } int colormap_get_autoscaling(void) { return colormap_autoscaling; } void colormap_set_frame(fftw_real *frame) { colormap_frame = frame; } fftw_real *colormap_get_frame(void) { return colormap_frame; } 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; value = colormap_clamping ? clamp(value) : value; value = colormap_scaling ? remap(value) : value; return_value = set_palette(colormap_colormap, value, colormap_num_colors); return_value.a = colormap_alpha; return return_value; } void colormap_reset_scaling(void) { colormap_scale_min = 0.0f; colormap_scale_max = 1.0f; } void colormap_reset_clamping(void) { colormap_clamp_min = 0.0f; colormap_clamp_max = 1.0f; }