summaryrefslogtreecommitdiff
path: root/draw.c
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2019-09-28 21:48:38 +0100
committerKatolaZ <katolaz@freaknet.org>2019-09-28 21:48:38 +0100
commit47a17a404c2faabc3db70df3a7a64a462a1a9d21 (patch)
tree7e5fc281e998cf7b2fd42c9a1d910df4a92f8849 /draw.c
parent7eb5b5f064f07bc50cafa1488961fa7be27dee22 (diff)
up and down (centred) trapezium working
Diffstat (limited to 'draw.c')
-rw-r--r--draw.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/draw.c b/draw.c
index 3e973b9..822113f 100644
--- a/draw.c
+++ b/draw.c
@@ -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;