ref: 2fe3ed3100c86497b7a4506d9495338609c945e2
parent: f5e46949cee9ce3053d87b38f3b9e36dc2d9af1b
author: phil9 <[email protected]>
date: Wed Nov 30 04:27:08 EST 2022
implement triangle shape
--- a/api.c
+++ b/api.c
@@ -200,6 +200,29 @@
return 0;
}
+int
+ctriangle(lua_State *L)
+{
+ Point p[4];
+ int x1, y1, x2, y2, x3, y3;
+
+ x1 = luaL_checkinteger(L, 1);
+ y1 = luaL_checkinteger(L, 2);
+ x2 = luaL_checkinteger(L, 3);
+ y2 = luaL_checkinteger(L, 4);
+ x3 = luaL_checkinteger(L, 5);
+ y3 = luaL_checkinteger(L, 6);
+ p[0] = Pt(x1, y1);
+ p[1] = Pt(x2, y2);
+ p[2] = Pt(x3, y3);
+ p[3] = p[0];
+ if(!nofill)
+ fillpoly(canvas, p, 3, 0, fill, ZP);
+ if(!nostroke)
+ poly(canvas, p, 4, 0, 0, strokewidth, stroke, ZP);
+ return 0;
+}
+
void
registerfunc(lua_State *L, const char *name, int(*f)(lua_State*))
{
@@ -222,5 +245,6 @@
registerfunc(L, "circle", ccircle);
registerfunc(L, "ellipse", cellipse);
registerfunc(L, "arc", carc);
+ registerfunc(L, "triangle", ctriangle);
}