Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
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
 
 IsFinite () 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 27 of file point.h.

Member Typedef Documentation

◆ Type

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

Definition at line 28 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 36 of file point.h.

37 : TPoint(static_cast<Type>(other.x), static_cast<Type>(other.y)) {}
constexpr TPoint()=default

◆ TPoint() [3/4]

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

Definition at line 40 of file point.h.

41 : TPoint(static_cast<Type>(other.width),
42 static_cast<Type>(other.height)) {}

◆ TPoint() [4/4]

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

Definition at line 44 of file point.h.

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

Member Function Documentation

◆ Abs()

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

Definition at line 216 of file point.h.

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

◆ AngleTo()

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

Definition at line 226 of file point.h.

226 {
227 return Radians{std::atan2(this->Cross(p), this->Dot(p))};
228 }
constexpr Type Cross(const TPoint &p) const
Definition point.h:218
constexpr Type Dot(const TPoint &p) const
Definition point.h:220

◆ Ceil()

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

Definition at line 196 of file point.h.

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

◆ Cross()

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

Definition at line 218 of file point.h.

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

◆ Dot()

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

Definition at line 220 of file point.h.

220{ return (x * p.x) + (y * p.y); }

◆ Floor()

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

Definition at line 194 of file point.h.

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

◆ GetDistance()

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

Definition at line 200 of file point.h.

200 {
201 return sqrt(GetDistanceSquared(p));
202 }
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition SkVx.h:706
constexpr Type GetDistanceSquared(const TPoint &p) const
Definition point.h:180

◆ GetDistanceSquared()

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

Definition at line 180 of file point.h.

180 {
181 double dx = p.x - x;
182 double dy = p.y - y;
183 return dx * dx + dy * dy;
184 }
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition SkRecords.h:208

◆ GetLength()

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

Definition at line 206 of file point.h.

206{ return GetDistance({}); }
constexpr Type GetDistance(const TPoint &p) const
Definition point.h:200

◆ GetLengthSquared()

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

Definition at line 204 of file point.h.

204{ return GetDistanceSquared({}); }

◆ IsFinite()

template<class T >
impeller::TPoint< T >::IsFinite ( ) const
inline

Definition at line 237 of file point.h.

237{ return std::isfinite(x) && std::isfinite(y); }

◆ IsZero()

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

Definition at line 234 of file point.h.

234{ return x == 0 && y == 0; }

◆ Lerp()

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

Definition at line 230 of file point.h.

230 {
231 return *this + (p - *this) * t;
232 }

◆ MakeXY()

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

Definition at line 46 of file point.h.

46{ return {x, y}; }

◆ Max()

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

Definition at line 190 of file point.h.

190 {
191 return {std::max<Type>(x, p.x), std::max<Type>(y, p.y)};
192 }

◆ Min()

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

Definition at line 186 of file point.h.

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

◆ Normalize()

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

Definition at line 208 of file point.h.

208 {
209 const auto length = GetLength();
210 if (length == 0) {
211 return {1, 0};
212 }
213 return {x / length, y / length};
214 }
size_t length
constexpr Type GetLength() const
Definition point.h:206

◆ operator!=()

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

Definition at line 58 of file point.h.

58 {
59 return p.x != x || p.y != y;
60 }

◆ operator*() [1/3]

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

Definition at line 157 of file point.h.

157 {
158 return {x * p.x, y * p.y};
159 }

◆ operator*() [2/3]

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

Definition at line 162 of file point.h.

162 {
163 return {x * static_cast<Type>(s.width), y * static_cast<Type>(s.height)};
164 }
struct MyStruct s

◆ 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 153 of file point.h.

153 {
154 return {static_cast<Type>(x * scale), static_cast<Type>(y * scale)};
155 }
const Scalar scale

◆ operator*=() [1/3]

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

Definition at line 91 of file point.h.

91 {
92 x *= static_cast<Type>(p.x);
93 y *= static_cast<Type>(p.y);
94 return *this;
95 }

◆ operator*=() [2/3]

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

Definition at line 98 of file point.h.

98 {
99 x *= static_cast<Type>(s.width);
100 y *= static_cast<Type>(s.height);
101 return *this;
102 }

◆ 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 105 of file point.h.

105 {
106 x *= static_cast<Type>(scale);
107 y *= static_cast<Type>(scale);
108 return *this;
109 }

◆ operator+() [1/2]

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

Definition at line 134 of file point.h.

134 {
135 return {x + p.x, y + p.y};
136 }

◆ operator+() [2/2]

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

Definition at line 139 of file point.h.

139 {
140 return {x + static_cast<Type>(s.width), y + static_cast<Type>(s.height)};
141 }

◆ operator+=() [1/2]

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

Definition at line 63 of file point.h.

63 {
64 x += static_cast<Type>(p.x);
65 y += static_cast<Type>(p.y);
66 return *this;
67 }

◆ operator+=() [2/2]

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

Definition at line 70 of file point.h.

70 {
71 x += static_cast<Type>(s.width);
72 y += static_cast<Type>(s.height);
73 return *this;
74 }

◆ operator-() [1/3]

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

Definition at line 132 of file point.h.

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

◆ operator-() [2/3]

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

Definition at line 143 of file point.h.

143 {
144 return {x - p.x, y - p.y};
145 }

◆ operator-() [3/3]

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

Definition at line 148 of file point.h.

148 {
149 return {x - static_cast<Type>(s.width), y - static_cast<Type>(s.height)};
150 }

◆ operator-=() [1/2]

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

Definition at line 77 of file point.h.

77 {
78 x -= static_cast<Type>(p.x);
79 y -= static_cast<Type>(p.y);
80 return *this;
81 }

◆ operator-=() [2/2]

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

Definition at line 84 of file point.h.

84 {
85 x -= static_cast<Type>(s.width);
86 y -= static_cast<Type>(s.height);
87 return *this;
88 }

◆ operator/() [1/3]

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

Definition at line 171 of file point.h.

171 {
172 return {x / p.x, y / p.y};
173 }

◆ operator/() [2/3]

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

Definition at line 176 of file point.h.

176 {
177 return {x / static_cast<Type>(s.width), y / static_cast<Type>(s.height)};
178 }

◆ 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 167 of file point.h.

167 {
168 return {static_cast<Type>(x / d), static_cast<Type>(y / d)};
169 }
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition main.cc:19

◆ operator/=() [1/3]

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

Definition at line 112 of file point.h.

112 {
113 x /= static_cast<Type>(p.x);
114 y /= static_cast<Type>(p.y);
115 return *this;
116 }

◆ operator/=() [2/3]

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

Definition at line 119 of file point.h.

119 {
120 x /= static_cast<Type>(s.width);
121 y /= static_cast<Type>(s.height);
122 return *this;
123 }

◆ 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 126 of file point.h.

126 {
127 x /= static_cast<Type>(scale);
128 y /= static_cast<Type>(scale);
129 return *this;
130 }

◆ operator==()

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

Definition at line 54 of file point.h.

54 {
55 return p.x == x && p.y == y;
56 }

◆ Reflect()

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

Definition at line 222 of file point.h.

222 {
223 return *this - axis * this->Dot(axis) * 2;
224 }

◆ Round() [1/2]

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

Definition at line 198 of file point.h.

198{ 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 49 of file point.h.

49 {
50 return TPoint{static_cast<Type>(std::round(other.x)),
51 static_cast<Type>(std::round(other.y))};
52 }

Member Data Documentation

◆ x

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

Definition at line 30 of file point.h.

30{};

◆ y

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

Definition at line 31 of file point.h.

31{};

The documentation for this struct was generated from the following file: