summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--draw.c70
-rw-r--r--gramscii.h4
2 files changed, 61 insertions, 13 deletions
diff --git a/draw.c b/draw.c
index 51a27b2..30d0945 100644
--- a/draw.c
+++ b/draw.c
@@ -226,7 +226,7 @@ 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) == BOX_TRAP_U){
+ if (STYLE_IS(st, BOX_TRAP_U)){
#ifdef DEBUG
fprintf(stderr, "This is an 'upward' trapezium\n");
#endif
@@ -237,7 +237,7 @@ void draw_trapezium(int x1, int y1, char st, char fix){
left_c = '/';
right_c = '\\';
}
- else if ((st & BOX_TRAP_D) == BOX_TRAP_D){
+ else if (STYLE_IS(st, BOX_TRAP_D)){
#ifdef DEBUG
fprintf(stderr, "This is a 'downward' trapezium\n");
#endif
@@ -248,25 +248,69 @@ void draw_trapezium(int x1, int y1, char st, char fix){
right_c = '/';
left_c = '\\';
}
+ /* Long side */
for(i=xmin+1; i<=xmax; i++){
f(i, ylong, line_h);
}
- if (st & 0x02){ /* Centred trapezium */
- for(i=xmin+xoff; i<=xmax-xoff; i++){
+ /* short side */
+ for(i=xmin+xoff; i<=xmax-xoff; i++){
+ f(i, yshort, line_h);
+ }
+
+ if (STYLE_IS(st, BOX_TRAP_L)){
+ left_c = '/';
+ right_c = line_v;
+ for(i=xmax-xoff;i<xmax; i++){
f(i, yshort, line_h);
}
+ xoff = dy;
+ if (STYLE_IS(st, BOX_TRAP_D)){
+ xoff = 0;
+ left_c = '\\';
+ }
+ for(i=ymin; i<ymax; i++, xoff += xincr){
+ f(xmin+xoff, i, left_c);
+ f(xmax, i, right_c);
+ }
+ xoff = dy;
+ f(xmin+xoff, yshort, corner);
+ f(xmax, yshort, corner);
}
- f(xmin+xoff, yshort, corner);
+ else if (STYLE_IS(st, BOX_TRAP_R)){
+ right_c = '\\';
+ left_c = line_v;
+ for(i=xmin; i<xmin+xoff; i++){
+ f(i, yshort, line_h);
+ }
+ xoff = dy-1;
+ if (STYLE_IS(st, BOX_TRAP_D)){
+ xoff = 1;
+ right_c = '/';
+ }
+ for(i=ymin+1; i<ymax; i++, xoff += xincr){
+ f(xmin, i, left_c);
+ f(xmax-xoff, i, right_c);
+ }
+ xoff = dy;
+ f(xmin, yshort, corner);
+ f(xmax-xoff, yshort, corner);
+ }
+ else if (STYLE_IS(st, BOX_TRAP_C)){
+ xoff = dy - 1;
+ if (STYLE_IS(st, BOX_TRAP_D))
+ xoff = 1;
+ for(i=ymin+1; i<ymax; i++, xoff += xincr){
+ 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, ylong, corner);
- f(xmax-xoff, yshort, corner);
f(xmax, ylong, corner);
- xoff --;
- if ((st & BOX_TRAP_DC) == BOX_TRAP_DC)
- xoff = 1;
- for(i=ymin+1; i<ymax; i++, xoff += xincr){
- f(xmin + xoff, i, left_c);
- f(xmax - xoff, i, right_c);
- }
if (fix == FIX)
diff --git a/gramscii.h b/gramscii.h
index 9c8959a..e6c5b77 100644
--- a/gramscii.h
+++ b/gramscii.h
@@ -47,12 +47,16 @@
#define BOX_TRAP 0x20
#define BOX_TRAP_U 0x24
#define BOX_TRAP_D 0x28
+#define BOX_TRAP_R 0x21
+#define BOX_TRAP_C 0x22
+#define BOX_TRAP_L 0x23
#define BOX_TRAP_UR 0x25
#define BOX_TRAP_UC 0x26
#define BOX_TRAP_UL 0x27
#define BOX_TRAP_DL 0x29
#define BOX_TRAP_DC 0x2a
#define BOX_TRAP_DR 0x2b
+#define STYLE_IS(x, y) (((x) & (y) ) == y)
/**/
#define NOFIX 0x0