Exemplo n.º 1
0
static int l_texture_new(lua_State * L)
{
	const char * filename = luaL_checkstring(L, 1);
	struct ltexture_t * texture = lua_newuserdata(L, sizeof(struct ltexture_t));
	texture->surface = cairo_image_surface_create_from_png_xfs(filename);
	if(cairo_surface_status(texture->surface) != CAIRO_STATUS_SUCCESS)
		return 0;
	luaL_setmetatable(L, MT_TEXTURE);
	return 1;
}
Exemplo n.º 2
0
static int l_ninepatch_new(lua_State * L)
{
	const char * filename = luaL_checkstring(L, 1);
	struct lninepatch_t * ninepatch = lua_newuserdata(L, sizeof(struct lninepatch_t));
	cairo_surface_t * surface = cairo_image_surface_create_from_png_xfs(filename);
	if(cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS)
		return 0;
	bool_t result = to_ninepatch(surface, ninepatch);
	cairo_surface_destroy(surface);
	if(!result)
		return 0;
	luaL_setmetatable(L, MT_NAME_NINEPATCH);
	return 1;
}