#include <SkPoint_impl.h>
|
static constexpr SkPoint | Make (float x, float y) |
|
static void | Offset (SkPoint points[], int count, const SkVector &offset) |
|
static void | Offset (SkPoint points[], int count, float dx, float dy) |
|
static float | Length (float x, float y) |
|
static float | Normalize (SkVector *vec) |
|
static float | Distance (const SkPoint &a, const SkPoint &b) |
|
static float | DotProduct (const SkVector &a, const SkVector &b) |
|
static float | CrossProduct (const SkVector &a, const SkVector &b) |
|
SkPoint holds two 32-bit floating point coordinates.
Definition at line 163 of file SkPoint_impl.h.
◆ cross()
float SkPoint::cross |
( |
const SkVector & |
vec | ) |
const |
|
inline |
Returns the cross product of vector and vec.
Vector and vec form three-dimensional vectors with z-axis value equal to zero. The cross product is a three-dimensional vector with x-axis and y-axis values equal to zero. The cross product z-axis component is returned.
- Parameters
-
vec | right side of cross product |
- Returns
- area spanned by vectors signed by angle direction
Definition at line 545 of file SkPoint_impl.h.
545 {
547 }
static float CrossProduct(const SkVector &a, const SkVector &b)
◆ CrossProduct()
Returns the cross product of vector a and vector b.
a and b form three-dimensional vectors with z-axis value equal to zero. The cross product is a three-dimensional vector with x-axis and y-axis values equal to zero. The cross product z-axis component is returned.
- Parameters
-
a | left side of cross product |
b | right side of cross product |
- Returns
- area spanned by vectors signed by angle direction
Definition at line 532 of file SkPoint_impl.h.
532 {
533 return a.fX *
b.fY -
a.fY *
b.fX;
534 }
◆ Distance()
static float SkPoint::Distance |
( |
const SkPoint & |
a, |
|
|
const SkPoint & |
b |
|
) |
| |
|
inlinestatic |
Returns the Euclidean distance between a and b.
- Parameters
-
a | line end point |
b | line end point |
- Returns
- straight-line distance from a to b
Definition at line 508 of file SkPoint_impl.h.
508 {
510 }
static float Length(float x, float y)
◆ distanceToOrigin()
float SkPoint::distanceToOrigin |
( |
| ) |
const |
|
inline |
Returns the Euclidean distance from origin, computed as:
sqrt(fX * fX + fY * fY)
- Returns
- straight-line distance to origin
Definition at line 292 of file SkPoint_impl.h.
◆ dot()
float SkPoint::dot |
( |
const SkVector & |
vec | ) |
const |
|
inline |
Returns the dot product of vector and vector vec.
- Parameters
-
vec | right side of dot product |
- Returns
- product of input magnitudes and cosine of the angle between them
Definition at line 554 of file SkPoint_impl.h.
554 {
556 }
static float DotProduct(const SkVector &a, const SkVector &b)
◆ DotProduct()
Returns the dot product of vector a and vector b.
- Parameters
-
a | left side of dot product |
b | right side of dot product |
- Returns
- product of input magnitudes and cosine of the angle between them
Definition at line 518 of file SkPoint_impl.h.
518 {
519 return a.fX *
b.fX +
a.fY *
b.fY;
520 }
◆ equals()
bool SkPoint::equals |
( |
float |
x, |
|
|
float |
y |
|
) |
| const |
|
inline |
Returns true if SkPoint is equivalent to SkPoint constructed from (x, y).
- Parameters
-
x | value compared with fX |
y | value compared with fY |
- Returns
- true if SkPoint equals (x, y)
Definition at line 422 of file SkPoint_impl.h.
422 {
423 return fX ==
x &&
fY ==
y;
424 }
constexpr float y() const
constexpr float x() const
◆ iset() [1/2]
void SkPoint::iset |
( |
const SkIPoint & |
p | ) |
|
|
inline |
Sets fX to p.fX and fY to p.fY, promoting integers to float values.
Assigning an SkIPoint containing a large integer value directly to fX or fY may cause a compiler error, triggered by narrowing conversion of int to float. This safely casts p.fX and p.fY to avoid the error.
- Parameters
-
Definition at line 227 of file SkPoint_impl.h.
227 {
228 fX =
static_cast<float>(
p.fX);
229 fY =
static_cast<float>(
p.fY);
230 }
◆ iset() [2/2]
void SkPoint::iset |
( |
int32_t |
x, |
|
|
int32_t |
y |
|
) |
| |
|
inline |
Sets fX to x and fY to y, promoting integers to float values.
Assigning a large integer value directly to fX or fY may cause a compiler error, triggered by narrowing conversion of int to float. This safely casts x and y to avoid the error.
- Parameters
-
x | new value for fX |
y | new value for fY |
Definition at line 214 of file SkPoint_impl.h.
214 {
215 fX =
static_cast<float>(
x);
216 fY =
static_cast<float>(
y);
217 }
◆ isFinite()
bool SkPoint::isFinite |
( |
| ) |
const |
|
inline |
Returns true if both fX and fY are measurable values.
- Returns
- true for values other than infinities and NaN
Definition at line 412 of file SkPoint_impl.h.
412 {
414 }
static bool SkIsFinite(T x, Pack... values)
◆ isZero()
bool SkPoint::isZero |
( |
| ) |
const |
|
inline |
Returns true if fX and fY are both zero.
- Returns
- true if fX is zero and fY is zero
Definition at line 193 of file SkPoint_impl.h.
193{
return (0 ==
fX) & (0 ==
fY); }
◆ length()
float SkPoint::length |
( |
| ) |
const |
|
inline |
Returns the Euclidean distance from origin, computed as:
sqrt(fX * fX + fY * fY)
- Returns
- straight-line distance to origin
Definition at line 282 of file SkPoint_impl.h.
◆ Length()
float SkPoint::Length |
( |
float |
x, |
|
|
float |
y |
|
) |
| |
|
static |
Returns the Euclidean distance from origin, computed as:
sqrt(x * x + y * y)
- Parameters
-
x | component of length |
y | component of length |
- Returns
- straight-line distance to origin
example: https://fiddle.skia.org/c/@Point_Length
Definition at line 79 of file SkPoint.cpp.
79 {
80 float mag2 =
dx *
dx + dy * dy;
83 } else {
85 double yy = dy;
87 }
88}
static constexpr float sk_double_to_float(double x)
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
◆ Make()
static constexpr SkPoint SkPoint::Make |
( |
float |
x, |
|
|
float |
y |
|
) |
| |
|
inlinestaticconstexpr |
Sets fX to x, fY to y. Used both to set SkPoint and vector.
- Parameters
-
x | float x-axis value of constructed SkPoint or vector |
y | float y-axis value of constructed SkPoint or vector |
- Returns
- SkPoint (x, y)
Definition at line 173 of file SkPoint_impl.h.
◆ negate()
◆ normalize()
bool SkPoint::normalize |
( |
| ) |
|
Scales (fX, fY) so that length() returns one, while preserving ratio of fX to fY, if possible. If prior length is nearly zero, sets vector to (0, 0) and returns false; otherwise returns true.
- Returns
- true if former length is not zero or nearly zero
example: https://fiddle.skia.org/c/@Point_normalize_2
Definition at line 22 of file SkPoint.cpp.
22 {
24}
bool setLength(float length)
◆ Normalize()
float SkPoint::Normalize |
( |
SkVector * |
vec | ) |
|
|
static |
Scales (vec->fX, vec->fY) so that length() returns one, while preserving ratio of vec->fX to vec->fY, if possible. If original length is nearly zero, sets vec to (0, 0) and returns zero; otherwise, returns length of vec before vec is scaled.
Returned prior length may be INFINITY if it can not be represented by float.
Note that normalize() is faster if prior length is not required.
- Parameters
-
vec | normalized to unit length |
- Returns
- original vec length
example: https://fiddle.skia.org/c/@Point_Normalize
Definition at line 71 of file SkPoint.cpp.
71 {
72 float mag;
73 if (set_point_length<false>(pt, pt->fX, pt->fY, 1.0f, &mag)) {
74 return mag;
75 }
76 return 0;
77}
◆ offset()
void SkPoint::offset |
( |
float |
dx, |
|
|
float |
dy |
|
) |
| |
|
inline |
◆ Offset() [1/2]
Adds offset to each SkPoint in points array with count entries.
- Parameters
-
points | SkPoint array |
count | entries in array |
offset | vector added to points |
Definition at line 247 of file SkPoint_impl.h.
247 {
249 }
static const int points[]
void offset(float dx, float dy)
static void Offset(SkPoint points[], int count, const SkVector &offset)
◆ Offset() [2/2]
static void SkPoint::Offset |
( |
SkPoint |
points[], |
|
|
int |
count, |
|
|
float |
dx, |
|
|
float |
dy |
|
) |
| |
|
inlinestatic |
Adds offset (dx, dy) to each SkPoint in points array of length count.
- Parameters
-
points | SkPoint array |
count | entries in array |
dx | added to fX in points |
dy | added to fY in points |
Definition at line 258 of file SkPoint_impl.h.
◆ operator*()
SkPoint SkPoint::operator* |
( |
float |
scale | ) |
const |
|
inline |
Returns SkPoint multiplied by scale.
- Parameters
-
scale | float to multiply by |
- Returns
- SkPoint as (fX * scale, fY * scale)
Definition at line 393 of file SkPoint_impl.h.
393 {
395 }
void scale(float scale, SkPoint *dst) const
◆ operator*=()
SkPoint & SkPoint::operator*= |
( |
float |
scale | ) |
|
|
inline |
Multiplies SkPoint by scale. Sets SkPoint to: (fX * scale, fY * scale).
- Parameters
-
scale | float to multiply by |
- Returns
- reference to SkPoint
Definition at line 402 of file SkPoint_impl.h.
402 {
405 return *this;
406 }
◆ operator+=()
void SkPoint::operator+= |
( |
const SkVector & |
v | ) |
|
|
inline |
◆ operator-()
SkPoint SkPoint::operator- |
( |
| ) |
const |
|
inline |
◆ operator-=()
void SkPoint::operator-= |
( |
const SkVector & |
v | ) |
|
|
inline |
◆ scale() [1/2]
void SkPoint::scale |
( |
float |
scale, |
|
|
SkPoint * |
dst |
|
) |
| const |
◆ scale() [2/2]
void SkPoint::scale |
( |
float |
value | ) |
|
|
inline |
◆ set()
void SkPoint::set |
( |
float |
x, |
|
|
float |
y |
|
) |
| |
|
inline |
Sets fX to x and fY to y.
- Parameters
-
x | new value for fX |
y | new value for fY |
Definition at line 200 of file SkPoint_impl.h.
◆ setAbs()
void SkPoint::setAbs |
( |
const SkPoint & |
pt | ) |
|
|
inline |
Sets fX to absolute value of pt.fX; and fY to absolute value of pt.fY.
- Parameters
-
pt | members providing magnitude for fX and fY |
Definition at line 236 of file SkPoint_impl.h.
236 {
239 }
SIN Vec< N, float > abs(const Vec< N, float > &x)
◆ setLength() [1/2]
bool SkPoint::setLength |
( |
float |
length | ) |
|
Scales vector so that distanceToOrigin() returns length, if possible. If former length is nearly zero, sets vector to (0, 0) and return false; otherwise returns true.
- Parameters
-
length | straight-line distance to origin |
- Returns
- true if former length is not zero or nearly zero
example: https://fiddle.skia.org/c/@Point_setLength
Definition at line 30 of file SkPoint.cpp.
◆ setLength() [2/2]
bool SkPoint::setLength |
( |
float |
x, |
|
|
float |
y, |
|
|
float |
length |
|
) |
| |
Sets vector to (x, y) scaled to length, if possible. If former length is nearly zero, sets vector to (0, 0) and return false; otherwise returns true.
- Parameters
-
x | proportional value for fX |
y | proportional value for fY |
length | straight-line distance to origin |
- Returns
- true if (x, y) length is not zero or nearly zero
example: https://fiddle.skia.org/c/@Point_setLength_2
Definition at line 90 of file SkPoint.cpp.
90 {
91 return set_point_length<false>(
this,
x,
y,
length);
92}
◆ setNormalize()
bool SkPoint::setNormalize |
( |
float |
x, |
|
|
float |
y |
|
) |
| |
Sets vector to (x, y) scaled so length() returns one, and so that (fX, fY) is proportional to (x, y). If (x, y) length is nearly zero, sets vector to (0, 0) and returns false; otherwise returns true.
- Parameters
-
x | proportional value for fX |
y | proportional value for fY |
- Returns
- true if (x, y) length is not zero or nearly zero
example: https://fiddle.skia.org/c/@Point_setNormalize
Definition at line 26 of file SkPoint.cpp.
◆ x()
constexpr float SkPoint::x |
( |
| ) |
const |
|
inlineconstexpr |
◆ y()
constexpr float SkPoint::y |
( |
| ) |
const |
|
inlineconstexpr |
◆ operator!=
Returns true if a is not equivalent to b.
- Parameters
-
- Returns
- true if a.fX != b.fX or a.fY != b.fY
Definition at line 442 of file SkPoint_impl.h.
442 {
443 return a.fX !=
b.fX ||
a.fY !=
b.fY;
444 }
◆ operator+
Returns SkPoint resulting from SkPoint a offset by vector b, computed as: (a.fX + b.fX, a.fY + b.fY).
Can also be used to offset SkPoint b by vector a, returning SkPoint. Can also be used to add vector to vector, returning vector.
- Parameters
-
- Returns
- SkPoint equal to a offset by b
Definition at line 469 of file SkPoint_impl.h.
469 {
470 return {
a.fX +
b.fX,
a.fY +
b.fY};
471 }
◆ operator-
Returns vector from b to a, computed as (a.fX - b.fX, a.fY - b.fY).
Can also be used to subtract vector from SkPoint, returning SkPoint. Can also be used to subtract vector from vector, returning vector.
- Parameters
-
- Returns
- vector from b to a
Definition at line 455 of file SkPoint_impl.h.
455 {
456 return {
a.fX -
b.fX,
a.fY -
b.fY};
457 }
◆ operator==
Returns true if a is equivalent to b.
- Parameters
-
- Returns
- true if a.fX == b.fX and a.fY == b.fY
Definition at line 432 of file SkPoint_impl.h.
432 {
433 return a.fX ==
b.fX &&
a.fY ==
b.fY;
434 }
◆ fX
◆ fY
The documentation for this struct was generated from the following files: