Point
- class Point
Point
holds two 32-bit floating point coordinates.Example:
point = skia.Point(0.0, 0.0) point = skia.Point((0.0, 0.0)) # Convert from tuple print(point.fX, point.fY) point + (1, 1) # Add offset point - (0, 0) # Subtract offset point * 2.0 # Scale x, y = tuple(point) # Convert to tuple
Methods
Returns the cross product of vector a and vector b.
Returns the Euclidean distance between a and b.
Returns the dot product of vector a and vector b.
Returns the Euclidean distance from origin, computed as:
Sets fX to x, fY to y.
Scales (vec->fX, vec->fY) so that length() returns one, while preserving ratio of vec->fX to vec->fY, if possible.
Overloaded function.
Overloaded function.
Returns the cross product of vector and vec.
Returns the Euclidean distance from origin, computed as:
Returns the dot product of vector and vector vec.
Returns true if
Point
is equivalent toPoint
constructed from (x, y).Returns true if both fX and fY are measurable values.
Returns true if fX and fY are both zero.
Overloaded function.
Returns the Euclidean distance from origin, computed as:
Changes the sign of fX and fY.
Scales (fX, fY) so that
length()
returns one, while preserving ratio of fX to fY, if possible.Adds offset (dx, dy) to
Point
.Sets dst to
Point
times scale.Sets fX to x and fY to y.
Sets fX to absolute value of pt.fX; and fY to absolute value of pt.fY.
Overloaded function.
Sets vector to (x, y) scaled so
length()
returns one, and so that (fX, fY) is proportional to (x, y).Returns x-axis value of
Point
or vector.Returns y-axis value of
Point
or vector.Attributes
x-axis value
y-axis value
Methods
- static Point.CrossProduct(a: skia.Point, b: skia.Point) float
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
- static Point.Distance(a: skia.Point, b: skia.Point) float
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
- static Point.DotProduct(a: skia.Point, b: skia.Point) float
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
- static Point.Length(x: float, y: float) float
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
- static Point.Make(x: float, y: float) skia.Point
Sets fX to x, fY to y.
Used both to set
Point
and vector.
- static Point.Normalize(vec: skia.Point) float
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:
vec – normalized to unit length
- Returns:
original vec length
- static Point.Offset(*args, **kwargs)
Overloaded function.
Offset(points: std::vector<SkPoint, std::allocator<SkPoint> >, offset: skia.Point) -> std::vector<SkPoint, std::allocator<SkPoint> >
Offset(points: std::vector<SkPoint, std::allocator<SkPoint> >, dx: float, dy: float) -> std::vector<SkPoint, std::allocator<SkPoint> >
- Point.__init__(*args, **kwargs)
Overloaded function.
__init__(self: skia.Point, x: float, y: float) -> None
__init__(self: skia.Point, ipoint: skia.IPoint) -> None
__init__(self: skia.Point, t: tuple) -> None
- Point.cross(self: skia.Point, vec: skia.Point) float
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
- Point.distanceToOrigin(self: skia.Point) float
Returns the Euclidean distance from origin, computed as:
sqrt(fX * fX + fY * fY)
- Returns:
straight-line distance to origin
- Point.dot(self: skia.Point, vec: skia.Point) float
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
- Point.equals(self: skia.Point, x: float, y: float) bool
Returns true if
Point
is equivalent toPoint
constructed from (x, y).- Parameters:
x – value compared with fX
y – value compared with fY
- Returns:
true if
Point
equals (x, y)
- Point.isFinite(self: skia.Point) bool
Returns true if both fX and fY are measurable values.
- Returns:
true for values other than infinities and NaN
- Point.isZero(self: skia.Point) bool
Returns true if fX and fY are both zero.
- Returns:
true if fX is zero and fY is zero
- Point.iset(*args, **kwargs)
Overloaded function.
iset(self: skia.Point, x: int, y: int) -> None
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.
- x:
new value for fX
- y:
new value for fY
iset(self: skia.Point, p: skia.IPoint) -> None
Sets fX to p.fX and fY to p.fY, promoting integers to SkScalar values.
Assigning an
IPoint
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.- p:
IPoint
members promoted to SkScalar
- Point.length(self: skia.Point) float
Returns the Euclidean distance from origin, computed as:
sqrt(fX * fX + fY * fY)
- Returns:
straight-line distance to origin
- Point.negate(self: skia.Point) None
Changes the sign of fX and fY.
- Point.normalize(self: skia.Point) bool
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
- Point.offset(self: skia.Point, dx: float, dy: float) None
Adds offset (dx, dy) to
Point
.- Parameters:
dx – added to fX
dy – added to fY
- Point.scale(self: skia.Point, scale: float) skia.Point
Sets dst to
Point
times scale.dst may be
Point
to modifyPoint
in place.It is also possible to use operators:
p * scale p *= scale # in-place
- Parameters:
scale – factor to multiply
Point
by
- Point.set(self: skia.Point, x: float, y: float) None
Sets fX to x and fY to y.
- Parameters:
x – new value for fX
y – new value for fY
- Point.setAbs(self: skia.Point, pt: skia.Point) None
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
- Point.setLength(*args, **kwargs)
Overloaded function.
setLength(self: skia.Point, length: float) -> bool
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.
- length:
straight-line distance to origin
- return:
true if former length is not zero or nearly zero
setLength(self: skia.Point, x: float, y: float, length: float) -> bool
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.
- x:
proportional value for fX
- y:
proportional value for fY
- length:
straight-line distance to origin
- return:
true if (x, y) length is not zero or nearly zero
- Point.setNormalize(self: skia.Point, x: float, y: float) bool
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
- Point.x(self: skia.Point) float
Returns x-axis value of
Point
or vector.
- Point.y(self: skia.Point) float
Returns y-axis value of
Point
or vector.
Attributes
- Point.fX
x-axis value
- Point.fY
y-axis value