Resize on border (#1347)

This commit is contained in:
Ching Pei Yang 2023-02-18 23:35:31 +01:00 committed by GitHub
parent b944386ca5
commit c92e0c05e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 228 additions and 51 deletions

View file

@ -29,4 +29,10 @@ Vector2D Vector2D::floor() {
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));
}
}
double Vector2D::distance(const Vector2D& other) {
double dx = x - other.x;
double dy = y - other.y;
return std::sqrt(dx * dx + dy * dy);
}

View file

@ -42,8 +42,10 @@ class Vector2D {
Vector2D operator/(const Vector2D& a) const {
return Vector2D(this->x / a.x, this->y / a.y);
}
double distance(const Vector2D& other);
Vector2D clamp(const Vector2D& min, const Vector2D& max = Vector2D());
Vector2D floor();
};
};