getPoints and getCoords

This commit is contained in:
lustlion 2022-03-13 10:43:07 +01:00
parent ef632d50ee
commit ba1c0f0c89

View File

@ -9,10 +9,19 @@ function Rect:fromPoints(pt1, pt2)
return o return o
end end
function Rect:getPoints()
return self.min, self.max
end
function Rect:fromCoords(x1, y1, x2, y2) function Rect:fromCoords(x1, y1, x2, y2)
return Rect:fromPoints(Point:new(x1, y1), Point:new(x2, y2)) return Rect:fromPoints(Point:new(x1, y1), Point:new(x2, y2))
end end
function Rect:getCoords()
return self.min.x, self.min.y, self.max.x, self.max.y
end
-- clone refers to a deep copy -- clone refers to a deep copy
function Rect:clone() function Rect:clone()
return Rect:fromCoords(self.min.x, self.min.y, self.max.x, self.max.y) return Rect:fromCoords(self.min.x, self.min.y, self.max.x, self.max.y)