Package org.gnome.graphene
Class Point
java.lang.Object
io.github.jwharm.javagi.base.ProxyInstance
org.gnome.graphene.Point
-
Constructor Summary
ConstructorDescriptionPoint()
Allocate a new Point.Point
(float x, float y) Allocate a new Point with the fields set to the provided values.Allocate a new Point with the fields set to the provided values.Allocate a new Point.Point
(MemorySegment address) Create a Point proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionstatic Point
alloc()
Allocates a newgraphene_point_t
structure.float
Computes the distance between this Point andb
.boolean
Checks if the two points this Point andb
point to the same coordinates.void
free()
Frees the resources allocated by graphene_point_alloc().static MemoryLayout
The memory layout of the native struct.static Type
getType()
Get the GType of the Point classinit
(float x, float y) Initializes this Point to the givenx
andy
coordinates.initFromPoint
(Point src) Initializes this Point with the same coordinates ofsrc
.initFromVec2
(Vec2 src) Initializes this Point with the coordinates inside the givengraphene_vec2_t
.void
interpolate
(Point b, double factor, Point res) Linearly interpolates the coordinates of this Point andb
using the givenfactor
.boolean
Checks whether the two points this Point andb
are within the threshold ofepsilon
.float
readX()
Read the value of the fieldx
.float
readY()
Read the value of the fieldy
.void
Stores the coordinates of the givengraphene_point_t
into agraphene_vec2_t
.void
writeX
(float x) Write a value in the fieldx
.void
writeY
(float y) Write a value in the fieldy
.static Point
zero()
Returns a point fixed at (0, 0).Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Point
Create a Point proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Point
Allocate a new Point.- Parameters:
arena
- to control the memory allocation scope
-
Point
public Point()Allocate a new Point. The memory is allocated withArena.ofAuto()
. -
Point
Allocate a new Point with the fields set to the provided values.- Parameters:
x
- value for the fieldx
y
- value for the fieldy
arena
- to control the memory allocation scope
-
Point
public Point(float x, float y) Allocate a new Point with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
x
- value for the fieldx
y
- value for the fieldy
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readX
public float readX()Read the value of the fieldx
.- Returns:
- The value of the field
x
-
writeX
public void writeX(float x) Write a value in the fieldx
.- Parameters:
x
- The new value for the fieldx
-
readY
public float readY()Read the value of the fieldy
.- Returns:
- The value of the field
y
-
writeY
public void writeY(float y) Write a value in the fieldy
.- Parameters:
y
- The new value for the fieldy
-
alloc
Allocates a newgraphene_point_t
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); }
- Returns:
- the newly allocated
graphene_point_t
. Use graphene_point_free() to free the resources allocated by this function.
-
zero
-
distance
public float distance(Point b, @Nullable @Nullable Out<Float> dX, @Nullable @Nullable Out<Float> dY) Computes the distance between this Point andb
.- Parameters:
b
- agraphene_point_t
dX
- distance component on the X axisdY
- distance component on the Y axis- Returns:
- the distance between the two points
-
equal
Checks if the two points this Point andb
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.
- Parameters:
b
- agraphene_point_t
- Returns:
true
if the points have the same coordinates
-
free
public void free()Frees the resources allocated by graphene_point_alloc(). -
init
Initializes this Point to the givenx
andy
coordinates.It's safe to call this function multiple times.
- Parameters:
x
- the X coordinatey
- the Y coordinate- Returns:
- the initialized point
-
initFromPoint
-
initFromVec2
-
interpolate
-
near
Checks whether the two points this Point andb
are within the threshold ofepsilon
.- Parameters:
b
- agraphene_point_t
epsilon
- threshold between the two points- Returns:
true
if the distance is withinepsilon
-
toVec2
Stores the coordinates of the givengraphene_point_t
into agraphene_vec2_t
.- Parameters:
v
- return location for the vertex
-