Introduction
Introduction Statistics Contact Development Disclaimer Help
up and down (centred) trapezium working - gramscii - A simple editor for ASCII …
Log
Files
Refs
Tags
README
LICENSE
---
commit 47a17a404c2faabc3db70df3a7a64a462a1a9d21
parent 7eb5b5f064f07bc50cafa1488961fa7be27dee22
Author: KatolaZ <[email protected]>
Date: Sat, 28 Sep 2019 21:48:38 +0100
up and down (centred) trapezium working
Diffstat:
M draw.c | 37 ++++++++++++++++++++++++++---…
M gramscii.h | 6 +++---
2 files changed, 35 insertions(+), 8 deletions(-)
---
diff --git 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;
diff --git a/gramscii.h b/gramscii.h
@@ -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
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.