MCPcopy Create free account
hub / github.com/The-Powder-Toy/The-Powder-Toy / drawLine

Function drawLine

src/lua/LuaGraphics.cpp:126–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126static int drawLine(lua_State *L)
127{
128 int x1 = lua_tointeger(L, 1);
129 int y1 = lua_tointeger(L, 2);
130 int x2 = lua_tointeger(L, 3);
131 int y2 = lua_tointeger(L, 4);
132 int r = luaL_optint(L, 5, 255);
133 int g = luaL_optint(L, 6, 255);
134 int b = luaL_optint(L, 7, 255);
135 int a = luaL_optint(L, 8, 255);
136
137 if (r<0) r = 0;
138 else if (r>255) r = 255;
139 if (g<0) g = 0;
140 else if (g>255) g = 255;
141 if (b<0) b = 0;
142 else if (b>255) b = 255;
143 if (a<0) a = 0;
144 else if (a>255) a = 255;
145
146 std::visit([x1, y1, x2, y2, r, g, b, a](auto p) {
147 if (a == 255)
148 {
149 p->DrawLine({ x1, y1 }, { x2, y2 }, RGB(r, g, b));
150 }
151 else
152 {
153 p->BlendLine({ x1, y1 }, { x2, y2 }, RGBA(r, g, b, a));
154 }
155 }, GetLSI()->GetGraphics());
156 return 0;
157}
158
159static int drawRect(lua_State *L)
160{

Callers

nothing calls this directly

Calls 6

RGBClass · 0.85
RGBAClass · 0.85
GetLSIFunction · 0.85
DrawLineMethod · 0.45
BlendLineMethod · 0.45
GetGraphicsMethod · 0.45

Tested by

no test coverage detected