1
0
Fork 0
mirror of https://github.com/ctruLua/ctruLua.git synced 2025-10-27 16:39:29 +00:00

Added angle support to ctr.gfx.rectangle

This commit is contained in:
Reuh 2015-08-18 16:55:38 +02:00
parent e8d5c53cbf
commit 5c0292f914
2 changed files with 13 additions and 3 deletions

View file

@ -4,6 +4,8 @@ local hid = require("ctr.hid")
local x = 0 local x = 0
local y = 0 local y = 0
local angle = 0
gfx.color.setBackground(gfx.color.RGBA8(200, 200, 200)) gfx.color.setBackground(gfx.color.RGBA8(200, 200, 200))
while os.run() do while os.run() do
@ -19,12 +21,15 @@ while os.run() do
gfx.startFrame() gfx.startFrame()
gfx.color.setDefault(0xFF0000FF) gfx.color.setDefault(0xFF0000FF)
gfx.rectangle(x, y, 10, 10) gfx.rectangle(x, y, 10, 10, angle)
gfx.color.setDefault(0x00FFFFFF) gfx.color.setDefault(0x00FFFFFF)
gfx.rectangle(240, 150, 120, 10) gfx.rectangle(240, 150, 120, 10)
gfx.endFrame() gfx.endFrame()
angle = angle + 0.05
if angle > 2*math.pi then angle = angle - 2*math.pi end
gfx.render() gfx.render()
end end

View file

@ -30,9 +30,14 @@ static int gfx_rectangle(lua_State *L) {
int y = luaL_checkinteger(L, 2); int y = luaL_checkinteger(L, 2);
int width = luaL_checkinteger(L, 3); int width = luaL_checkinteger(L, 3);
int height = luaL_checkinteger(L, 4); int height = luaL_checkinteger(L, 4);
u32 color = luaL_optinteger(L, 5, color_default);
sf2d_draw_rectangle(x, y, width, height, color); float angle = luaL_optnumber(L, 5, 0);
u32 color = luaL_optinteger(L, 6, color_default);
if (angle == 0)
sf2d_draw_rectangle(x, y, width, height, color);
else
sf2d_draw_rectangle_rotate(x, y, width, height, color, angle);
return 0; return 0;
} }