From f2963b9e2afe2b54534d695be740dc2cc4e99d04 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Tue, 28 Sep 2010 20:33:40 -0300 Subject: [PATCH] Added a thin black border above and below the projections. - solidify/style.h (PROJECTION_BORDER): number of pixels to leave dark above and below the face - solidify/level.c (draw_xz, draw_zy, level): increase projection z size by twice the border width - solidify/level.c (draw_xz, draw_zy): offset z coordinates by the border --- solidify/level.c | 28 ++++++++++++++++++---------- solidify/style.h | 1 + 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/solidify/level.c b/solidify/level.c index b358d8e..e95f61b 100644 --- a/solidify/level.c +++ b/solidify/level.c @@ -95,7 +95,7 @@ static void draw_image(GtkWidget *widget, struct face *f, int osd) static void draw_xz(GtkWidget *widget, struct face *f, int y) { int zm = f->a->max_z; - int sz = f->sz*z0_scale(f); + int sz = f->sz*z0_scale(f)+2*PROJECTION_BORDER; int x, z; double z0; guchar *rgbbuf, *p; @@ -111,19 +111,22 @@ static void draw_xz(GtkWidget *widget, struct face *f, int y) z0 = face_z0(f, x, y); if (z == UNDEF || z == z0) { aa_line(rgbbuf, x, - (zm-z0)*z0_scale(f), (zm-z0)*z0_scale(f), + (zm-z0)*z0_scale(f)+PROJECTION_BORDER, + (zm-z0)*z0_scale(f)+PROJECTION_BORDER, sz-1, f->sx, (uint8_t *) "\0\0\xff", vpoint); continue; } if (z > z0) { aa_line(rgbbuf, x, - (zm-z)*z0_scale(f), (zm-z0)*z0_scale(f), + (zm-z)*z0_scale(f)+PROJECTION_BORDER, + (zm-z0)*z0_scale(f)+PROJECTION_BORDER, sz-1, f->sx, (uint8_t *) "\0\xff\0", vpoint); } else { aa_line(rgbbuf, x, - (zm-z0)*z0_scale(f), (zm-z)*z0_scale(f), + (zm-z0)*z0_scale(f)+PROJECTION_BORDER, + (zm-z)*z0_scale(f)+PROJECTION_BORDER, sz-1, f->sx, (uint8_t *) "\xff\0\0", vpoint); } @@ -139,7 +142,7 @@ static void draw_xz(GtkWidget *widget, struct face *f, int y) static void draw_zy(GtkWidget *widget, struct face *f, int x) { int zm = f->a->max_z; - int sz = f->sz*z0_scale(f); + int sz = f->sz*z0_scale(f)+2*PROJECTION_BORDER; int y, z; double z0; guchar *rgbbuf, *p; @@ -155,19 +158,22 @@ static void draw_zy(GtkWidget *widget, struct face *f, int x) z0 = face_z0(f, x, f->sy-y-1); if (z == UNDEF || z == z0) { aa_line(rgbbuf, y, - (zm-z0)*z0_scale(f), (zm-z0)*z0_scale(f), + (zm-z0)*z0_scale(f)+PROJECTION_BORDER, + (zm-z0)*z0_scale(f)+PROJECTION_BORDER, sz-1, sz, (uint8_t *) "\0\0\xff", hpoint); continue; } if (z > z0) { aa_line(rgbbuf, y, - (zm-z)*z0_scale(f), (zm-z0)*z0_scale(f), + (zm-z)*z0_scale(f)+PROJECTION_BORDER, + (zm-z0)*z0_scale(f)+PROJECTION_BORDER, sz-1, sz, (uint8_t *) "\0\xff\0", hpoint); } else { aa_line(rgbbuf, y, - (zm-z0)*z0_scale(f), (zm-z)*z0_scale(f), + (zm-z0)*z0_scale(f)+PROJECTION_BORDER, + (zm-z)*z0_scale(f)+PROJECTION_BORDER, sz-1, sz, (uint8_t *) "\xff\0\0", hpoint); } @@ -298,8 +304,10 @@ void level(GtkWidget *canvas, struct face *f) GDK_POINTER_MOTION_MASK); gtk_widget_set_size_request(xy, f->sx, f->sy); - gtk_widget_set_size_request(xz, f->sx, f->sz*z0_scale(f)); - gtk_widget_set_size_request(zy, f->sz*z0_scale(f), f->sy); + gtk_widget_set_size_request(xz, + f->sx, f->sz*z0_scale(f)+2*PROJECTION_BORDER); + gtk_widget_set_size_request(zy, + f->sz*z0_scale(f)+2*PROJECTION_BORDER, f->sy); gtk_table_set_row_spacings(GTK_TABLE(tab), 2); gtk_table_set_col_spacings(GTK_TABLE(tab), 2); diff --git a/solidify/style.h b/solidify/style.h index 39085fb..275178c 100644 --- a/solidify/style.h +++ b/solidify/style.h @@ -26,6 +26,7 @@ extern GdkGC *gc_osd; #define SLOWEST_ROT 3 /* thrice the half-diagonal */ #define FASTEST_ROT 2 /* one pixel in distance of 2 pixels */ #define DIST_STEPS 5 /* fastest shift is 5 px/wheel step */ +#define PROJECTION_BORDER 2 /* pixels around projections */ void init_style(GdkDrawable *da);