gi-graphene-1.0.8: Graphene bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Graphene.Structs.Point

Contents

- Exported types
- Methods
  - alloc
  - distance
  - equal
  - free
  - init
  - initFromPoint
  - initFromVec2
  - interpolate
  - near
  - toVec2
  - zero
- Properties
  - x
  - y

Description

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

newtype Point Source #

Memory-managed wrapper type.

Constructors

Point (ManagedPtr Point) |

#### Instances

Instances details

Eq Point Source # |
Instance details Defined in GI.Graphene.Structs.Point Methods (==) :: Point -> Point -> Bool Source # (/=) :: Point -> Point -> Bool Source #
GBoxed Point Source # |
Instance details Defined in GI.Graphene.Structs.Point
ManagedPtrNewtype Point Source # |
Instance details Defined in GI.Graphene.Structs.Point Methods toManagedPtr :: Point -> ManagedPtr Point Source #
TypedObject Point Source # |
Instance details Defined in GI.Graphene.Structs.Point Methods glibType :: IO GType Source #
HasParentTypes Point Source # |
Instance details Defined in GI.Graphene.Structs.Point
tag ~ 'AttrSet => Constructible Point tag Source # |
Instance details Defined in GI.Graphene.Structs.Point Methods new :: MonadIO m => (ManagedPtr Point -> Point) -> [AttrOp Point tag] -> m Point Source #
IsGValue (Maybe Point) Source # | Convert `Point` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Graphene.Structs.Point Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe Point -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe Point) Source #
type ParentTypes Point Source # |
Instance details Defined in GI.Graphene.Structs.Point type ParentTypes Point = '[] :: [Type]

newZeroPoint :: MonadIO m => m Point Source #

Construct a `Point` struct initialized to zero.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

distance, equal, free, init, initFromPoint, initFromVec2, interpolate, near, toVec2.

#### Getters

None.

#### Setters

None.

## alloc

pointAlloc Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> m Point | Returns: the newly allocated `Point`. Use `pointFree` to free the resources allocated by this function.

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

pointDistance Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Point | `a`: a `Point`
-> Point | `b`: a `Point`
-> m (Float, Float, Float) | Returns: the distance between the two points

Computes the distance between `a` and `b`.

Since: 1.0

## equal

pointEqual Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Point | `a`: a `Point`
-> Point | `b`: a `Point`
-> m Bool | Returns: `true` if the points have the same coordinates

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

pointFree Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Point | `p`: a `Point`
-> m () |

Frees the resources allocated by `pointAlloc`.

Since: 1.0

## init

pointInit Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Point | `p`: a `Point`
-> Float | `x`: the X coordinate
-> Float | `y`: the Y coordinate
-> 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

pointInitFromPoint Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Point | `p`: a `Point`
-> Point | `src`: the `Point` to use
-> m Point | Returns: the initialized point

Initializes `p` with the same coordinates of `src`.

Since: 1.0

## initFromVec2

pointInitFromVec2 Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Point | `p`: the `Point` to initialize
-> Vec2 | `src`: a `Vec2`
-> m Point | Returns: the initialized point

Initializes `p` with the coordinates inside the given `Vec2`.

Since: 1.4

## interpolate

pointInterpolate Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Point | `a`: a `Point`
-> Point | `b`: a `Point`
-> Double | `factor`: the linear interpolation factor
-> m Point |

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

Since: 1.0

## near

pointNear Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Point | `a`: a `Point`
-> Point | `b`: a `Point`
-> Float | `epsilon`: threshold between the two points
-> m Bool | Returns: `true` if the distance is within `epsilon`

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

Since: 1.0

## toVec2

pointToVec2 Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Point | `p`: a `Point`
-> m Vec2 |

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

Since: 1.4

## zero

pointZero Source #

Arguments

:: (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

getPointY :: MonadIO m => Point -> m Float Source #

Get the value of the “`y`” field. When overloading is enabled, this is equivalent to

    get point #y

setPointY :: MonadIO m => Point -> Float -> m () Source #

Set the value of the “`y`” field. When overloading is enabled, this is equivalent to

    set point [ #y := value ]