From 7eb5b5f064f07bc50cafa1488961fa7be27dee22 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Mon, 26 Aug 2019 17:30:40 +0100 Subject: up-center trapezium working --- draw.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'draw.c') diff --git a/draw.c b/draw.c index e1ee63b..3e973b9 100644 --- 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