Graphene.Point

Fields

Name

Type

Access

Description

x

float

r/w

the X coordinate of the point

y

float

r/w

the Y coordinate of the point

Methods

class

alloc ()

class

zero ()

distance (b)

equal (b)

free ()

init (x, y)

init_from_point (src)

init_from_vec2 (src)

interpolate (b, factor)

near (b, epsilon)

to_vec2 ()

Details

class Graphene.Point

A point with two coordinates.

New in version 1.0.

classmethod alloc()
Returns:

the newly allocated Graphene.Point. Use Graphene.Point.free() to free the resources allocated by this function.

Return type:

Graphene.Point

Allocates a new Graphene.Point structure.

The coordinates of the returned point are (0, 0).

It’s possible to chain this function with Graphene.Point.init() or Graphene.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:

Graphene.Point

Returns a point fixed at (0, 0).

New in version 1.0.

distance(b)
Parameters:

b (Graphene.Point) – a Graphene.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:

(float, d_x: float, d_y: float)

Computes the distance between self and b.

New in version 1.0.

equal(b)
Parameters:

b (Graphene.Point) – a Graphene.Point

Returns:

true if the points have the same coordinates

Return type:

bool

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:
  • x (float) – the X coordinate

  • y (float) – the Y coordinate

Returns:

the initialized point

Return type:

Graphene.Point

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) – the Graphene.Point to use

Returns:

the initialized point

Return type:

Graphene.Point

Initializes self with the same coordinates of src.

New in version 1.0.

init_from_vec2(src)
Parameters:

src (Graphene.Vec2) – a Graphene.Vec2

Returns:

the initialized point

Return type:

Graphene.Point

Initializes self with the coordinates inside the given Graphene.Vec2.

New in version 1.4.

interpolate(b, factor)
Parameters:
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:
Returns:

true if the distance is within epsilon

Return type:

bool

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:

v: Graphene.Vec2

Stores the coordinates of the given Graphene.Point into a Graphene.Vec2.

New in version 1.4.