fix short side in left and right trapezium - gramscii - A simple editor for ASCII box-and-arrow charts
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit c5123472d732ee8d512c914707251b0053d758e1
 (DIR) parent 6dddf567f41d43335698598d310c161fb01462ac
 (HTM) Author: KatolaZ <katolaz@freaknet.org>
       Date:   Sun, 29 Sep 2019 21:08:57 +0100
       
       fix short side in left and right trapezium
       
       Diffstat:
         M draw.c                              |      31 ++++++++++++++++---------------
       
       1 file changed, 16 insertions(+), 15 deletions(-)
       ---
 (DIR) diff --git a/draw.c b/draw.c
       @@ -215,9 +215,12 @@ void draw_trapezium(int x1, int y1, char st, char fix){
                xmax = MAX(x, x1);
                ymin = MIN(y, y1);
                ymax = MAX(y, y1);
       -        dx = xmax - xmin;
       +        dx = (xmax - xmin);
                dy = ymax - ymin;
       -        
       +        /* dy = MAX(dx2, dy); */
       +#ifdef DEBUG
       +        fprintf(stderr, "dy: %d dx: %d\n", dy, dx);
       +#endif        
                if (fix == FIX){
                        f = set_xy;
                        copy_lines_to_ring(ymin, ymax, PRV_STATE);
       @@ -252,15 +255,12 @@ void draw_trapezium(int x1, int y1, char st, char fix){
                for(i=xmin+1; i<=xmax; i++){
                        f(i, ylong, line_h);
                }
       -        /* short side */
       -        for(i=xmin+xoff; i<=xmax-xoff; i++){
       -                f(i, yshort, line_h);
       -        }
                
                if (STYLE_IS(st, BOX_TRAP_L)){
       +                /* short side */
                        left_c = '/';
                        right_c = line_v;
       -                for(i=xmax-xoff;i<xmax; i++){
       +                for(i=xmin+xoff;i<xmax; i++){
                                f(i, yshort, line_h);
                        }
                        xoff = dy;
       @@ -272,14 +272,13 @@ void draw_trapezium(int x1, int y1, char st, char fix){
                                f(xmin+xoff, i, left_c);
                                f(xmax, i, right_c);
                        }
       -                xoff = dy;
       -                f(xmin+xoff, yshort, corner);
       +                f(xmin+dy, yshort, corner);
                        f(xmax, yshort, corner);
                }
                else if (STYLE_IS(st, BOX_TRAP_R)){
                        right_c = '\\';
                        left_c = line_v;
       -                for(i=xmin; i<xmin+xoff; i++){
       +                for(i=xmin; i<xmax-xoff; i++){
                                f(i, yshort, line_h);
                        }
                        xoff = dy-1;
       @@ -291,11 +290,14 @@ void draw_trapezium(int x1, int y1, char st, char fix){
                                f(xmin, i, left_c);
                                f(xmax-xoff, i, right_c);
                        }
       -                xoff = dy;
                        f(xmin, yshort, corner);
       -                f(xmax-xoff, yshort, corner);
       +                f(xmax-dy, yshort, corner);
                }
                else if (STYLE_IS(st, BOX_TRAP_C)){
       +                xoff = dy;
       +                for (i=xmin+xoff; i<=xmax-xoff; i++){
       +                        f(i, yshort, line_h);
       +                }
                        xoff = dy - 1;
                        if (STYLE_IS(st, BOX_TRAP_D))
                                xoff = 1;
       @@ -303,9 +305,8 @@ void draw_trapezium(int x1, int y1, char st, char fix){
                                f(xmin + xoff, i, left_c);
                                f(xmax - xoff, i, right_c);
                        }
       -                xoff = dy;
       -                f(xmin+xoff, yshort, corner);
       -                f(xmax-xoff, yshort, corner);
       +                f(xmin+dy, yshort, corner);
       +                f(xmax-dy, yshort, corner);
                }