diff options
author | rgl <devnull@localhost> | 2020-02-03 22:42:28 +0100 |
---|---|---|
committer | rgl <devnull@localhost> | 2020-02-03 22:42:28 +0100 |
commit | 0373255087377122eeb10e006ffb8aa1b57e611c (patch) | |
tree | 33a4fafa4996fc2efa205b2973622c3fbd27f368 /libgraphics/triangle.c | |
download | 3dee-0373255087377122eeb10e006ffb8aa1b57e611c.tar.gz 3dee-0373255087377122eeb10e006ffb8aa1b57e611c.tar.bz2 3dee-0373255087377122eeb10e006ffb8aa1b57e611c.zip |
after a year or so of work, i dare create a proper repo.
Diffstat (limited to 'libgraphics/triangle.c')
-rw-r--r-- | libgraphics/triangle.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libgraphics/triangle.c b/libgraphics/triangle.c new file mode 100644 index 0000000..b598855 --- /dev/null +++ b/libgraphics/triangle.c @@ -0,0 +1,43 @@ +#include <u.h> +#include <libc.h> +#include <draw.h> +#include "../geometry.h" +#include "../graphics.h" + +Triangle +Trian(int x0, int y0, int x1, int y1, int x2, int y2) +{ + return (Triangle){Pt(x0, y0), Pt(x1, y1), Pt(x2, y2)}; +} + +Triangle +Trianpt(Point p0, Point p1, Point p2) +{ + return (Triangle){p0, p1, p2}; +} + +void +triangle(Image *dst, Triangle t, int thick, Image *src, Point sp) +{ + Point pl[4]; + + pl[0] = t.p0; + pl[1] = t.p1; + pl[2] = t.p2; + pl[3] = pl[0]; + + poly(dst, pl, nelem(pl), 0, 0, thick, src, sp); +} + +void +filltriangle(Image *dst, Triangle t, Image *src, Point sp) +{ + Point pl[4]; + + pl[0] = t.p0; + pl[1] = t.p1; + pl[2] = t.p2; + pl[3] = pl[0]; + + fillpoly(dst, pl, nelem(pl), 0, src, sp); +} |