universal indexing rules in BezierCurve

This commit is contained in:
muddmaker
2014-12-31 23:19:07 -08:00
parent 2c5f7dc896
commit 47a4cc34a5
3 changed files with 12 additions and 9 deletions
+6 -3
View File
@@ -54,7 +54,8 @@ int w_BezierCurve_getControlPoint(lua_State *L)
BezierCurve *curve = luax_checkbeziercurve(L, 1);
int idx = luaL_checkinteger(L, 2);
idx--; // 1-indexing
if (idx > 0) // 1-indexing
idx--;
luax_catchexcept(L, [&]() {
Vector v = curve->getControlPoint(idx);
@@ -72,7 +73,8 @@ int w_BezierCurve_setControlPoint(lua_State *L)
float vx = (float) luaL_checknumber(L, 3);
float vy = (float) luaL_checknumber(L, 4);
idx--; // 1-indexing
if (idx > 0) // 1-indexing
idx--;
luax_catchexcept(L, [&](){ curve->setControlPoint(idx, Vector(vx,vy)); });
return 0;
@@ -97,7 +99,8 @@ int w_BezierCurve_removeControlPoint(lua_State *L)
BezierCurve *curve = luax_checkbeziercurve(L, 1);
int idx = luaL_checkint(L, 2);
idx--; // 1-indexing
if (idx > 0) // 1-indexing
idx--;
luax_catchexcept(L, [&](){ curve->removeControlPoint(idx); });
return 0;