mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
bugfix: intersected geom should be initiated with a fresh copy of self
This commit is contained in:
@@ -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