Bart van Strien avatar Bart van Strien committed 4ec4e48

Add getWidth and getHeight to Canvas (issue #307)

Comments (0)

Files changed (2)

src/modules/graphics/opengl/wrap_Canvas.cpp

 		return 0;
 	}
 
+	int w_Canvas_getWidth(lua_State * L)
+	{
+		Canvas * canvas = luax_checkcanvas(L, 1);
+		lua_pushnumber(L, canvas->getWidth());
+		return 1;
+	}
+
+	int w_Canvas_getHeight(lua_State * L)
+	{
+		Canvas * canvas = luax_checkcanvas(L, 1);
+		lua_pushnumber(L, canvas->getHeight());
+		return 1;
+	}
+
 	static const luaL_Reg functions[] = {
 		{ "renderTo", w_Canvas_renderTo },
 		{ "getImageData", w_Canvas_getImageData },
 		{ "setWrap", w_Canvas_setWrap },
 		{ "getWrap", w_Canvas_getWrap },
 		{ "clear", w_Canvas_clear },
+		{ "getWidth", w_Canvas_getWidth },
+		{ "getHeight", w_Canvas_getHeight },
 		{ 0, 0 }
 	};
 

src/modules/graphics/opengl/wrap_Canvas.h

 	int w_Canvas_setWrap(lua_State * L);
 	int w_Canvas_getWrap(lua_State * L);
 	int w_Canvas_clear(lua_State * L);
+	int w_Canvas_getWidth(lua_State * L);
+	int w_Canvas_getHeight(lua_State * L);
 	int luaopen_canvas(lua_State * L);
 
 } // opengl
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.