gi-graphene-1.0.5: Graphene bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Graphene.Structs.Rect

Description

The location and size of a rectangle region.

The width and height of a Rect can be negative; for instance, a Rect with an origin of [ 0, 0 ] and a size of [ 10, 10 ] is equivalent to a Rect with an origin of [ 10, 10 ] and a size of [ -10, -10 ].

Application code can normalize rectangles using rectNormalize; this function will ensure that the width and height of a rectangle are positive values. All functions taking a Rect as an argument will internally operate on a normalized copy; all functions returning a Rect will always return a normalized rectangle.

Since: 1.0

Synopsis

Exported types

newtype Rect Source #

Memory-managed wrapper type.

Constructors

Rect (ManagedPtr Rect) 

Instances

Instances details
Eq Rect Source # 
Instance details

Defined in GI.Graphene.Structs.Rect

Methods

(==) :: Rect -> Rect -> Bool #

(/=) :: Rect -> Rect -> Bool #

GBoxed Rect Source # 
Instance details

Defined in GI.Graphene.Structs.Rect

ManagedPtrNewtype Rect Source # 
Instance details

Defined in GI.Graphene.Structs.Rect

Methods

toManagedPtr :: Rect -> ManagedPtr Rect

TypedObject Rect Source # 
Instance details

Defined in GI.Graphene.Structs.Rect

Methods

glibType :: IO GType

HasParentTypes Rect Source # 
Instance details

Defined in GI.Graphene.Structs.Rect

tag ~ 'AttrSet => Constructible Rect tag Source # 
Instance details

Defined in GI.Graphene.Structs.Rect

Methods

new :: MonadIO m => (ManagedPtr Rect -> Rect) -> [AttrOp Rect tag] -> m Rect

IsGValue (Maybe Rect) Source #

Convert Rect to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Graphene.Structs.Rect

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe Rect -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe Rect)

type ParentTypes Rect Source # 
Instance details

Defined in GI.Graphene.Structs.Rect

type ParentTypes Rect = '[] :: [Type]

newZeroRect :: MonadIO m => m Rect Source #

Construct a Rect struct initialized to zero.

Methods

alloc

rectAlloc Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m Rect

Returns: the newly allocated rectangle

Allocates a new Rect.

The contents of the returned rectangle are undefined.

Since: 1.0

containsPoint

rectContainsPoint Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> Point

p: a Point

-> m Bool

Returns: true if the rectangle contains the point

Checks whether a Rect contains the given coordinates.

Since: 1.0

containsRect

rectContainsRect Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

a: a Rect

-> Rect

b: a Rect

-> m Bool

Returns: true if the rectangle a fully contains b

Checks whether a Rect fully contains the given rectangle.

Since: 1.0

equal

rectEqual Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

a: a Rect

-> Rect

b: a Rect

-> m Bool

Returns: true if the rectangles are equal

Checks whether the two given rectangle are equal.

Since: 1.0

expand

rectExpand Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> Point

p: a Point

-> m Rect 

Expands a Rect to contain the given Point.

Since: 1.4

free

rectFree Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m () 

Frees the resources allocated by rectAlloc.

Since: 1.0

getArea

rectGetArea Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m Float

Returns: the area of the normalized rectangle

Compute the area of given normalized rectangle.

Since: 1.10

getBottomLeft

rectGetBottomLeft Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m Point 

Retrieves the coordinates of the bottom-left corner of the given rectangle.

Since: 1.0

getBottomRight

rectGetBottomRight Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m Point 

Retrieves the coordinates of the bottom-right corner of the given rectangle.

Since: 1.0

getCenter

rectGetCenter Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m Point 

Retrieves the coordinates of the center of the given rectangle.

Since: 1.0

getHeight

rectGetHeight Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m Float

Returns: the normalized height of the rectangle

Retrieves the normalized height of the given rectangle.

Since: 1.0

getTopLeft

rectGetTopLeft Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m Point 

Retrieves the coordinates of the top-left corner of the given rectangle.

Since: 1.0

getTopRight

rectGetTopRight Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m Point 

Retrieves the coordinates of the top-right corner of the given rectangle.

Since: 1.0

getWidth

rectGetWidth Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m Float

Returns: the normalized width of the rectangle

Retrieves the normalized width of the given rectangle.

Since: 1.0

getX

rectGetX Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m Float

Returns: the normalized X coordinate of the rectangle

Retrieves the normalized X coordinate of the origin of the given rectangle.

Since: 1.0

getY

rectGetY Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m Float

Returns: the normalized Y coordinate of the rectangle

Retrieves the normalized Y coordinate of the origin of the given rectangle.

Since: 1.0

init

rectInit Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> Float

x: the X coordinate of the grapheneRectT.origin

-> Float

y: the Y coordinate of the grapheneRectT.origin

-> Float

width: the width of the grapheneRectT.size

-> Float

height: the height of the grapheneRectT.size

-> m Rect

Returns: the initialized rectangle

Initializes the given Rect with the given values.

This function will implicitly normalize the Rect before returning.

Since: 1.0

initFromRect

rectInitFromRect Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> Rect

src: a Rect

-> m Rect

Returns: the initialized rectangle

Initializes r using the given src rectangle.

This function will implicitly normalize the Rect before returning.

Since: 1.0

inset

rectInset Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> Float

dX: the horizontal inset

-> Float

dY: the vertical inset

-> m Rect

Returns: the inset rectangle

Changes the given rectangle to be smaller, or larger depending on the given inset parameters.

To create an inset rectangle, use positive dX or dY values; to create a larger, encompassing rectangle, use negative dX or dY values.

The origin of the rectangle is offset by dX and dY, while the size is adjusted by (2 * @d_x, 2 * @d_y). If dX and dY are positive values, the size of the rectangle is decreased; if dX and dY are negative values, the size of the rectangle is increased.

If the size of the resulting inset rectangle has a negative width or height then the size will be set to zero.

Since: 1.0

insetR

rectInsetR Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> Float

dX: the horizontal inset

-> Float

dY: the vertical inset

-> m Rect 

Changes the given rectangle to be smaller, or larger depending on the given inset parameters.

To create an inset rectangle, use positive dX or dY values; to create a larger, encompassing rectangle, use negative dX or dY values.

The origin of the rectangle is offset by dX and dY, while the size is adjusted by (2 * @d_x, 2 * @d_y). If dX and dY are positive values, the size of the rectangle is decreased; if dX and dY are negative values, the size of the rectangle is increased.

If the size of the resulting inset rectangle has a negative width or height then the size will be set to zero.

Since: 1.4

interpolate

rectInterpolate Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

a: a Rect

-> Rect

b: a Rect

-> Double

factor: the linear interpolation factor

-> m Rect 

Linearly interpolates the origin and size of the two given rectangles.

Since: 1.0

intersection

rectIntersection Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

a: a Rect

-> Rect

b: a Rect

-> m (Bool, Rect)

Returns: true if the two rectangles intersect

Computes the intersection of the two given rectangles.

The intersection in the image above is the blue outline.

If the two rectangles do not intersect, res will contain a degenerate rectangle with origin in (0, 0) and a size of 0.

Since: 1.0

normalize

rectNormalize Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m Rect

Returns: the normalized rectangle

Normalizes the passed rectangle.

This function ensures that the size of the rectangle is made of positive values, and that the origin is the top-left corner of the rectangle.

Since: 1.0

normalizeR

rectNormalizeR Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m Rect 

Normalizes the passed rectangle.

This function ensures that the size of the rectangle is made of positive values, and that the origin is in the top-left corner of the rectangle.

Since: 1.4

offset

rectOffset Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> Float

dX: the horizontal offset

-> Float

dY: the vertical offset

-> m Rect

Returns: the offset rectangle

Offsets the origin by dX and dY.

The size of the rectangle is unchanged.

Since: 1.0

offsetR

rectOffsetR Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> Float

dX: the horizontal offset

-> Float

dY: the vertical offset

-> m Rect 

Offsets the origin of the given rectangle by dX and dY.

The size of the rectangle is left unchanged.

Since: 1.4

round

rectRound Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m Rect 

Deprecated: (Since version 1.10)Use rectRoundExtents instead

Rounds the origin and size of the given rectangle to their nearest integer values; the rounding is guaranteed to be large enough to have an area bigger or equal to the original rectangle, but might not fully contain its extents. Use rectRoundExtents in case you need to round to a rectangle that covers fully the original one.

This function is the equivalent of calling floor on the coordinates of the origin, and ceil on the size.

Since: 1.4

roundExtents

rectRoundExtents Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m Rect 

Rounds the origin of the given rectangle to its nearest integer value and and recompute the size so that the rectangle is large enough to contain all the conrners of the original rectangle.

This function is the equivalent of calling floor on the coordinates of the origin, and recomputing the size calling ceil on the bottom-right coordinates.

If you want to be sure that the rounded rectangle completely covers the area that was covered by the original rectangle — i.e. you want to cover the area including all its corners — this function will make sure that the size is recomputed taking into account the ceiling of the coordinates of the bottom-right corner. If the difference between the original coordinates and the coordinates of the rounded rectangle is greater than the difference between the original size and and the rounded size, then the move of the origin would not be compensated by a move in the anti-origin, leaving the corners of the original rectangle outside the rounded one.

Since: 1.10

roundToPixel

rectRoundToPixel Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> m Rect

Returns: the pixel-aligned rectangle.

Deprecated: (Since version 1.4)Use rectRound instead

Rounds the origin and the size of the given rectangle to their nearest integer values; the rounding is guaranteed to be large enough to contain the original rectangle.

Since: 1.0

scale

rectScale Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

r: a Rect

-> Float

sH: horizontal scale factor

-> Float

sV: vertical scale factor

-> m Rect 

Scales the size and origin of a rectangle horizontaly by sH, and vertically by sV. The result res is normalized.

Since: 1.10

union

rectUnion Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Rect

a: a Rect

-> Rect

b: a Rect

-> m Rect 

Computes the union of the two given rectangles.

The union in the image above is the blue outline.

Since: 1.0

zero

rectZero Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m Rect

Returns: a fixed rectangle

Returns a degenerate rectangle with origin fixed at (0, 0) and a size of 0, 0.

Since: 1.4

Properties

origin

the coordinates of the origin of the rectangle

getRectOrigin :: MonadIO m => Rect -> m Point Source #

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

get rect #origin

size

the size of the rectangle

getRectSize :: MonadIO m => Rect -> m Size Source #

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

get rect #size