mirror of
https://github.com/hyprwm/hyprutils.git
synced 2024-11-16 23:05:58 +01:00
math/region: add expand
This commit is contained in:
parent
259ecfa098
commit
a8c3a13570
2 changed files with 14 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue