fix: remove some problems in point and rects

This commit is contained in:
Kazhnuz Klappsthul 2020-11-27 16:02:21 +01:00
parent fb55c9e706
commit cf1928444f
2 changed files with 11 additions and 2 deletions

View File

@ -31,7 +31,7 @@ function Point:setPosition(x, y)
self.x, self.y = x, y
end
function Point:move(x, y)
function Point:goToward(x, y)
local x = x or 0
local y = y or 0
self:setPosition(self.x + x, self.y + y)
@ -63,7 +63,7 @@ function Point:getMiddlePoint(x, y)
return utils.math.getMiddlePoint(self.x, self.y, x, y)
end
function Point:getDirectionFromPoint(other)
function Point:getMiddlePointFromPoint(other)
local x, y = other:getPosition()
self:getMiddlePoint(x, y)
end

View File

@ -29,6 +29,11 @@ function Rect:new(x, y, w, h)
self:setSize(w, h)
end
function Rect:set(x, y, w, h)
self:setPosition(x, y)
self:setSize(w, h)
end
function Rect:setSize(w, h)
self.w = w or self.w
self.h = h or self.h
@ -39,6 +44,10 @@ function Rect:getArea()
return x, y, self.w, self.h
end
function Rect:getShape()
return self:getArea()
end
function Rect:getCorners()
local x, y, w, h = self:getArea()
return x, y, x + w, y + h