SkPoint Reference


SkPoint holds two 32-bit floating point coordinates.


Sets fX to x, fY to y. Used both to set SkPoint and vector.

Parameters

Return Value

SkPoint (x, y)

Example

Example Output

all equal

See Also

set() iset() SkIPoint::Make


Returns x-axis value of SkPoint or vector.

Return Value

fX

Example

Example Output

pt1.fX == pt1.x()

See Also

y() SkIPoint::x()


Returns y-axis value of SkPoint or vector.

Return Value

fY

Example

Example Output

pt1.fY == pt1.y()

See Also

x() SkIPoint::y()


Returns true if fX and fY are both zero.

Return Value

true if fX is zero and fY is zero

Example

Example Output

pt.fX=+0 pt.fY=-0
pt.isZero() == true

See Also

isFinite SkIPoint::isZero


Sets fX to x and fY to y.

Parameters

Example

Example Output

pt1 == pt2

See Also

iset() Make


Sets fX to x and fY to y, promoting integers to SkScalar values.

Assigning a large integer value directly to fX or fY may cause a compiler error, triggered by narrowing conversion of int to SkScalar. This safely casts x and y to avoid the error.

Parameters

Example

See Also

set Make SkIPoint::set


Sets fX to p.fX and fY to p.fY, promoting integers to SkScalar 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 SkScalar. This safely casts p.fX and p.fY to avoid the error.

Parameters

Example

Example Output

iPt: -2147483647, 2147483647
fPt: -2.14748e+09, 2.14748e+09

See Also

set Make SkIPoint::set


Sets fX to absolute value of pt.fX; and fY to absolute value of pt.fY.

Parameters

Example

Example Output

pt: 0, -0  abs: 0, 0
pt: -1, -2  abs: 1, 2
pt: inf, -inf  abs: inf, inf
pt: nan, -nan  abs: nan, nan

See Also

set Make negate


Adds offset to each SkPoint in points array with count entries.

Parameters

Example

See Also

offset offsetoperator+=(const SkVector& v)


Adds offset (dx, dy) to each SkPoint in points array of length count.

Parameters

Example

See Also

offset offsetoperator+=(const SkVector& v)


Adds offset (dx, dy) to SkPoint.

Parameters

Example

See Also

Offset Offsetoperator+=(const SkVector& v)


Returns the Euclidean distance from origin, computed as:

sqrt(fX * fX + fY * fY)

.

Return Value

straight-line distance to origin

Example

See Also

distanceToOrigin Length setLength Distance


Returns the Euclidean distance from origin, computed as:

sqrt(fX * fX + fY * fY)

.

Return Value

straight-line distance to origin

Example

See Also

length Length setLength Distance


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.

Return Value

true if former length is not zero or nearly zero

Example

See Also

Normalize setLength length Length


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

Return Value

true if (x, y) length is not zero or nearly zero

Example

See Also

normalize setLength


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

Return Value

true if former length is not zero or nearly zero

Example

See Also

length Length setNormalize setAbs


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

Return Value

true if (x, y) length is not zero or nearly zero

Example

See Also

length Length setNormalize setAbs


Sets dst to SkPoint times scale. dst may be SkPoint to modify SkPoint in place.

Parameters

Example

See Also

operator*(SkScalar scale)_const operator*(SkScalar scale)_constoperator*=(SkScalar scale) setLength


Scales SkPoint in place by scale.

Parameters

Example

See Also

operator*(SkScalar scale)_const operator*(SkScalar scale)_constoperator*=(SkScalar scale) setLength


Changes the sign of fX and fY.

Example

Example Output

pt: 0, -0  negate: -0, 0
pt: -1, -2  negate: 1, 2
pt: inf, -inf  negate: -inf, inf
pt: nan, -nan  negate: -nan, nan

See Also

operator-()_const setAbs


Returns SkPoint changing the signs of fX and fY.

Return Value

SkPoint as (-fX, -fY)

Example

Example Output

pt: 0, -0  negate: -0, 0
pt: -1, -2  negate: 1, 2
pt: inf, -inf  negate: -inf, inf
pt: nan, -nan  negate: -nan, nan

See Also

negate negateoperator-(const SkPoint& a, const SkPoint& b) operator-(const SkPoint& a, const SkPoint& b)operator-=(const SkVector& v) SkIPoint::operator-()_const


Adds Vector v to Point. Sets Point to: (fX + v.fX, fY + v.fY).

Parameters

Example

See Also

offset() offset()operator+(const SkPoint& a, const SkVector& b) SkIPoint::SkIPointoperator+=(const SkIVector& v)


Subtracts Vector v from Point. Sets Point to: (fX - v.fX, fY - v.fY).

Parameters

Example

See Also

offset() offset()operator-(const SkPoint& a, const SkPoint& b) SkIPoint::SkIPointoperator-=(const SkIVector& v)


Returns SkPoint multiplied by scale.

Parameters

Return Value

SkPoint as (fX * scale, fY * scale)

Example

See Also

operator*=(SkScalar scale) scale() setLength setNormalize


Multiplies Point by scale. Sets Point to: (fX * scale, fY * scale).

Parameters

Return Value

reference to Point

Example

See Also

operator*(SkScalar scale)_const scale() setLength setNormalize


Returns true if both fX and fY are measurable values.

Return Value

true for values other than infinities and NaN

Example

Example Output

pt: 0, -0  finite: true
pt: -1, -2  finite: true
pt: inf, 1  finite: false
pt: nan, -1  finite: false

See Also

SkRect::isFinite SkPath::isFinite


Returns true if SkPoint is equivalent to SkPoint constructed from (x, y).

Parameters

Return Value

true if SkPoint equals (x, y)

Example

Example Output

pt: 0, -0  == pt
pt: -1, -2  == pt
pt: inf, 1  == pt
pt: nan, -1  != pt

See Also

operator==(const SkPoint& a, const SkPoint& b)


Returns true if a is equivalent to b.

Parameters

Return Value

true if a.fX == b.fX and a.fY == b.fY

Example

Example Output

pt: 0, -0  == pt
pt: -1, -2  == pt
pt: inf, 1  == pt
pt: nan, -1  != pt

See Also

equals() equals()operator!=(const SkPoint& a, const SkPoint& b)


Returns true if a is not equivalent to b.

Parameters

Return Value

true if a.fX != b.fX or a.fY != b.fY

Example

Example Output

pt: 0, -0  == pt
pt: -1, -2  == pt
pt: inf, 1  == pt
pt: nan, -1  != pt

See Also

operator==(const SkPoint& a, const SkPoint& b) equals()


Returns Vector from b to a, computed as (a.fX - b.fX, a.fY - b.fY).

Can also be used to subtract Vector from Point, returning Point. Can also be used to subtract Vector from Vector, returning Vector.

Parameters

Return Value

Vector from b to a

Example

See Also

operator-=(const SkVector& v) offset()


Returns Point resulting from Point a offset by Vector b, computed as: (a.fX + b.fX, a.fY + b.fY).

Can also be used to offset Point b by Vector a, returning Point. Can also be used to add Vector to Vector, returning Vector.

Parameters

Return Value

Point equal to a offset by b

Example

See Also

operator+=(const SkVector& v) offset()


Returns the Euclidean distance from origin, computed as:

sqrt(x * x + y * y)

.

Parameters

Return Value

straight-line distance to origin

Example

See Also

length() Distance setLength


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 SK_ScalarInfinity if it can not be represented by SkScalar.

Note that normalize() is faster if prior length is not required.

Parameters

Return Value

original vec length

Example

See Also

normalize() setLength Length


Returns the Euclidean distance between a and b.

Parameters

Return Value

straight-line distance from a to b

Example

See Also

length() setLength


Returns the dot product of vector a and vector b.

Parameters

Return Value

product of input magnitudes and cosine of the angle between them

Example

See Also

dot 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

Return Value

area spanned by vectors signed by angle direction

Example

See Also

cross DotProduct


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

Return Value

area spanned by vectors signed by angle direction

Example

See Also

CrossProduct dot


Returns the dot product of vector and vector vec.

Parameters

Return Value

product of input magnitudes and cosine of the angle between them

Example

See Also

DotProduct cross


SkVector provides an alternative name for SkPoint. SkVector and SkPoint can be used interchangeably for all purposes.