|
| | Rect () |
| | Constructs an invalid object.
|
| | Rect (graphene_rect_t * castitem, bool make_a_copy=false) |
| | Rect (const Rect & src) |
| Rect & | operator= (const Rect & src) |
| | Rect (Rect && other) noexcept |
| Rect & | operator= (Rect && other) noexcept |
| | ~Rect () noexcept |
| void | swap (Rect & other) noexcept |
| graphene_rect_t * | gobj () |
| const graphene_rect_t * | gobj () const |
| graphene_rect_t * | gobj_copy () const |
| | Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
|
| | Rect (float x, float y, float width, float height) |
| | operator bool () const |
| | Checks if this instance is valid.
|
| Point | get_origin () const |
| void | set_origin (const Point & value) |
| Size | get_size () const |
| void | set_size (const Size & value) |
| Point | get_center () const |
| | Retrieves the coordinates of the center of the given rectangle.
|
| Point | get_top_left () const |
| | Retrieves the coordinates of the top-left corner of the given rectangle.
|
| Point | get_top_right () const |
| | Retrieves the coordinates of the top-right corner of the given rectangle.
|
| Point | get_bottom_right () const |
| | Retrieves the coordinates of the bottom-right corner of the given rectangle.
|
| Point | get_bottom_left () const |
| | Retrieves the coordinates of the bottom-left corner of the given rectangle.
|
| std::array< Vec2, 4 > | get_vertices () const |
| | Computes the four vertices of this Rect.
|
| bool | equal (const Rect & b) const |
| | Checks whether the two given rectangle are equal.
|
| void | normalize () |
| | Normalizes the passed rectangle.
|
| float | get_x () const |
| | Retrieves the normalized X coordinate of the origin of the given rectangle.
|
| float | get_y () const |
| | Retrieves the normalized Y coordinate of the origin of the given rectangle.
|
| float | get_width () const |
| | Retrieves the normalized width of the given rectangle.
|
| float | get_height () const |
| | Retrieves the normalized height of the given rectangle.
|
| float | get_area () const |
| | Compute the area of given normalized rectangle.
|
| Rect | join (const Rect & b) const |
| | Computes the union of the two rectangles.
|
| std::optional< Rect > | intersection (const Rect & b) const |
| | Computes the intersection of the two given rectangles.
|
| bool | contains_point (const Point & p) const |
| | Checks whether a #graphene_rect_t contains the given coordinates.
|
| bool | contains_rect (const Rect & b) const |
| | Checks whether a #graphene_rect_t fully contains the given rectangle.
|
| void | offset (float d_x, float d_y) |
| | Offsets the origin by d_x and d_y.
|
| void | inset (float d_x, float d_y) |
| | Changes the given rectangle to be smaller, or larger depending on the given inset parameters.
|
| Rect | round_extents () const |
| | Rounds the origin of this rectangle to its nearest integer value and recomputes the size so that the rectangle is large enough to contain all the corners of the original rectangle.
|
| Rect | interpolate (const Rect & b, double factor) const |
| | Linearly interpolates the origin and size of this rectangle and rectangle b.
|
| Rect | expand (const Point & p) const |
| | Expands this rectangle to contain the given point.
|
| Rect | scale (float s_h, float s_v) const |
| | Scales the size and origin of this rectangle horizontally by s_h, and vertically by s_v.
|
The location and size of a rectangle region.
The width and height of a Gdk::Graphene::Rect can be negative; for instance, a Gdk::Graphene::Rect with an origin of [ 0, 0 ] and a size of [ 10, 10 ] is equivalent to a Gdk::Graphene::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 Gdk::Graphene::Rect as an argument will internally operate on a normalized copy; all functions returning a Gdk::Graphene::Rect will always return a normalized rectangle.
- Since gtkmm 4.12
| void Gdk::Graphene::Rect::inset |
( |
float | d_x, |
|
|
float | 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 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 * @a d_x, 2 * @a 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.
- Since gtkmm 4.24
- Parameters
-
| d_x | The horizontal inset. |
| d_y | The vertical inset. |
| Rect Gdk::Graphene::Rect::round_extents |
( |
| ) |
const |
Rounds the origin of this rectangle to its nearest integer value and recomputes the size so that the rectangle is large enough to contain all the corners 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 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 gtkmm 4.24
- Returns
- The rectangle with rounded extents.