From 06b1b08c47b19345428f0a84f8776e81a7d50370 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 23 Sep 2010 19:55:11 -0300 Subject: [PATCH] Added red and green band to blue band as further visual clues. - solidify/level.c (draw_map): moved open-coded "almost at the same height" parameter to constant NEAR - solidify/level.c (draw_map): draw green and red band next to the "near" blue band --- solidify/level.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/solidify/level.c b/solidify/level.c index 077fbce..43175d4 100644 --- a/solidify/level.c +++ b/solidify/level.c @@ -8,6 +8,9 @@ #include "level.h" +#define NEAR 1 + + static void draw_map(GtkWidget *widget, struct face *f) { int x, y, z; @@ -27,19 +30,21 @@ static void draw_map(GtkWidget *widget, struct face *f) continue; } z0 = f->z_ref+f->fx*(x-f->sx/2)+f->fy*(y-f->sy/2); - if (fabs(z-z0) < 1) { + if (fabs(z-z0) < NEAR) { *p++ = 255*fabs(z-z0); *p++ = 255*fabs(z-z0); *p++ = 255; continue; } if (z < z0) { - z = 255.0*(z-z0)/(z0-f->a->min_z); + z = z > z0-2*NEAR ? 255*(z-z0)/NEAR : + 255.0*(z-z0)/(z0-f->a->min_z); *p++ = 255; *p++ = z; *p++ = z; } else { - z = 255.0*(z0-z)/(f->a->max_z-z0); + z = z < z0+2*NEAR ? 255*(z0-z)/NEAR : + 255.0*(z0-z)/(f->a->max_z-z0); *p++ = z; *p++ = 255; *p++ = z;