Rect

The location and size of a rectangle region.

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

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

Members

Functions

containsPoint
bool containsPoint(graphene.point.Point p)

Checks whether a #graphene_rect_t contains the given coordinates.

containsRect
bool containsRect(graphene.rect.Rect b)

Checks whether a #graphene_rect_t fully contains the given rectangle.

equal
bool equal(graphene.rect.Rect b)

Checks whether the two given rectangle are equal.

expand
void expand(graphene.point.Point p, graphene.rect.Rect res)

Expands a #graphene_rect_t to contain the given #graphene_point_t.

getArea
float getArea()

Compute the area of given normalized rectangle.

getBottomLeft
void getBottomLeft(graphene.point.Point p)

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

getBottomRight
void getBottomRight(graphene.point.Point p)

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

getCenter
void getCenter(graphene.point.Point p)

Retrieves the coordinates of the center of the given rectangle.

getHeight
float getHeight()

Retrieves the normalized height of the given rectangle.

getTopLeft
void getTopLeft(graphene.point.Point p)

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

getTopRight
void getTopRight(graphene.point.Point p)

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

getVertices
void getVertices(graphene.vec2.Vec2[] vertices)

Computes the four vertices of a #graphene_rect_t.

getWidth
float getWidth()

Retrieves the normalized width of the given rectangle.

getX
float getX()

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

getY
float getY()

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

initFromRect
graphene.rect.Rect initFromRect(graphene.rect.Rect src)

Initializes r using the given src rectangle.

init_
graphene.rect.Rect init_(float x, float y, float width, float height)

Initializes the given #graphene_rect_t with the given values.

inset
graphene.rect.Rect inset(float dX, float dY)

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

insetR
void insetR(float dX, float dY, graphene.rect.Rect res)

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

interpolate
void interpolate(graphene.rect.Rect b, double factor, graphene.rect.Rect res)

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

intersection
bool intersection(graphene.rect.Rect b, graphene.rect.Rect res)

Computes the intersection of the two given rectangles.

normalize
graphene.rect.Rect normalize()

Normalizes the passed rectangle.

normalizeR
void normalizeR(graphene.rect.Rect res)

Normalizes the passed rectangle.

offset
graphene.rect.Rect offset(float dX, float dY)

Offsets the origin by d_x and d_y.

offsetR
void offsetR(float dX, float dY, graphene.rect.Rect res)

Offsets the origin of the given rectangle by d_x and d_y.

round
void round(graphene.rect.Rect res)

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 graphene.rect.Rect.roundExtents in case you need to round to a rectangle that covers fully the original one.

roundExtents
void roundExtents(graphene.rect.Rect res)

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.

roundToPixel
graphene.rect.Rect roundToPixel()

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.

scale
void scale(float sH, float sV, graphene.rect.Rect res)

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

union_
void union_(graphene.rect.Rect b, graphene.rect.Rect res)

Computes the union of the two given rectangles.

Static functions

alloc
graphene.rect.Rect alloc()

Allocates a new #graphene_rect_t.

zero
graphene.rect.Rect zero()

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

Inherited Members

From Boxed

cInstancePtr
void* cInstancePtr;

Pointer to the C boxed value

getType
GType getType()

Get the GType of this boxed type.

gType
GType gType [@property getter]

Boxed GType property.

self
Boxed self()

Convenience method to return this cast to a type. For use in D with statements.

copy_
void* copy_()

Make a copy of the wrapped C boxed data.

boxedCopy
void* boxedCopy(void* cBoxed)

Copy a C boxed value using g_boxed_copy.

boxedFree
void boxedFree(void* cBoxed)

Free a C boxed value using g_boxed_free.