 |
Flutter Impeller
|
|
Go to the documentation of this file.
11 #include <type_traits>
26 constexpr
TPoint() =
default;
35 static_cast<
Type>(other.height)) {}
43 return TPoint{
static_cast<Type>(std::round(other.
x)),
44 static_cast<Type>(std::round(other.
y))};
48 return p.
x ==
x && p.
y ==
y;
52 return p.
x !=
x || p.
y !=
y;
57 x +=
static_cast<Type>(p.
x);
58 y +=
static_cast<Type>(p.
y);
71 x -=
static_cast<Type>(p.
x);
72 y -=
static_cast<Type>(p.
y);
85 x *=
static_cast<Type>(p.
x);
86 y *=
static_cast<Type>(p.
y);
97 template <
class U,
class = std::enable_if_t<std::is_arithmetic_v<U>>>
99 x *=
static_cast<Type>(scale);
100 y *=
static_cast<Type>(scale);
106 x /=
static_cast<Type>(p.
x);
107 y /=
static_cast<Type>(p.
y);
118 template <
class U,
class = std::enable_if_t<std::is_arithmetic_v<U>>>
120 x /=
static_cast<Type>(scale);
121 y /=
static_cast<Type>(scale);
128 return {
x + p.
x,
y + p.
y};
137 return {
x - p.
x,
y - p.
y};
145 template <
class U,
class = std::enable_if_t<std::is_arithmetic_v<U>>>
147 return {
static_cast<Type>(
x * scale),
static_cast<Type>(
y * scale)};
151 return {
x * p.
x,
y * p.
y};
159 template <
class U,
class = std::enable_if_t<std::is_arithmetic_v<U>>>
161 return {
static_cast<Type>(
x / d),
static_cast<Type>(
y / d)};
165 return {
x / p.
x,
y / p.
y};
176 return dx * dx + dy * dy;
180 return {std::min<Type>(
x, p.
x), std::min<Type>(
y, p.
y)};
184 return {std::max<Type>(
x, p.
x), std::max<Type>(
y, p.
y)};
206 return {
x / length,
y / length};
209 constexpr
TPoint Abs()
const {
return {std::fabs(
x), std::fabs(
y)}; }
216 return *
this - axis * this->
Dot(axis) * 2;
224 return *
this + (p - *
this) * t;
227 constexpr
bool IsZero()
const {
return x == 0 &&
y == 0; }
232 template <
class F,
class I,
class = MixedOp<F, I>>
234 return {p1.
x +
static_cast<F
>(p2.
x), p1.
y +
static_cast<F
>(p2.
y)};
237 template <
class F,
class I,
class = MixedOp<F, I>>
242 template <
class F,
class I,
class = MixedOp<F, I>>
244 return {p1.
x -
static_cast<F
>(p2.
x), p1.
y -
static_cast<F
>(p2.
y)};
247 template <
class F,
class I,
class = MixedOp<F, I>>
249 return {
static_cast<F
>(p1.
x) - p2.
x,
static_cast<F
>(p1.
y) - p2.
y};
252 template <
class F,
class I,
class = MixedOp<F, I>>
254 return {p1.
x *
static_cast<F
>(p2.
x), p1.
y *
static_cast<F
>(p2.
y)};
257 template <
class F,
class I,
class = MixedOp<F, I>>
262 template <
class F,
class I,
class = MixedOp<F, I>>
264 return {p1.
x /
static_cast<F
>(p2.
x), p1.
y /
static_cast<F
>(p2.
y)};
267 template <
class F,
class I,
class = MixedOp<F, I>>
269 return {
static_cast<F
>(p1.
x) / p2.
x,
static_cast<F
>(p1.
y) / p2.
y};
274 template <
class T,
class U,
class = std::enable_if_t<std::is_arithmetic_v<U>>>
279 template <
class T,
class U,
class = std::enable_if_t<std::is_arithmetic_v<U>>>
281 return {
static_cast<T
>(s) / p.
x,
static_cast<T
>(s) / p.
y};
286 template <
class T,
class U>
291 template <
class T,
class U>
293 return {
static_cast<T
>(s.
width) - p.
x,
static_cast<T
>(s.
height) - p.
y};
296 template <
class T,
class U>
301 template <
class T,
class U>
303 return {
static_cast<T
>(s.
width) / p.
x,
static_cast<T
>(s.
height) / p.
y};
319 out <<
"(" << p.
x <<
", " << p.
y <<
")";
TPoint operator-=(const TSize< U > &s)
constexpr TPoint Ceil() const
constexpr TPoint(Type x, Type y)
TPoint operator+=(const TSize< U > &s)
constexpr TPoint Lerp(const TPoint &p, Scalar t) const
TPoint operator*=(U scale)
constexpr TPoint Min(const TPoint &p) const
static constexpr TPoint Round(const TPoint< U > &other)
constexpr TPoint operator*(const TSize< U > &s) const
constexpr TPoint()=default
TPoint operator/=(const TPoint< U > &p)
std::ostream & operator<<(std::ostream &out, const impeller::Color &c)
TPoint operator*=(const TPoint< U > &p)
constexpr Color operator*(T value, const Color &c)
TPoint operator/=(const TSize< U > &s)
constexpr TPoint Floor() const
constexpr Type Dot(const TPoint &p) const
constexpr TPoint operator/(U d) const
constexpr TPoint Round() const
constexpr bool IsZero() const
constexpr TPoint operator-() const
constexpr TPoint Reflect(const TPoint &axis) const
constexpr TPoint operator-(const TPoint &p) const
constexpr Radians AngleTo(const TPoint &p) const
constexpr TPoint Max(const TPoint &p) const
constexpr TPoint operator/(const TSize< U > &s) const
constexpr TPoint(const TPoint< U > &other)
TPoint operator/=(U scale)
constexpr Type Cross(const TPoint &p) const
constexpr Color operator-(T value, const Color &c)
constexpr bool operator==(const TPoint &p) const
constexpr TPoint operator+(const TPoint &p) const
constexpr TPoint Abs() const
constexpr TPoint operator*(const TPoint &p) const
constexpr Type GetLengthSquared() const
constexpr TPoint operator/(const TPoint &p) const
constexpr Type GetLength() const
constexpr TPoint operator*(U scale) const
constexpr bool operator!=(const TPoint &p) const
constexpr Color operator/(T value, const Color &c)
constexpr Type GetDistance(const TPoint &p) const
constexpr TPoint Normalize() const
TPoint operator+=(const TPoint< U > &p)
constexpr TPoint(const TSize< U > &other)
TPoint operator-=(const TPoint< U > &p)
constexpr Type GetDistanceSquared(const TPoint &p) const
constexpr TPoint operator+(const TSize< U > &s) const
static constexpr TPoint< Type > MakeXY(Type x, Type y)
constexpr TPoint operator-(const TSize< U > &s) const
constexpr Color operator+(T value, const Color &c)
TPoint operator*=(const TSize< U > &s)