Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
A point with two coordinates.
Since: 1.0
Synopsis
- newtype Point = Point (ManagedPtr Point)
- newZeroPoint :: MonadIO m => m Point
- pointAlloc :: (HasCallStack, MonadIO m) => m Point
- pointDistance :: (HasCallStack, MonadIO m) => Point -> Point -> m (Float, Float, Float)
- pointEqual :: (HasCallStack, MonadIO m) => Point -> Point -> m Bool
- pointFree :: (HasCallStack, MonadIO m) => Point -> m ()
- pointInit :: (HasCallStack, MonadIO m) => Point -> Float -> Float -> m Point
- pointInitFromPoint :: (HasCallStack, MonadIO m) => Point -> Point -> m Point
- pointInitFromVec2 :: (HasCallStack, MonadIO m) => Point -> Vec2 -> m Point
- pointInterpolate :: (HasCallStack, MonadIO m) => Point -> Point -> Double -> m Point
- pointNear :: (HasCallStack, MonadIO m) => Point -> Point -> Float -> m Bool
- pointToVec2 :: (HasCallStack, MonadIO m) => Point -> m Vec2
- pointZero :: (HasCallStack, MonadIO m) => m Point
- getPointX :: MonadIO m => Point -> m Float
- setPointX :: MonadIO m => Point -> Float -> m ()
- getPointY :: MonadIO m => Point -> m Float
- setPointY :: MonadIO m => Point -> Float -> m ()
Exported types
Memory-managed wrapper type.
Instances
Eq Point Source # | |
IsGValue Point Source # | Convert |
ManagedPtrNewtype Point Source # | |
Defined in GI.Graphene.Structs.Point toManagedPtr :: Point -> ManagedPtr Point # | |
TypedObject Point Source # | |
Defined in GI.Graphene.Structs.Point | |
GBoxed Point Source # | |
Defined in GI.Graphene.Structs.Point | |
HasParentTypes Point Source # | |
Defined in GI.Graphene.Structs.Point | |
tag ~ 'AttrSet => Constructible Point tag Source # | |
Defined in GI.Graphene.Structs.Point | |
type ParentTypes Point Source # | |
Defined in GI.Graphene.Structs.Point |
Methods
Overloaded methods
alloc
:: (HasCallStack, MonadIO m) | |
=> m Point | Returns: the newly allocated |
Allocates a new Point
structure.
The coordinates of the returned point are (0, 0).
It's possible to chain this function with pointInit
or pointInitFromPoint
, e.g.:
C code
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); }
Since: 1.0
distance
:: (HasCallStack, MonadIO m) | |
=> Point |
|
-> Point |
|
-> m (Float, Float, Float) | Returns: the distance between the two points |
Computes the distance between a
and b
.
Since: 1.0
equal
:: (HasCallStack, MonadIO m) | |
=> Point |
|
-> Point |
|
-> m Bool | Returns: |
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
pointNear
instead.
Since: 1.0
free
:: (HasCallStack, MonadIO m) | |
=> Point |
|
-> m () |
Frees the resources allocated by pointAlloc
.
Since: 1.0
init
:: (HasCallStack, MonadIO m) | |
=> Point |
|
-> Float |
|
-> Float |
|
-> m Point | Returns: the initialized point |
Initializes p
to the given x
and y
coordinates.
It's safe to call this function multiple times.
Since: 1.0
initFromPoint
:: (HasCallStack, MonadIO m) | |
=> Point |
|
-> Point |
|
-> m Point | Returns: the initialized point |
Initializes p
with the same coordinates of src
.
Since: 1.0
initFromVec2
:: (HasCallStack, MonadIO m) | |
=> Point |
|
-> Vec2 |
|
-> m Point | Returns: the initialized point |
Initializes p
with the coordinates inside the given Vec2
.
Since: 1.4
interpolate
:: (HasCallStack, MonadIO m) | |
=> Point |
|
-> Point |
|
-> Double |
|
-> m Point |
Linearly interpolates the coordinates of a
and b
using the
given factor
.
Since: 1.0
near
:: (HasCallStack, MonadIO m) | |
=> Point |
|
-> Point |
|
-> Float |
|
-> m Bool | Returns: |
Checks whether the two points a
and b
are within
the threshold of epsilon
.
Since: 1.0
toVec2
:: (HasCallStack, MonadIO m) | |
=> Point |
|
-> m Vec2 |
zero
:: (HasCallStack, MonadIO m) | |
=> m Point | Returns: a fixed point |
Returns a point fixed at (0, 0).
Since: 1.0
Properties
x
the X coordinate of the point
getPointX :: MonadIO m => Point -> m Float Source #
Get the value of the “x
” field.
When overloading is enabled, this is equivalent to
get
point #x
setPointX :: MonadIO m => Point -> Float -> m () Source #
Set the value of the “x
” field.
When overloading is enabled, this is equivalent to
set
point [ #x:=
value ]
y
the Y coordinate of the point