Introduction
Introduction Statistics Contact Development Disclaimer Help
up-center trapezium working - gramscii - A simple editor for ASCII box-and-arro…
Log
Files
Refs
Tags
README
LICENSE
---
commit 7eb5b5f064f07bc50cafa1488961fa7be27dee22
parent e8c98a65cd161a5d2c0a76d41e39b352e083a9ab
Author: KatolaZ <[email protected]>
Date: Mon, 26 Aug 2019 17:30:40 +0100
up-center trapezium working
Diffstat:
M TODO | 3 +--
M draw.c | 48 +++++++++++++++++++++++++++++…
M gramscii.c | 4 ++++
M gramscii.h | 23 +++++++++++++----------
M screen.c | 2 ++
5 files changed, 68 insertions(+), 12 deletions(-)
---
diff --git a/TODO b/TODO
@@ -1,7 +1,6 @@
+ optimize redraws (redraw only the modified rectangle)
- add screen geometry option (-g 25x80?)
-- (?)maybe move "text" mode to "t"
-- implement trapezium
++ implement trapezium
- implement ellipse
- (?) filled box (B)
- (?) manage filled box character (as for other styles)
diff --git a/draw.c b/draw.c
@@ -204,6 +204,54 @@ char flip_par_lean(char st){
}
void draw_trapezium(int x1, int y1, char st, char fix){
+ int xmin, ymin, xmax, ymax;
+ int dx, dy, ylong, yshort, xoff;
+ int xincr;
+ int i;
+ void (*f)(int, int, char);
+
+
+ xmin = MIN(x, x1);
+ xmax = MAX(x, x1);
+ ymin = MIN(y, y1);
+ ymax = MAX(y, y1);
+ dx = xmax - xmin;
+ dy = ymax - ymin;
+
+ if (fix == FIX){
+ f = set_xy;
+ copy_lines_to_ring(ymin, ymax, PRV_STATE);
+ }
+ else
+ f = draw_xy;
+
+ /* This is valid only for "upper" trapezoids */
+ if (st & BOX_TRAP_U){
+ ylong = ymax;
+ yshort = ymin;
+ xoff = dy;
+ xincr = -1;
+ }
+ for(i=xmin+1; i<=xmax; i++){
+ f(i, ylong, line_h);
+ }
+ for(i=xmin+xoff; i<=xmax-xoff; i++){
+ f(i, yshort, line_h);
+ }
+ f(xmin+xoff, yshort, corner);
+ f(xmin, ylong, corner);
+ f(xmax-xoff, yshort, corner);
+ f(xmax, ylong, corner);
+ xoff --;
+ for(i=ymin+1; i<ymax; i++, xoff += xincr){
+ f(xmin + xoff, i, '/');
+ f(xmax - xoff, i, '\\');
+ }
+
+
+ if (fix == FIX)
+ copy_lines_to_ring(ymin, ymax, NEW_STATE);
+ show_cursor();
}
diff --git a/gramscii.c b/gramscii.c
@@ -134,6 +134,10 @@ void commands(FILE *fc){
case 'r':
read_file_at(fc, x, y);
break;
+ case 't':
+ mode = TRP;
+ get_box(fc, BOX_TRAP_UC);
+ break;
case 'z':
mode = PAR;
get_box(fc, BOX_PARR);
diff --git a/gramscii.h b/gramscii.h
@@ -20,6 +20,7 @@
#define VIS 0x10
#define PAR 0x20
#define REM 0x40
+#define TRP 0x80
/**/
/* directions */
@@ -37,19 +38,21 @@
/* rectangular box */
#define BOX_RECT 0x00
/* parallelograms */
-#define BOX_PAR 0x04
+#define BOX_PAR 0x10
/* parallelogram (leaning right) */
-#define BOX_PARR 0x05
+#define BOX_PARR 0x11
/* parallelogram (leaning left) */
-#define BOX_PARL 0x06
+#define BOX_PARL 0x12
/* trapezium */
-#define BOX_TRAP 0x10
-#define BOX_TRAP_UR 0x11
-#define BOX_TRAP_UC 0x12
-#define BOX_TRAP_UL 0x13
-#define BOX_TRAP_DL 0x14
-#define BOX_TRAP_DC 0x15
-#define BOX_TRAP_DR 0x16
+#define BOX_TRAP 0x20
+#define BOX_TRAP_U 0x24
+#define BOX_TRAP_D 0x28
+#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 NOFIX 0x0
diff --git a/screen.c b/screen.c
@@ -39,6 +39,8 @@ char* mode_str(){
return "par";
case REM:
return "rem";
+ case TRP:
+ return "trp";
default:
return "ERR";
}
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.