bugfix: intersected geom should be initiated with a fresh copy of self
This commit is contained in:
1 parent
6561475cf7
commit
dc22370cf1
1 file changed
+7
-1
@@ -117,7 +117,8 @@ returns a rectangle for the part that we and a given rectangle share
|
||||
TODO: what happens if there is no rectangle shared? currently behaviour is undefined.
|
||||
]]--
|
||||
function Geom:intersect(rect_b)
|
||||
local intersected = Geom:new(self)
|
||||
-- make a copy of self
|
||||
local intersected = self:copy()
|
||||
if self.x < rect_b.x then
|
||||
intersected.x = rect_b.x
|
||||
end
|
||||
@@ -259,6 +260,11 @@ function Geom:offsetWithin(rect_b, dx, dy)
|
||||
end
|
||||
end
|
||||
|
||||
function Geom:shrinkInside(rect_b, dx, dy)
|
||||
self:offsetBy(dx, dy)
|
||||
return self:intersect(rect_b)
|
||||
end
|
||||
|
||||
--[[
|
||||
return the Euclidean distance between two geoms
|
||||
]]--
|
||||
|
||||
Reference in new issue
Block a user