Graphene.Point¶
Fields¶
Name |
Type |
Access |
Description |
|---|---|---|---|
x |
r/w |
the X coordinate of the point |
|
y |
r/w |
the Y coordinate of the point |
Methods¶
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class Graphene.Point¶
A point with two coordinates.
New in version 1.0.
- classmethod alloc()¶
- Returns:
the newly allocated
Graphene.Point. UseGraphene.Point.free() to free the resources allocated by this function.- Return type:
Allocates a new
Graphene.Pointstructure.The coordinates of the returned point are (0, 0).
It’s possible to chain this function with
Graphene.Point.init() orGraphene.Point.init_from_point(), e.g.:graphene_point_t * point_new (float x, float y) { return graphene_point_init (graphene_point_alloc (), x, y); } graphene_point_t * point_copy (const graphene_point_t *p) { return graphene_point_init_from_point (graphene_point_alloc (), p); }
New in version 1.0.
- classmethod zero()¶
- Returns:
a fixed point
- Return type:
Returns a point fixed at (0, 0).
New in version 1.0.
- distance(b)¶
- Parameters:
b (
Graphene.Point) – aGraphene.Point- Returns:
the distance between the two points
- d_x:
distance component on the X axis
- d_y:
distance component on the Y axis
- Return type:
Computes the distance between self and b.
New in version 1.0.
- equal(b)¶
- Parameters:
b (
Graphene.Point) – aGraphene.Point- Returns:
trueif the points have the same coordinates- Return type:
Checks if the two points self and b point to the same coordinates.
This function accounts for floating point fluctuations; if you want to control the fuzziness of the match, you can use
Graphene.Point.near() instead.New in version 1.0.
- free()¶
Frees the resources allocated by
Graphene.Point.alloc().New in version 1.0.
- init(x, y)¶
- Parameters:
- Returns:
the initialized point
- Return type:
Initializes self to the given x and y coordinates.
It’s safe to call this function multiple times.
New in version 1.0.
- init_from_point(src)¶
- Parameters:
src (
Graphene.Point) – theGraphene.Pointto use- Returns:
the initialized point
- Return type:
Initializes self with the same coordinates of src.
New in version 1.0.
- init_from_vec2(src)¶
- Parameters:
src (
Graphene.Vec2) – aGraphene.Vec2- Returns:
the initialized point
- Return type:
Initializes self with the coordinates inside the given
Graphene.Vec2.New in version 1.4.
- interpolate(b, factor)¶
- Parameters:
b (
Graphene.Point) – aGraphene.Pointfactor (
float) – the linear interpolation factor
- Returns:
return location for the interpolated point
- Return type:
res:
Graphene.Point
Linearly interpolates the coordinates of self and b using the given factor.
New in version 1.0.
- near(b, epsilon)¶
- Parameters:
b (
Graphene.Point) – aGraphene.Pointepsilon (
float) – threshold between the two points
- Returns:
trueif the distance is within epsilon- Return type:
Checks whether the two points self and b are within the threshold of epsilon.
New in version 1.0.
- to_vec2()¶
- Returns:
return location for the vertex
- Return type:
Stores the coordinates of the given
Graphene.Pointinto aGraphene.Vec2.New in version 1.4.