#15 Реализовано втупую и всякие выравнивания с текстами надо добавлять вручную. Зато у нас есть поддержка анимаций и дерева матриц преобразования. Вообще UI - это просто иерархия прямоугольников на экране. Reviewed-on: #18
25 lines
547 B
Lua
25 lines
547 B
Lua
--- @class Rect
|
|
--- @field x number
|
|
--- @field y number
|
|
--- @field width number
|
|
--- @field height number
|
|
local rect = {}
|
|
rect.__index = rect
|
|
|
|
--- @param table {x: number, y: number, width: number, height: number}
|
|
function rect.new(table)
|
|
local r = {
|
|
x = table.x or 0,
|
|
y = table.y or 0,
|
|
width = table.width or 0,
|
|
height = table.height or 0
|
|
}
|
|
return setmetatable(r, rect)
|
|
end
|
|
|
|
function rect:hasPoint(x, y)
|
|
return x >= self.x and x < self.width and y >= self.y and y < self.height
|
|
end
|
|
|
|
return rect.new
|