Rect
Object Hierarchy:
Description:
[ CCode ( cname = "graphene_rect_t" , copy_function = "g_boxed_copy" , free_function = "g_boxed_free" , type_id = "graphene_rect_get_type ()" ) ]
[ Version ( since = "1.0" ) ]
public struct Rect
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 normalize; 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.
Content:
Static methods:
Methods:
- public bool contains_point (Point p)
Checks whether a Rect contains the given
coordinates.
- public bool contains_rect (Rect b)
Checks whether a Rect fully contains the
given rectangle.
- public bool equal (Rect b)
Checks whether the two given rectangle are equal.
- public Rect expand (Point p)
Expands a Rect to contain the given
Point.
- public float get_area ()
Compute the area of given normalized rectangle.
- public Point get_bottom_left ()
Retrieves the coordinates of the bottom-left corner of the given
rectangle.
- public Point get_bottom_right ()
Retrieves the coordinates of the bottom-right corner of the given
rectangle.
- public Point get_center ()
Retrieves the coordinates of the center of the given rectangle.
- public float get_height ()
Retrieves the normalized height of the given rectangle.
- public Point get_top_left ()
Retrieves the coordinates of the top-left corner of the given
rectangle.
- public Point get_top_right ()
Retrieves the coordinates of the top-right corner of the given
rectangle.
- public void get_vertices (ref Vec2[] vertices)
Computes the four vertices of a Rect.
- public float get_width ()
Retrieves the normalized width of the given rectangle.
- public float get_x ()
Retrieves the normalized X coordinate of the origin of the given
rectangle.
- public float get_y ()
Retrieves the normalized Y coordinate of the origin of the given
rectangle.
- public unowned Rect? init (float x, float y, float width, float height)
Initializes the given Rect with the given
values.
- public unowned Rect? init_from_rect (Rect src)
Initializes this using the given
src rectangle.
- public unowned Rect? inset (float d_x, float d_y)
Changes the given rectangle to be smaller, or larger depending on the
given inset parameters.
- public Rect inset_r (float d_x, float d_y)
Changes the given rectangle to be smaller, or larger depending on the
given inset parameters.
- public Rect interpolate (Rect b, double factor)
Linearly interpolates the origin and size of the two given rectangles.
- public bool intersection (Rect b, out Rect res)
Computes the intersection of the two given rectangles.
- public unowned Rect? normalize ()
Normalizes the passed rectangle.
- public Rect normalize_r ()
Normalizes the passed rectangle.
- public unowned Rect? offset (float d_x, float d_y)
Offsets the origin by d_x and d_y.
- public Rect offset_r (float d_x, float d_y)
Offsets the origin of the given rectangle by d_x and
d_y.
- public Rect 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.
- public Rect 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.
- public unowned Rect? 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.
- public Rect scale (float s_h, float s_v)
Scales the size and origin of a rectangle horizontaly by s_h
, and vertically by s_v.
- public Rect union (Rect b)
Computes the union of the two given rectangles.
Fields: