diff --git a/sdcard/ctruLua/main.lua b/sdcard/ctruLua/main.lua index d512547..1cde273 100644 --- a/sdcard/ctruLua/main.lua +++ b/sdcard/ctruLua/main.lua @@ -4,6 +4,8 @@ local hid = require("ctr.hid") local x = 0 local y = 0 +local angle = 0 + gfx.color.setBackground(gfx.color.RGBA8(200, 200, 200)) while os.run() do @@ -19,12 +21,15 @@ while os.run() do gfx.startFrame() gfx.color.setDefault(0xFF0000FF) - gfx.rectangle(x, y, 10, 10) + gfx.rectangle(x, y, 10, 10, angle) gfx.color.setDefault(0x00FFFFFF) gfx.rectangle(240, 150, 120, 10) gfx.endFrame() + angle = angle + 0.05 + if angle > 2*math.pi then angle = angle - 2*math.pi end + gfx.render() end \ No newline at end of file diff --git a/source/gfx.c b/source/gfx.c index f6dac1b..cf452ea 100644 --- a/source/gfx.c +++ b/source/gfx.c @@ -30,9 +30,14 @@ static int gfx_rectangle(lua_State *L) { int y = luaL_checkinteger(L, 2); int width = luaL_checkinteger(L, 3); 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; }