diff --git a/include/hyprutils/math/Region.hpp b/include/hyprutils/math/Region.hpp index 856489b..f7589f2 100644 --- a/include/hyprutils/math/Region.hpp +++ b/include/hyprutils/math/Region.hpp @@ -49,6 +49,7 @@ namespace Hyprutils { CRegion& invert(const CBox& box); CRegion& scale(float scale); CRegion& scale(const Vector2D& scale); + CRegion& expand(double units); CRegion& rationalize(); CBox getExtents(); bool containsPoint(const Vector2D& vec) const; diff --git a/src/math/Region.cpp b/src/math/Region.cpp index 81eda8b..e69ddb8 100644 --- a/src/math/Region.cpp +++ b/src/math/Region.cpp @@ -112,6 +112,19 @@ CRegion& Hyprutils::Math::CRegion::transform(const eTransform t, double w, doubl return *this; } +CRegion& Hyprutils::Math::CRegion::expand(double units) { + auto rects = getRects(); + + clear(); + + for (auto& r : rects) { + CBox b{(double)r.x1 - units, (double)r.y1 - units, (double)r.x2 - r.x1 + units * 2, (double)r.y2 - r.y1 + units * 2}; + add(b); + } + + return *this; +} + CRegion& Hyprutils::Math::CRegion::rationalize() { intersect(CBox{-MAX_REGION_SIDE, -MAX_REGION_SIDE, MAX_REGION_SIDE * 2, MAX_REGION_SIDE * 2}); return *this;