gears.geometry: Add a function to compare 2 rectangles.

The next step will be to find all the places where this is duplicated.
This commit is contained in:
Emmanuel Lepage Vallee 2019-06-24 17:10:50 -04:00
parent f1335be21a
commit f60abed1d0
1 changed files with 14 additions and 0 deletions

View File

@ -151,6 +151,20 @@ function gears.geometry.rectangle.get_in_direction(dir, recttbl, cur)
return target return target
end end
--- Return true if the area are exactly identical.
--
-- The areas are table with a `x`, `y`, `width` and `height` keys.
--
-- @tparam table a The area.
-- @tparam table b The other area.
-- @treturn boolean If the areas are identical.
function gears.geometry.rectangle.are_equal(a, b)
for _, v in ipairs {"x", "y", "width", "height"} do
if a[v] ~= b[v] then return false end
end
return true
end
--- Check if an area intersect another area. --- Check if an area intersect another area.
-- @param a The area. -- @param a The area.
-- @param b The other area. -- @param b The other area.