mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-05 22:51:58 -07:00
added Vector2D::clamp
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "Vector2D.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
Vector2D::Vector2D(double xx, double yy) {
|
||||
x = xx;
|
||||
@@ -20,4 +21,11 @@ double Vector2D::normalize() {
|
||||
|
||||
Vector2D Vector2D::floor() {
|
||||
return Vector2D((int)x, (int)y);
|
||||
}
|
||||
|
||||
Vector2D Vector2D::clamp(const Vector2D& min, const Vector2D& max) {
|
||||
return Vector2D(
|
||||
std::clamp(this->x, min.x, max.x == 0 ? INFINITY : max.x),
|
||||
std::clamp(this->y, min.y, max.y == 0 ? INFINITY : max.y)
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user