diff options
| author | jacob1 <jfu614@gmail.com> | 2013-05-14 20:39:20 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-05-14 20:39:20 (GMT) |
| commit | 2e409f966cbae3665ac2d6f9a9a0311f3894e3b6 (patch) | |
| tree | 23c86bdb698caea424e45809dddb0d1bee4fc066 /src/cat/LuaScriptInterface.cpp | |
| parent | 431f5a0083dca3da5c881e507908690ebb5a052a (diff) | |
| download | powder-2e409f966cbae3665ac2d6f9a9a0311f3894e3b6.zip powder-2e409f966cbae3665ac2d6f9a9a0311f3894e3b6.tar.gz | |
gfx.draw/fillcircle
Diffstat (limited to 'src/cat/LuaScriptInterface.cpp')
| -rw-r--r-- | src/cat/LuaScriptInterface.cpp | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index 485f167..15f2def 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -1876,6 +1876,8 @@ void LuaScriptInterface::initGraphicsAPI() {"drawLine", graphics_drawLine}, {"drawRect", graphics_drawRect}, {"fillRect", graphics_fillRect}, + {"drawCircle", graphics_drawCircle}, + {"fillCircle", graphics_fillCircle}, {NULL, NULL} }; luaL_register(l, "graphics", graphicsAPIMethods); @@ -1953,6 +1955,54 @@ int LuaScriptInterface::graphics_drawLine(lua_State * l) int LuaScriptInterface::graphics_drawRect(lua_State * l) { + int x, y, rx, ry, r, g, b, a; + x = lua_tointeger(l, 1); + y = lua_tointeger(l, 2); + rx = lua_tointeger(l, 3); + ry = lua_tointeger(l, 4); + r = luaL_optint(l, 5, 255); + g = luaL_optint(l, 6, 255); + b = luaL_optint(l, 7, 255); + a = luaL_optint(l, 8, 255); + + if (r<0) r = 0; + if (r>255) r = 255; + if (g<0) g = 0; + if (g>255) g = 255; + if (b<0) b = 0; + if (b>255) b = 255; + if (a<0) a = 0; + if (a>255) a = 255; + luacon_g->drawrect(x, y, rx, ry, r, g, b, a); + return 0; +} + +int LuaScriptInterface::graphics_fillRect(lua_State * l) +{ + int x, y, rx, ry, r, g, b, a; + x = lua_tointeger(l, 1); + y = lua_tointeger(l, 2); + rx = lua_tointeger(l, 3); + ry = lua_tointeger(l, 4); + r = luaL_optint(l, 5, 255); + g = luaL_optint(l, 6, 255); + b = luaL_optint(l, 7, 255); + a = luaL_optint(l, 8, 255); + + if (r<0) r = 0; + if (r>255) r = 255; + if (g<0) g = 0; + if (g>255) g = 255; + if (b<0) b = 0; + if (b>255) b = 255; + if (a<0) a = 0; + if (a>255) a = 255; + luacon_g->fillrect(x, y, rx, ry, r, g, b, a); + return 0; +} + +int LuaScriptInterface::graphics_drawCircle(lua_State * l) +{ int x, y, w, h, r, g, b, a; x = lua_tointeger(l, 1); y = lua_tointeger(l, 2); @@ -1971,11 +2021,11 @@ int LuaScriptInterface::graphics_drawRect(lua_State * l) if (b>255) b = 255; if (a<0) a = 0; if (a>255) a = 255; - luacon_g->drawrect(x, y, w, h, r, g, b, a); + luacon_g->drawcircle(x, y, w, h, r, g, b, a); return 0; } -int LuaScriptInterface::graphics_fillRect(lua_State * l) +int LuaScriptInterface::graphics_fillCircle(lua_State * l) { int x, y, w, h, r, g, b, a; x = lua_tointeger(l, 1); @@ -1995,7 +2045,7 @@ int LuaScriptInterface::graphics_fillRect(lua_State * l) if (b>255) b = 255; if (a<0) a = 0; if (a>255) a = 255; - luacon_g->fillrect(x, y, w, h, r, g, b, a); + luacon_g->fillcircle(x, y, w, h, r, g, b, a); return 0; } |
