Basics
Guides
API Reference
Basics
Guides
API Reference
[12:14] static extends: object
Generated struct layout helper for GIR record Rect.
layout ()
Returns the Panama struct layout for
Rect.
[36:7] extends: object
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_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.
GrapheneRect (Handle = null)
Creates a new
Rectby wrapping a native handle or another wrapper.
Handle is the native handle or another wrapper whose handle to adopt.toNativeHandle (Source)
Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from
fn.call(...), another generated wrapper exposinghandle(), or null. Returns null when the argument carries no pointer.
Source is the raw handle, raw buffer, wrapper, or null.A raw pointer carrier or null when no pointer is present.getLib ()
Returns the opened native library for this generated wrapper.
The opened native library.handle ()
Returns the wrapped NativeHandle.
The wrapped NativeHandle.isNull ()
Returns true when the wrapped handle is null.
A bool.describe ()
Returns a small string for debugging generated wrappers.
A string.contains_point (object p)
Checks whether a #graphene_rect_t contains the given coordinates.
p is a #graphene_point_t.true if the rectangle contains the point.contains_rect (object b)
Checks whether a #graphene_rect_t fully contains the given rectangle.
b is a #graphene_rect_t.true if the rectangle @a fully contains @b.equal (object b)
Checks whether the two given rectangle are equal.
b is a #graphene_rect_t.true if the rectangles are equal.expand (object p)
Expands a #graphene_rect_t to contain the given #graphene_point_t.
p is a #graphene_point_t.res is return location for the expanded rectangle.None.free ()
Frees the resources allocated by graphene_rect_alloc().
None.get_area ()
Compute the area of given normalized rectangle.
the area of the normalized rectangle.get_bottom_left ()
Retrieves the coordinates of the bottom-left corner of the given rectangle.
p is return location for a #graphene_point_t.None.get_bottom_right ()
Retrieves the coordinates of the bottom-right corner of the given rectangle.
p is return location for a #graphene_point_t.None.get_center ()
Retrieves the coordinates of the center of the given rectangle.
p is return location for a #graphene_point_t.None.get_height ()
Retrieves the normalized height of the given rectangle.
the normalized height of the rectangle.get_top_left ()
Retrieves the coordinates of the top-left corner of the given rectangle.
p is return location for a #graphene_point_t.None.get_top_right ()
Retrieves the coordinates of the top-right corner of the given rectangle.
p is return location for a #graphene_point_t.None.get_vertices ()
Computes the four vertices of a #graphene_rect_t.
vertices is return location for an array of 4 #graphene_vec2_t.None.get_width ()
Retrieves the normalized width of the given rectangle.
the normalized width of the rectangle.get_x ()
Retrieves the normalized X coordinate of the origin of the given rectangle.
the normalized X coordinate of the rectangle.get_y ()
Retrieves the normalized Y coordinate of the origin of the given rectangle.
the normalized Y coordinate of the rectangle.init (double x, double y, double width, double height)
Initializes the given #graphene_rect_t with the given values. This function will implicitly normalize the #graphene_rect_t before returning.
x is the X coordinate of the @graphene_rect_t.origin.y is the Y coordinate of the @graphene_rect_t.origin.width is the width of the @graphene_rect_t.size.height is the height of the @graphene_rect_t.size.the initialized rectangle.init_from_rect (object src)
Initializes @r using the given @src rectangle. This function will implicitly normalize the #graphene_rect_t before returning.
src is a #graphene_rect_t.the initialized rectangle.inset (double d_x, double d_y)
Changes the given rectangle to be smaller, or larger depending on the given inset parameters. To create an inset rectangle, use positive @d_x or @d_y values; to create a larger, encompassing rectangle, use negative
or @d_y values. The origin of the rectangle is offset by @d_x andwhile the size is adjusted by (2 * @d_x, 2 * @d_y). If @d_x andare positive values, the size of the rectangle is decreased; if @d_x and @d_y 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.d_x is the horizontal inset.d_y is the vertical inset.the inset rectangle.inset_r (double d_x, double d_y)
Changes the given rectangle to be smaller, or larger depending on the given inset parameters. To create an inset rectangle, use positive @d_x or @d_y values; to create a larger, encompassing rectangle, use negative
or @d_y values. The origin of the rectangle is offset by @d_x andwhile the size is adjusted by (2 * @d_x, 2 * @d_y). If @d_x andare positive values, the size of the rectangle is decreased; if @d_x and @d_y 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.d_x is the horizontal inset.d_y is the vertical inset.res is return location for the inset rectangle.None.interpolate (object b, double factor)
Linearly interpolates the origin and size of the two given rectangles.
b is a #graphene_rect_t.factor is the linear interpolation factor.res is return location for the interpolated rectangle.None.intersection (object b)
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.
b is a #graphene_rect_t.res is return location for a #graphene_rect_t.true if the two rectangles intersect.normalize ()
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.
the normalized rectangle.normalize_r ()
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.
res is the return location for the normalized rectangle.None.offset (double d_x, double d_y)
Offsets the origin by @d_x and @d_y. The size of the rectangle is unchanged.
d_x is the horizontal offset.d_y is the vertical offset.the offset rectangle.offset_r (double d_x, double d_y)
Offsets the origin of the given rectangle by @d_x and @d_y. The size of the rectangle is left unchanged.
d_x is the horizontal offset.d_y is the vertical offset.res is return location for the offset rectangle.None.round ()
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_round_extents() in case you need to round to a rectangle that covers fully the original one. This function is the equivalent of calling
flooron the coordinates of the origin, andceilon the size.
res is return location for the rounded rectangle.None.round_extents ()
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
flooron the coordinates of the origin, and recomputing the size callingceilon 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.
res is return location for the rectangle with rounded extents.None.round_to_pixel ()
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.
the pixel-aligned rectangle..scale (double s_h, double s_v)
Scales the size and origin of a rectangle horizontaly by @s_h, and vertically by @s_v. The result @res is normalized.
s_h is horizontal scale factor.s_v is vertical scale factor.res is return location for the scaled rectangle.None.union (object b)
Computes the union of the two given rectangles.
The union in the image above is the blue outline.
b is a #graphene_rect_t.res is return location for a #graphene_rect_t.None.
Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.
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.
The union in the image above is the blue outline.