MCPcopy Create free account
hub / github.com/NetHack/NetHack / l_selection_ellipse

Function l_selection_ellipse

src/nhlsel.c:809–854  ·  view source on GitHub ↗

local s = selection.ellipse(x, y, radius1, radius2); */ local s = selection.ellipse(x, y, radius1, radius2, filled); */ local s = selection.ellipse(sel, x, y, radius1, radius2); */ local s = selection.ellipse(sel, x, y, radius1, radius2, filled); */

Source from the content-addressed store, hash-verified

807/* local s = selection.ellipse(sel, x, y, radius1, radius2); */
808/* local s = selection.ellipse(sel, x, y, radius1, radius2, filled); */
809staticfn int
810l_selection_ellipse(lua_State *L)
811{
812 int argc = lua_gettop(L);
813 struct selectionvar *sel = (struct selectionvar *) 0;
814 coordxy x = 0, y = 0;
815 int r1 = 0, r2 = 0, filled = 0;
816
817 if (argc == 4) {
818 x = (coordxy) luaL_checkinteger(L, 1);
819 y = (coordxy) luaL_checkinteger(L, 2);
820 r1 = (int) luaL_checkinteger(L, 3);
821 r2 = (int) luaL_checkinteger(L, 4);
822 lua_pop(L, 4);
823 (void) l_selection_new(L);
824 sel = l_selection_check(L, 1);
825 filled = 0;
826 } else if (argc == 5 && lua_type(L, 1) == LUA_TNUMBER) {
827 x = (coordxy) luaL_checkinteger(L, 1);
828 y = (coordxy) luaL_checkinteger(L, 2);
829 r1 = (int) luaL_checkinteger(L, 3);
830 r2 = (int) luaL_checkinteger(L, 4);
831 filled = (int) luaL_optinteger(L, 5, 0); /* TODO: boolean */
832 lua_pop(L, 5);
833 (void) l_selection_new(L);
834 sel = l_selection_check(L, 1);
835 } else if (argc == 5 || argc == 6) {
836 sel = l_selection_check(L, 1);
837 x = (coordxy) luaL_checkinteger(L, 2);
838 y = (coordxy) luaL_checkinteger(L, 3);
839 r1 = (int) luaL_checkinteger(L, 4);
840 r2 = (int) luaL_checkinteger(L, 5);
841 filled = (int) luaL_optinteger(L, 6, 0); /* TODO: boolean */
842 } else {
843 nhl_error(L, "wrong parameters");
844 /*NOTREACHED*/
845 }
846
847 get_location_coord(&x, &y, ANY_LOC, gc.coder ? gc.coder->croom : NULL,
848 SP_COORD_PACK(x, y));
849
850 selection_do_ellipse(sel, x, y, r1, r2, !filled);
851
852 lua_settop(L, 1);
853 return 1;
854}
855
856/* Gradients are versatile enough, with so many independently optional
857 * arguments, that it doesn't seem helpful to provide a non-table form with

Callers

nothing calls this directly

Calls 5

l_selection_newFunction · 0.85
l_selection_checkFunction · 0.85
nhl_errorFunction · 0.85
get_location_coordFunction · 0.85
selection_do_ellipseFunction · 0.85

Tested by

no test coverage detected