About all my projects
NO_TITLE

NO_TITLE

Gnome::Graphene::N-Point

Description

A point with two coordinates.

Class initialization

new

:native-object

Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.

multi method new ( N-Object :$native-object! )

alloc

Allocates a new Gnome::Graphene::N-Point structure.

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

It's possible to chain this function with .init() or .init-from-point(), e.g.:

method alloc ( --> Gnome::Graphene::Point \)

Methods

distance

Computes the distance between $a and $b.

method distance ( CArray[N-Point] $b, Num() $d-x, Num() $d-y --> Num )
  • $b; a Gnome::Graphene::N-Point.

  • $d-x; (transfer ownership: full) distance component on the X axis.

  • $d-y; (transfer ownership: full) distance component on the Y axis.

Return value; the distance between the two points.

equal This function is not yet available

Checks if the two points $a 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 .near() instead.

method equal ( CArray[N-Point] $b )
  • $b; a Gnome::Graphene::N-Point.

free

Frees the resources allocated by .alloc().

method free ( )

init

Initializes $p to the given $x and $y coordinates.

It's safe to call this function multiple times.

method init ( Num() $x, Num() $y --> CArray[N-Point] )
  • $x; the X coordinate.

  • $y; the Y coordinate.

Return value; the initialized point.

init-from-point

Initializes $p with the same coordinates of $src.

method init-from-point ( CArray[N-Point] $src --> CArray[N-Point] )
  • $src; the Gnome::Graphene::N-Point to use.

Return value; the initialized point.

init-from-vec2

Initializes $p with the coordinates inside the given graphene_vec2_t.

method init-from-vec2 ( CArray[N-Vec2] $src --> CArray[N-Point] )
  • $src; a graphene_vec2_t.

Return value; the initialized point.

interpolate

Linearly interpolates the coordinates of $a and $b using the given $factor.

method interpolate ( CArray[N-Point] $b, Num() $factor, CArray[N-Point] $res )
  • $b; a Gnome::Graphene::N-Point.

  • $factor; the linear interpolation factor.

  • $res; return location for the interpolated point.

near This function is not yet available

Checks whether the two points $a and $b are within the threshold of $epsilon.

method near ( CArray[N-Point] $b, Num() $epsilon )
  • $b; a Gnome::Graphene::N-Point.

  • $epsilon; threshold between the two points.

to-vec2

Stores the coordinates of the given Gnome::Graphene::N-Point into a graphene_vec2_t.

method to-vec2 ( CArray[N-Vec2] $v )
  • $v; return location for the vertex.

Functions

zero

Returns a point fixed at (0, 0).

method zero (--> CArray[N-Point] )

Return value; a fixed point.