Package org.gnome.graphene
Class Point
java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.graphene.Point
-
Constructor Summary
ConstructorsConstructorDescriptionPoint()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 Pointalloc()Allocates a newgraphene_point_tstructure.floatComputes the distance between this Point andb.booleanChecks if the two points this Point andbpoint to the same coordinates.voidfree()Frees the resources allocated by graphene_point_alloc().static MemoryLayoutThe memory layout of the native struct.static @Nullable TypegetType()Get the GType of the Point classinit(float x, float y) Initializes this Point to the givenxandycoordinates.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.voidinterpolate(Point b, double factor, Point res) Linearly interpolates the coordinates of this Point andbusing the givenfactor.booleanChecks whether the two points this Point andbare within the threshold ofepsilon.floatreadX()Read the value of the fieldx.floatreadY()Read the value of the fieldy.voidStores the coordinates of the givengraphene_point_tinto agraphene_vec2_t.voidwriteX(float x) Write a value in the fieldx.voidwriteY(float y) Write a value in the fieldy.static Pointzero()Returns a point fixed at (0, 0).Methods inherited from class org.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 fieldxy- value for the fieldyarena- 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 fieldxy- 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_tstructure.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. - Since:
- 1.0
-
zero
-
distance
-
equal
Checks if the two points this Point andbpoint 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:
trueif the points have the same coordinates- Since:
- 1.0
-
free
public void free()Frees the resources allocated by graphene_point_alloc().- Since:
- 1.0
-
init
Initializes this Point to the givenxandycoordinates.It's safe to call this function multiple times.
- Parameters:
x- the X coordinatey- the Y coordinate- Returns:
- the initialized point
- Since:
- 1.0
-
initFromPoint
-
initFromVec2
-
interpolate
-
near
Checks whether the two points this Point andbare within the threshold ofepsilon.- Parameters:
b- agraphene_point_tepsilon- threshold between the two points- Returns:
trueif the distance is withinepsilon- Since:
- 1.0
-
toVec2
Stores the coordinates of the givengraphene_point_tinto agraphene_vec2_t.- Parameters:
v- return location for the vertex- Since:
- 1.4
-