Class (GI Struct)

Graphene-1.0GrapheneRectSince 1.0

The location and size of a rectangle region.

The width and height of a Graphene.Rect can be negative; for instance, a Graphene.Rect with an origin of [ 0, 0 ] and a size of [ 10, 10 ] is equivalent to a Graphene.Rect 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 as an argument will internally operate on a normalized copy; all functions returning a Graphene.Rect will always return a normalized rectangle.

1.0

Index

Constructors

Properties

origin: Graphene.Point
size: Size

Methods

  • Retrieves the normalized height of the given rectangle.

    Returns number

    the normalized height of the rectangle

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

    Returns number

    the normalized X coordinate of the rectangle

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

    Returns number

    the normalized Y coordinate of the rectangle

  • Initializes the given Graphene.Rect with the given values.

    This function will implicitly normalize the Graphene.Rect before returning.

    Parameters

    • x: number

      the X coordinate of the graphene_rect_t.origin

    • y: number

      the Y coordinate of the graphene_rect_t.origin

    • width: number

      the width of the graphene_rect_t.size

    • height: number

      the height of the graphene_rect_t.size

    Returns Graphene.Rect

    the initialized rectangle

  • 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 d_x or d_y values.

    The origin of the rectangle is offset by d_x and d_y, while the size is adjusted by (2 * d_x, 2 * d_y). If d_x and d_y are 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.

    Parameters

    • d_x: number

      the horizontal inset

    • d_y: number

      the vertical inset

    Returns Graphene.Rect

    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 d_x or d_y values; to create a larger, encompassing rectangle, use negative d_x or d_y values.

    The origin of the rectangle is offset by d_x and d_y, while the size is adjusted by (2 * d_x, 2 * d_y). If d_x and d_y are 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.

    Parameters

    • d_x: number

      the horizontal inset

    • d_y: number

      the vertical inset

    Returns Graphene.Rect

  • 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 floor on the coordinates of the origin, and ceil on the size.

    Returns Graphene.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.

    Returns Graphene.Rect

  • 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.

    Returns Graphene.Rect

    the pixel-aligned rectangle.

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

    Parameters

    • s_h: number

      horizontal scale factor

    • s_v: number

      vertical scale factor

    Returns Graphene.Rect