diff options
-rw-r--r-- | draw.c | 37 | ||||
-rw-r--r-- | gramscii.h | 6 |
2 files changed, 35 insertions, 8 deletions
@@ -209,7 +209,7 @@ void draw_trapezium(int x1, int y1, char st, char fix){ int xincr; int i; void (*f)(int, int, char); - + char left_c, right_c; xmin = MIN(x, x1); xmax = MAX(x, x1); @@ -226,11 +226,27 @@ void draw_trapezium(int x1, int y1, char st, char fix){ f = draw_xy; /* This is valid only for "upper" trapezoids */ - if (st & BOX_TRAP_U){ + if ((st & BOX_TRAP_U) == BOX_TRAP_U){ +#ifdef DEBUG + fprintf(stderr, "This is an 'upward' trapezium\n"); +#endif ylong = ymax; yshort = ymin; xoff = dy; xincr = -1; + left_c = '/'; + right_c = '\\'; + } + else if ((st & BOX_TRAP_D) == BOX_TRAP_D){ +#ifdef DEBUG + fprintf(stderr, "This is a 'downward' trapezium\n"); +#endif + ylong = ymin; + yshort = ymax; + xoff = dy; + xincr = +1; + right_c = '/'; + left_c = '\\'; } for(i=xmin+1; i<=xmax; i++){ f(i, ylong, line_h); @@ -243,9 +259,11 @@ void draw_trapezium(int x1, int y1, char st, char fix){ f(xmax-xoff, yshort, corner); f(xmax, ylong, corner); xoff --; + if ((st & BOX_TRAP_D) == BOX_TRAP_D) + xoff = 1; for(i=ymin+1; i<ymax; i++, xoff += xincr){ - f(xmin + xoff, i, '/'); - f(xmax - xoff, i, '\\'); + f(xmin + xoff, i, left_c); + f(xmax - xoff, i, right_c); } @@ -272,6 +290,12 @@ void update_box(int x1, int y1, char st, char fix){ } char toggle_trap_type(char st){ + if (st & BOX_TRAP){ + if (st < BOX_TRAP_DR) + st ++; + else + st = BOX_TRAP_UR; + } return st; } @@ -300,13 +324,16 @@ void get_box(FILE *fc, char st){ st = flip_par_lean(st); redraw(); #ifdef DEBUG - fprintf(stderr, "new parallelogram style: %d\n", st); + fprintf(stderr, "new parallelogram style: %d\n", st); #endif update_box(orig_x, orig_y, st, NOFIX); continue; } else if (c == 'T' && (st & BOX_TRAP)){ st = toggle_trap_type(st); +#ifdef DEBUG + fprintf(stderr, "new trapezium style: %d\n", st); +#endif redraw(); update_box(orig_x, orig_y, st, NOFIX); continue; @@ -50,9 +50,9 @@ #define BOX_TRAP_UR 0x25 #define BOX_TRAP_UC 0x26 #define BOX_TRAP_UL 0x27 -#define BOX_TRAP_DL 0x28 -#define BOX_TRAP_DC 0x29 -#define BOX_TRAP_DR 0x2a +#define BOX_TRAP_DL 0x29 +#define BOX_TRAP_DC 0x2a +#define BOX_TRAP_DR 0x2b /**/ #define NOFIX 0x0 |