mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-03 19:05:59 -04:00
Add div/mul/remainder operators with another Point as an argument
This commit is contained in:
parent
47f0263ca3
commit
495f873736
@ -82,14 +82,26 @@ Point Point::operator/(int value) const {
|
|||||||
return Point(x / value, y / value);
|
return Point(x / value, y / value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Point Point::operator/(const Point& other) const {
|
||||||
|
return Point(x / other.x, y / other.y);
|
||||||
|
}
|
||||||
|
|
||||||
Point Point::operator%(int value) const {
|
Point Point::operator%(int value) const {
|
||||||
return Point(x % value, y % value);
|
return Point(x % value, y % value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Point Point::operator%(const Point& other) const {
|
||||||
|
return Point(x % other.x, y % other.y);
|
||||||
|
}
|
||||||
|
|
||||||
Point Point::operator*(int value) const {
|
Point Point::operator*(int value) const {
|
||||||
return Point(x * value, y * value);
|
return Point(x * value, y * value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Point Point::operator*(const Point& other) const {
|
||||||
|
return Point(x * other.x, y * other.y);
|
||||||
|
}
|
||||||
|
|
||||||
Point& Point::operator+=(const Point& other) {
|
Point& Point::operator+=(const Point& other) {
|
||||||
x += other.x;
|
x += other.x;
|
||||||
y += other.y;
|
y += other.y;
|
||||||
@ -111,6 +123,13 @@ Point& Point::operator/=(int value) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Point& Point::operator/=(const Point& other) {
|
||||||
|
x /= other.x;
|
||||||
|
y /= other.y;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
Point& Point::operator%=(int value) {
|
Point& Point::operator%=(int value) {
|
||||||
x %= value;
|
x %= value;
|
||||||
y %= value;
|
y %= value;
|
||||||
@ -118,6 +137,13 @@ Point& Point::operator%=(int value) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Point& Point::operator%=(const Point& other) {
|
||||||
|
x %= other.x;
|
||||||
|
y %= other.y;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
Point& Point::operator*=(int value) {
|
Point& Point::operator*=(int value) {
|
||||||
x *= value;
|
x *= value;
|
||||||
y *= value;
|
y *= value;
|
||||||
@ -125,6 +151,13 @@ Point& Point::operator*=(int value) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Point& Point::operator*=(const Point& other) {
|
||||||
|
x *= other.x;
|
||||||
|
y *= other.y;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
Point Point::GetClamped(const Rect& rect) const {
|
Point Point::GetClamped(const Rect& rect) const {
|
||||||
Point p = *this;
|
Point p = *this;
|
||||||
p.Clamp(rect);
|
p.Clamp(rect);
|
||||||
|
@ -189,31 +189,71 @@ public:
|
|||||||
///
|
///
|
||||||
/// \param[in] value Divisor
|
/// \param[in] value Divisor
|
||||||
///
|
///
|
||||||
/// \returns New Point representing memberwise division of point by an integer
|
/// \returns New Point representing memberwise division of
|
||||||
|
/// point by an integer
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Point operator/(int value) const;
|
Point operator/(int value) const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get point's memberwise remainder from integer division
|
/// \brief Get point's memberwise division by another point
|
||||||
///
|
///
|
||||||
/// \param[in] value Divisor
|
/// \param[in] value Divisor
|
||||||
///
|
///
|
||||||
/// \returns New Point representing memberwise remainder from point divided by an integer
|
/// \returns New Point representing memberwise division of
|
||||||
|
/// point by another point
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
Point operator/(const Point& other) const;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get point's memberwise remainder from division
|
||||||
|
/// by an integer
|
||||||
|
///
|
||||||
|
/// \param[in] value Divisor
|
||||||
|
///
|
||||||
|
/// \returns New Point representing memberwise remainder
|
||||||
|
/// from division by an integer
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Point operator%(int value) const;
|
Point operator%(int value) const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get point's memberwise multiplication by an integer
|
/// \brief Get point's memberwise remainder from division
|
||||||
|
/// by another point
|
||||||
|
///
|
||||||
|
/// \param[in] value Divisor
|
||||||
|
///
|
||||||
|
/// \returns New Point representing memberwise remainder
|
||||||
|
/// from division by another point
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
Point operator%(const Point& other) const;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get point's memberwise multiplication by an
|
||||||
|
/// integer
|
||||||
///
|
///
|
||||||
/// \param[in] value Multiplier
|
/// \param[in] value Multiplier
|
||||||
///
|
///
|
||||||
/// \returns New Point representing memberwise multiplication of point by an integer
|
/// \returns New Point representing memberwise multiplication
|
||||||
|
/// of point by an integer
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Point operator*(int value) const;
|
Point operator*(int value) const;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get point's memberwise multiplication by anoter
|
||||||
|
/// point
|
||||||
|
///
|
||||||
|
/// \param[in] value Multiplier
|
||||||
|
///
|
||||||
|
/// \returns New Point representing memberwise multiplication
|
||||||
|
/// of point by another point
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
Point operator*(const Point& other) const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Memberwise add another point
|
/// \brief Memberwise add another point
|
||||||
///
|
///
|
||||||
@ -245,7 +285,17 @@ public:
|
|||||||
Point& operator/=(int value);
|
Point& operator/=(int value);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Memberwise remainder from integer division
|
/// \brief Memberwise divide by another point
|
||||||
|
///
|
||||||
|
/// \param[in] value Divisor
|
||||||
|
///
|
||||||
|
/// \returns Reference to self
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
Point& operator/=(const Point& other);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Memberwise remainder from division by an integer
|
||||||
///
|
///
|
||||||
/// \param[in] value Divisor
|
/// \param[in] value Divisor
|
||||||
///
|
///
|
||||||
@ -254,6 +304,17 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Point& operator%=(int value);
|
Point& operator%=(int value);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Memberwise remainder from division by another
|
||||||
|
/// point
|
||||||
|
///
|
||||||
|
/// \param[in] value Divisor
|
||||||
|
///
|
||||||
|
/// \returns Reference to self
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
Point& operator%=(const Point& other);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Memberwise multiply by an integer
|
/// \brief Memberwise multiply by an integer
|
||||||
///
|
///
|
||||||
@ -265,7 +326,18 @@ public:
|
|||||||
Point& operator*=(int value);
|
Point& operator*=(int value);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get a point with coordinates modified so it fits into a given rect
|
/// \brief Memberwise multiply by another point
|
||||||
|
///
|
||||||
|
/// \param[in] value Multiplier
|
||||||
|
///
|
||||||
|
/// \returns Reference to self
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
Point& operator*=(const Point& other);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Get a point with coordinates modified so it fits
|
||||||
|
/// into a given rect
|
||||||
///
|
///
|
||||||
/// \param[in] rect Rectangle to clamp with
|
/// \param[in] rect Rectangle to clamp with
|
||||||
///
|
///
|
||||||
@ -275,7 +347,8 @@ public:
|
|||||||
Point GetClamped(const Rect& rect) const;
|
Point GetClamped(const Rect& rect) const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Clamp point coordinates to make it fit into a given rect
|
/// \brief Clamp point coordinates to make it fit into a
|
||||||
|
/// given rect
|
||||||
///
|
///
|
||||||
/// \param[in] rect Rectangle to clamp with
|
/// \param[in] rect Rectangle to clamp with
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user