Skip to content

Commit

Permalink
math/region: add expand
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Jul 5, 2024
1 parent 259ecfa commit a8c3a13
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/hyprutils/math/Region.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions src/math/Region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a8c3a13

Please sign in to comment.