| 124 | } |
| 125 | |
| 126 | static 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 | |
| 159 | static int drawRect(lua_State *L) |
| 160 | { |