mirror of
https://github.com/ctruLua/uCompat.git
synced 2025-10-28 09:09:31 +00:00
Added Image, Motion and Sprite libraries
This commit is contained in:
parent
6d3ec78c8c
commit
0166ba6bce
6 changed files with 307 additions and 2 deletions
68
Image.lua
Normal file
68
Image.lua
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
--[[
|
||||
Images related µLua compatibility layer/lib for ctrµLua
|
||||
|
||||
Actually doesn't support GIFs, because sfillib doesn't. Use PNGs, these are
|
||||
better.
|
||||
]]
|
||||
|
||||
-- Local
|
||||
|
||||
local texture = require("ctr.gfx.texture")
|
||||
|
||||
-- Constants
|
||||
|
||||
RAM = texture.PLACE_RAM
|
||||
VRAM = texture.PLACE_VRAM
|
||||
|
||||
-- Module
|
||||
|
||||
Image = {}
|
||||
|
||||
function Image.load(path, dest)
|
||||
local t = texture.load(path, dest)
|
||||
if not t then return nil end
|
||||
return { -- Image object
|
||||
texture = t,
|
||||
rotation = 0
|
||||
}
|
||||
end
|
||||
|
||||
function Image.destroy(img)
|
||||
img.texture:unload()
|
||||
img = nil
|
||||
end
|
||||
|
||||
function Image.width(img)
|
||||
local x,y = img.texture:getSize()
|
||||
return x
|
||||
end
|
||||
|
||||
function Image.height(img)
|
||||
local x,y = img.texture:getSize()
|
||||
return y
|
||||
end
|
||||
|
||||
function Image.scale(img, w, h)
|
||||
|
||||
end
|
||||
|
||||
function Image.rotate(img, angle, cx, cy)
|
||||
img.rotation = angle*((math.pi*2)/512)
|
||||
end
|
||||
|
||||
function Image.rotateDegree(img, angle, cx, cy)
|
||||
img.rotation = angle*((math.pi*2)/360)
|
||||
end
|
||||
|
||||
function Image.mirrorH(img, activate)
|
||||
|
||||
end
|
||||
|
||||
function Image.mirrorV(img. activate)
|
||||
|
||||
end
|
||||
|
||||
function Image.setTint(img, color)
|
||||
img.texture:setBlendColor(color*256)
|
||||
end
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue