Flutter Impeller
impeller::TPoint< T > Struct Template Reference

#include <point.h>

Public Types

using Type = T
 

Public Member Functions

constexpr TPoint ()=default
 
template<class U >
constexpr TPoint (const TPoint< U > &other)
 
template<class U >
constexpr TPoint (const TSize< U > &other)
 
constexpr TPoint (Type x, Type y)
 
constexpr bool operator== (const TPoint &p) const
 
constexpr bool operator!= (const TPoint &p) const
 
template<class U >
TPoint operator+= (const TPoint< U > &p)
 
template<class U >
TPoint operator+= (const TSize< U > &s)
 
template<class U >
TPoint operator-= (const TPoint< U > &p)
 
template<class U >
TPoint operator-= (const TSize< U > &s)
 
template<class U >
TPoint operator*= (const TPoint< U > &p)
 
template<class U >
TPoint operator*= (const TSize< U > &s)
 
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
TPoint operator*= (U scale)
 
template<class U >
TPoint operator/= (const TPoint< U > &p)
 
template<class U >
TPoint operator/= (const TSize< U > &s)
 
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
TPoint operator/= (U scale)
 
constexpr TPoint operator- () const
 
constexpr TPoint operator+ (const TPoint &p) const
 
template<class U >
constexpr TPoint operator+ (const TSize< U > &s) const
 
constexpr TPoint operator- (const TPoint &p) const
 
template<class U >
constexpr TPoint operator- (const TSize< U > &s) const
 
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
constexpr TPoint operator* (U scale) const
 
constexpr TPoint operator* (const TPoint &p) const
 
template<class U >
constexpr TPoint operator* (const TSize< U > &s) const
 
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
constexpr TPoint operator/ (U d) const
 
constexpr TPoint operator/ (const TPoint &p) const
 
template<class U >
constexpr TPoint operator/ (const TSize< U > &s) const
 
constexpr Type GetDistanceSquared (const TPoint &p) const
 
constexpr TPoint Min (const TPoint &p) const
 
constexpr TPoint Max (const TPoint &p) const
 
constexpr TPoint Floor () const
 
constexpr TPoint Ceil () const
 
constexpr TPoint Round () const
 
constexpr Type GetDistance (const TPoint &p) const
 
constexpr Type GetLengthSquared () const
 
constexpr Type GetLength () const
 
constexpr TPoint Normalize () const
 
constexpr TPoint Abs () const
 
constexpr Type Cross (const TPoint &p) const
 
constexpr Type Dot (const TPoint &p) const
 
constexpr TPoint Reflect (const TPoint &axis) const
 
constexpr Radians AngleTo (const TPoint &p) const
 
constexpr TPoint Lerp (const TPoint &p, Scalar t) const
 
constexpr bool IsZero () const
 

Static Public Member Functions

static constexpr TPoint< TypeMakeXY (Type x, Type y)
 
template<class U >
static constexpr TPoint Round (const TPoint< U > &other)
 

Public Attributes

Type x = {}
 
Type y = {}
 

Detailed Description

template<class T>
struct impeller::TPoint< T >

Definition at line 22 of file point.h.

Member Typedef Documentation

◆ Type

template<class T >
using impeller::TPoint< T >::Type = T

Definition at line 23 of file point.h.

Constructor & Destructor Documentation

◆ TPoint() [1/4]

template<class T >
constexpr impeller::TPoint< T >::TPoint ( )
constexprdefault

◆ TPoint() [2/4]

template<class T >
template<class U >
constexpr impeller::TPoint< T >::TPoint ( const TPoint< U > &  other)
inlineexplicitconstexpr

Definition at line 31 of file point.h.

32  : TPoint(static_cast<Type>(other.x), static_cast<Type>(other.y)) {}

◆ TPoint() [3/4]

template<class T >
template<class U >
constexpr impeller::TPoint< T >::TPoint ( const TSize< U > &  other)
inlineexplicitconstexpr

Definition at line 35 of file point.h.

36  : TPoint(static_cast<Type>(other.width),
37  static_cast<Type>(other.height)) {}

◆ TPoint() [4/4]

template<class T >
constexpr impeller::TPoint< T >::TPoint ( Type  x,
Type  y 
)
inlineconstexpr

Definition at line 39 of file point.h.

39 : x(x), y(y) {}

Member Function Documentation

◆ Abs()

template<class T >
constexpr TPoint impeller::TPoint< T >::Abs ( ) const
inlineconstexpr

Definition at line 211 of file point.h.

211 { return {std::fabs(x), std::fabs(y)}; }

Referenced by impeller::testing::TEST().

◆ AngleTo()

template<class T >
constexpr Radians impeller::TPoint< T >::AngleTo ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 221 of file point.h.

221  {
222  return Radians{std::atan2(this->Cross(p), this->Dot(p))};
223  }

Referenced by impeller::testing::TEST().

◆ Ceil()

template<class T >
constexpr TPoint impeller::TPoint< T >::Ceil ( ) const
inlineconstexpr

Definition at line 191 of file point.h.

191 { return {std::ceil(x), std::ceil(y)}; }

Referenced by impeller::testing::TEST().

◆ Cross()

template<class T >
constexpr Type impeller::TPoint< T >::Cross ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 213 of file point.h.

213 { return (x * p.y) - (y * p.x); }

Referenced by impeller::TPoint< Type >::AngleTo(), and impeller::testing::TEST().

◆ Dot()

template<class T >
constexpr Type impeller::TPoint< T >::Dot ( const TPoint< T > &  p) const
inlineconstexpr

◆ Floor()

template<class T >
constexpr TPoint impeller::TPoint< T >::Floor ( ) const
inlineconstexpr

Definition at line 189 of file point.h.

189 { return {std::floor(x), std::floor(y)}; }

Referenced by impeller::testing::TEST().

◆ GetDistance()

template<class T >
constexpr Type impeller::TPoint< T >::GetDistance ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 195 of file point.h.

195  {
196  return sqrt(GetDistanceSquared(p));
197  }

Referenced by impeller::TPoint< Type >::GetLength(), and impeller::testing::TEST_P().

◆ GetDistanceSquared()

template<class T >
constexpr Type impeller::TPoint< T >::GetDistanceSquared ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 175 of file point.h.

175  {
176  double dx = p.x - x;
177  double dy = p.y - y;
178  return dx * dx + dy * dy;
179  }

Referenced by impeller::TPoint< Type >::GetDistance(), and impeller::TPoint< Type >::GetLengthSquared().

◆ GetLength()

template<class T >
constexpr Type impeller::TPoint< T >::GetLength ( ) const
inlineconstexpr

◆ GetLengthSquared()

template<class T >
constexpr Type impeller::TPoint< T >::GetLengthSquared ( ) const
inlineconstexpr

Definition at line 199 of file point.h.

199 { return GetDistanceSquared({}); }

◆ IsZero()

template<class T >
constexpr bool impeller::TPoint< T >::IsZero ( ) const
inlineconstexpr

◆ Lerp()

template<class T >
constexpr TPoint impeller::TPoint< T >::Lerp ( const TPoint< T > &  p,
Scalar  t 
) const
inlineconstexpr

Definition at line 225 of file point.h.

225  {
226  return *this + (p - *this) * t;
227  }

Referenced by impeller::testing::TEST().

◆ MakeXY()

template<class T >
static constexpr TPoint<Type> impeller::TPoint< T >::MakeXY ( Type  x,
Type  y 
)
inlinestaticconstexpr

Definition at line 41 of file point.h.

41 { return {x, y}; }

◆ Max()

template<class T >
constexpr TPoint impeller::TPoint< T >::Max ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 185 of file point.h.

185  {
186  return {std::max<Type>(x, p.x), std::max<Type>(y, p.y)};
187  }

Referenced by impeller::testing::TEST().

◆ Min()

template<class T >
constexpr TPoint impeller::TPoint< T >::Min ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 181 of file point.h.

181  {
182  return {std::min<Type>(x, p.x), std::min<Type>(y, p.y)};
183  }

Referenced by impeller::testing::TEST().

◆ Normalize()

template<class T >
constexpr TPoint impeller::TPoint< T >::Normalize ( ) const
inlineconstexpr

Definition at line 203 of file point.h.

203  {
204  const auto length = GetLength();
205  if (length == 0) {
206  return {1, 0};
207  }
208  return {x / length, y / length};
209  }

Referenced by impeller::DirectionalMorphologyFilterContents::SetDirection(), impeller::DirectionalGaussianBlurFilterContents::SetDirection(), impeller::testing::TEST(), and impeller::testing::TEST_P().

◆ operator!=()

template<class T >
constexpr bool impeller::TPoint< T >::operator!= ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 53 of file point.h.

53  {
54  return p.x != x || p.y != y;
55  }

◆ operator*() [1/3]

template<class T >
constexpr TPoint impeller::TPoint< T >::operator* ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 152 of file point.h.

152  {
153  return {x * p.x, y * p.y};
154  }

◆ operator*() [2/3]

template<class T >
template<class U >
constexpr TPoint impeller::TPoint< T >::operator* ( const TSize< U > &  s) const
inlineconstexpr

Definition at line 157 of file point.h.

157  {
158  return {x * static_cast<Type>(s.width), y * static_cast<Type>(s.height)};
159  }

◆ operator*() [3/3]

template<class T >
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
constexpr TPoint impeller::TPoint< T >::operator* ( scale) const
inlineconstexpr

Definition at line 148 of file point.h.

148  {
149  return {static_cast<Type>(x * scale), static_cast<Type>(y * scale)};
150  }

◆ operator*=() [1/3]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator*= ( const TPoint< U > &  p)
inline

Definition at line 86 of file point.h.

86  {
87  x *= static_cast<Type>(p.x);
88  y *= static_cast<Type>(p.y);
89  return *this;
90  }

◆ operator*=() [2/3]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator*= ( const TSize< U > &  s)
inline

Definition at line 93 of file point.h.

93  {
94  x *= static_cast<Type>(s.width);
95  y *= static_cast<Type>(s.height);
96  return *this;
97  }

◆ operator*=() [3/3]

template<class T >
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
TPoint impeller::TPoint< T >::operator*= ( scale)
inline

Definition at line 100 of file point.h.

100  {
101  x *= static_cast<Type>(scale);
102  y *= static_cast<Type>(scale);
103  return *this;
104  }

◆ operator+() [1/2]

template<class T >
constexpr TPoint impeller::TPoint< T >::operator+ ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 129 of file point.h.

129  {
130  return {x + p.x, y + p.y};
131  }

◆ operator+() [2/2]

template<class T >
template<class U >
constexpr TPoint impeller::TPoint< T >::operator+ ( const TSize< U > &  s) const
inlineconstexpr

Definition at line 134 of file point.h.

134  {
135  return {x + static_cast<Type>(s.width), y + static_cast<Type>(s.height)};
136  }

◆ operator+=() [1/2]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator+= ( const TPoint< U > &  p)
inline

Definition at line 58 of file point.h.

58  {
59  x += static_cast<Type>(p.x);
60  y += static_cast<Type>(p.y);
61  return *this;
62  }

◆ operator+=() [2/2]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator+= ( const TSize< U > &  s)
inline

Definition at line 65 of file point.h.

65  {
66  x += static_cast<Type>(s.width);
67  y += static_cast<Type>(s.height);
68  return *this;
69  }

◆ operator-() [1/3]

template<class T >
constexpr TPoint impeller::TPoint< T >::operator- ( ) const
inlineconstexpr

Definition at line 127 of file point.h.

127 { return {-x, -y}; }

◆ operator-() [2/3]

template<class T >
constexpr TPoint impeller::TPoint< T >::operator- ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 138 of file point.h.

138  {
139  return {x - p.x, y - p.y};
140  }

◆ operator-() [3/3]

template<class T >
template<class U >
constexpr TPoint impeller::TPoint< T >::operator- ( const TSize< U > &  s) const
inlineconstexpr

Definition at line 143 of file point.h.

143  {
144  return {x - static_cast<Type>(s.width), y - static_cast<Type>(s.height)};
145  }

◆ operator-=() [1/2]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator-= ( const TPoint< U > &  p)
inline

Definition at line 72 of file point.h.

72  {
73  x -= static_cast<Type>(p.x);
74  y -= static_cast<Type>(p.y);
75  return *this;
76  }

◆ operator-=() [2/2]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator-= ( const TSize< U > &  s)
inline

Definition at line 79 of file point.h.

79  {
80  x -= static_cast<Type>(s.width);
81  y -= static_cast<Type>(s.height);
82  return *this;
83  }

◆ operator/() [1/3]

template<class T >
constexpr TPoint impeller::TPoint< T >::operator/ ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 166 of file point.h.

166  {
167  return {x / p.x, y / p.y};
168  }

◆ operator/() [2/3]

template<class T >
template<class U >
constexpr TPoint impeller::TPoint< T >::operator/ ( const TSize< U > &  s) const
inlineconstexpr

Definition at line 171 of file point.h.

171  {
172  return {x / static_cast<Type>(s.width), y / static_cast<Type>(s.height)};
173  }

◆ operator/() [3/3]

template<class T >
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
constexpr TPoint impeller::TPoint< T >::operator/ ( d) const
inlineconstexpr

Definition at line 162 of file point.h.

162  {
163  return {static_cast<Type>(x / d), static_cast<Type>(y / d)};
164  }

◆ operator/=() [1/3]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator/= ( const TPoint< U > &  p)
inline

Definition at line 107 of file point.h.

107  {
108  x /= static_cast<Type>(p.x);
109  y /= static_cast<Type>(p.y);
110  return *this;
111  }

◆ operator/=() [2/3]

template<class T >
template<class U >
TPoint impeller::TPoint< T >::operator/= ( const TSize< U > &  s)
inline

Definition at line 114 of file point.h.

114  {
115  x /= static_cast<Type>(s.width);
116  y /= static_cast<Type>(s.height);
117  return *this;
118  }

◆ operator/=() [3/3]

template<class T >
template<class U , class = std::enable_if_t<std::is_arithmetic_v<U>>>
TPoint impeller::TPoint< T >::operator/= ( scale)
inline

Definition at line 121 of file point.h.

121  {
122  x /= static_cast<Type>(scale);
123  y /= static_cast<Type>(scale);
124  return *this;
125  }

◆ operator==()

template<class T >
constexpr bool impeller::TPoint< T >::operator== ( const TPoint< T > &  p) const
inlineconstexpr

Definition at line 49 of file point.h.

49  {
50  return p.x == x && p.y == y;
51  }

◆ Reflect()

template<class T >
constexpr TPoint impeller::TPoint< T >::Reflect ( const TPoint< T > &  axis) const
inlineconstexpr

Definition at line 217 of file point.h.

217  {
218  return *this - axis * this->Dot(axis) * 2;
219  }

Referenced by impeller::testing::TEST().

◆ Round() [1/2]

template<class T >
constexpr TPoint impeller::TPoint< T >::Round ( ) const
inlineconstexpr

Definition at line 193 of file point.h.

193 { return {std::round(x), std::round(y)}; }

◆ Round() [2/2]

template<class T >
template<class U >
static constexpr TPoint impeller::TPoint< T >::Round ( const TPoint< U > &  other)
inlinestaticconstexpr

Definition at line 44 of file point.h.

44  {
45  return TPoint{static_cast<Type>(std::round(other.x)),
46  static_cast<Type>(std::round(other.y))};
47  }

Referenced by impeller::testing::TEST().

Member Data Documentation

◆ x

template<class T >
Type impeller::TPoint< T >::x = {}

Definition at line 25 of file point.h.

Referenced by impeller::TPoint< Type >::Abs(), impeller::PathBuilder::AddArc(), impeller::PathBuilder::AddCircle(), impeller::PathBuilder::AddOval(), impeller::PathBuilder::AddRoundedRect(), impeller::TPoint< Type >::Ceil(), impeller::TRect< Scalar >::Contains(), impeller::TPoint< Type >::Cross(), impeller::TPoint< Type >::Dot(), impeller::BlitCopyTextureToTextureCommandGLES::Encode(), impeller::BlitCopyTextureToTextureCommandMTL::Encode(), impeller::BlitCopyTextureToTextureCommandVK::Encode(), impeller::BlitCopyBufferToTextureCommandVK::Encode(), impeller::BlitCopyBufferToTextureCommandMTL::Encode(), impeller::TRect< Scalar >::Expand(), impeller::CubicPathComponent::Extrema(), impeller::TPoint< Type >::Floor(), impeller::TRect< Scalar >::GetCenter(), impeller::PlaygroundImpl::GetContentScale(), impeller::TPoint< Type >::GetDistanceSquared(), impeller::GaussianBlurFilterContents::GetFilterCoverage(), impeller::GaussianBlurFilterContents::GetFilterSourceCoverage(), impeller::TRect< Scalar >::GetLeft(), impeller::TRect< Scalar >::GetNormalizingTransform(), impeller::BitmapSTB::GetPixelAddress(), impeller::TRect< Scalar >::GetRight(), impeller::TRect< Scalar >::GetX(), impeller::TRect< Scalar >::GetXYWH(), impeller::PathBuilder::HorizontalLineTo(), impeller::LineGeometry::IsAxisAlignedRect(), impeller::TPoint< Type >::IsZero(), impeller::Matrix::MakeScale(), impeller::testing::MetalScreenshotter::MakeScreenshot(), impeller::MakeTextFrameFromTextBlobSkia(), impeller::TPoint< Type >::MakeXY(), impeller::TPoint< Type >::Max(), impeller::TPoint< Type >::Min(), impeller::TPoint< Type >::Normalize(), impeller::TPoint< Type >::operator!=(), impeller::TRect< Scalar >::operator*(), impeller::TPoint< Type >::operator*(), impeller::operator*(), impeller::Matrix::operator*(), impeller::TPoint< Type >::operator*=(), impeller::TRect< Scalar >::operator+(), impeller::TPoint< Type >::operator+(), impeller::operator+(), impeller::TPoint< Type >::operator+=(), impeller::TRect< Scalar >::operator-(), impeller::TPoint< Type >::operator-(), impeller::operator-(), impeller::TPoint< Type >::operator-=(), impeller::TPoint< Type >::operator/(), impeller::operator/(), impeller::TPoint< Type >::operator/=(), std::operator<<(), impeller::TPoint< Type >::operator==(), PointNear(), impeller::TPoint< Type >::Round(), impeller::TRect< Scalar >::Scale(), impeller::TRect< Scalar >::Shift(), impeller::LinearPathComponent::Solve(), impeller::QuadraticPathComponent::Solve(), impeller::CubicPathComponent::Solve(), impeller::QuadraticPathComponent::SolveDerivative(), impeller::CubicPathComponent::SolveDerivative(), impeller::testing::TEST(), impeller::testing::TEST_P(), impeller::scene::importer::ToFBVec2(), impeller::skia_conversions::ToPath(), impeller::Matrix::TransformDirection(), and impeller::PathBuilder::VerticalLineTo().

◆ y

template<class T >
Type impeller::TPoint< T >::y = {}

Definition at line 26 of file point.h.

Referenced by impeller::TPoint< Type >::Abs(), impeller::PathBuilder::AddArc(), impeller::PathBuilder::AddCircle(), impeller::PathBuilder::AddOval(), impeller::PathBuilder::AddRoundedRect(), impeller::TPoint< Type >::Ceil(), impeller::TRect< Scalar >::Contains(), impeller::TPoint< Type >::Cross(), impeller::TPoint< Type >::Dot(), impeller::BlitCopyTextureToTextureCommandGLES::Encode(), impeller::BlitCopyTextureToTextureCommandMTL::Encode(), impeller::BlitCopyTextureToTextureCommandVK::Encode(), impeller::BlitCopyBufferToTextureCommandVK::Encode(), impeller::BlitCopyBufferToTextureCommandMTL::Encode(), impeller::TRect< Scalar >::Expand(), impeller::CubicPathComponent::Extrema(), impeller::TPoint< Type >::Floor(), impeller::TRect< Scalar >::GetBottom(), impeller::TRect< Scalar >::GetCenter(), impeller::PlaygroundImpl::GetContentScale(), impeller::TPoint< Type >::GetDistanceSquared(), impeller::GaussianBlurFilterContents::GetFilterCoverage(), impeller::GaussianBlurFilterContents::GetFilterSourceCoverage(), impeller::TRect< Scalar >::GetNormalizingTransform(), impeller::BitmapSTB::GetPixelAddress(), impeller::TRect< Scalar >::GetTop(), impeller::TRect< Scalar >::GetXYWH(), impeller::TRect< Scalar >::GetY(), impeller::PathBuilder::HorizontalLineTo(), impeller::LineGeometry::IsAxisAlignedRect(), impeller::TPoint< Type >::IsZero(), impeller::Matrix::MakeScale(), impeller::testing::MetalScreenshotter::MakeScreenshot(), impeller::TPoint< Type >::MakeXY(), impeller::TPoint< Type >::Max(), impeller::TPoint< Type >::Min(), impeller::TPoint< Type >::Normalize(), impeller::TPoint< Type >::operator!=(), impeller::TRect< Scalar >::operator*(), impeller::TPoint< Type >::operator*(), impeller::operator*(), impeller::Matrix::operator*(), impeller::TPoint< Type >::operator*=(), impeller::TRect< Scalar >::operator+(), impeller::TPoint< Type >::operator+(), impeller::operator+(), impeller::TPoint< Type >::operator+=(), impeller::TRect< Scalar >::operator-(), impeller::TPoint< Type >::operator-(), impeller::operator-(), impeller::TPoint< Type >::operator-=(), impeller::TPoint< Type >::operator/(), impeller::operator/(), impeller::TPoint< Type >::operator/=(), std::operator<<(), impeller::TPoint< Type >::operator==(), PointNear(), impeller::TPoint< Type >::Round(), impeller::TRect< Scalar >::Scale(), impeller::TRect< Scalar >::Shift(), impeller::LinearPathComponent::Solve(), impeller::QuadraticPathComponent::Solve(), impeller::CubicPathComponent::Solve(), impeller::QuadraticPathComponent::SolveDerivative(), impeller::CubicPathComponent::SolveDerivative(), impeller::testing::TEST(), impeller::testing::TEST_P(), impeller::scene::importer::ToFBVec2(), impeller::skia_conversions::ToPath(), impeller::Matrix::TransformDirection(), and impeller::PathBuilder::VerticalLineTo().


The documentation for this struct was generated from the following file:
impeller::TPoint::y
Type y
Definition: point.h:26
impeller::TPoint::TPoint
constexpr TPoint()=default
impeller::TPoint::Dot
constexpr Type Dot(const TPoint &p) const
Definition: point.h:215
impeller::TPoint::Cross
constexpr Type Cross(const TPoint &p) const
Definition: point.h:213
impeller::TPoint::x
Type x
Definition: point.h:25
impeller::TPoint::GetLength
constexpr Type GetLength() const
Definition: point.h:201
impeller::TPoint::GetDistance
constexpr Type GetDistance(const TPoint &p) const
Definition: point.h:195
impeller::TPoint::Type
T Type
Definition: point.h:23
impeller::TPoint::GetDistanceSquared
constexpr Type GetDistanceSquared(const TPoint &p) const
Definition: point.h:175