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:
parent
e8d5c53cbf
commit
5c0292f914
2 changed files with 13 additions and 3 deletions
|
|
@ -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
|
||||
|
|
@ -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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue