Browse Source

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

The next step will be to find all the places where this is duplicated.
Emmanuel Lepage Vallee 3 months ago
parent
commit
f60abed1d0
1 changed files with 14 additions and 0 deletions
  1. 14
    0
      lib/gears/geometry.lua

+ 14
- 0
lib/gears/geometry.lua View File

@@ -151,6 +151,20 @@ function gears.geometry.rectangle.get_in_direction(dir, recttbl, cur)
151 151
     return target
152 152
 end
153 153
 
154
+--- Return true if the area are exactly identical.
155
+--
156
+-- The areas are table with a `x`, `y`, `width` and `height` keys.
157
+--
158
+-- @tparam table a The area.
159
+-- @tparam table b The other area.
160
+-- @treturn boolean If the areas are identical.
161
+function gears.geometry.rectangle.are_equal(a, b)
162
+    for _, v in ipairs {"x", "y", "width", "height"} do
163
+        if a[v] ~= b[v] then return false end
164
+    end
165
+    return true
166
+end
167
+
154 168
 --- Check if an area intersect another area.
155 169
 -- @param a The area.
156 170
 -- @param b The other area.

Loading…
Cancel
Save