Clutter.Rect¶
Fields¶
Name |
Type |
Access |
Description |
|---|---|---|---|
origin |
r/w |
the origin of the rectangle |
|
size |
r/w |
the size of the rectangle |
Methods¶
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class Clutter.Rect¶
The location and size of a rectangle.
The width and height of a
Clutter.Rectcan be negative; Clutter considers a rectangle with an origin of [ 0.0, 0.0 ] and a size of [ 10.0, 10.0 ] to be equivalent to a rectangle with origin of [ 10.0, 10.0 ] and size of [ -10.0, -10.0 ].Application code can normalize rectangles using
Clutter.Rect.normalize(): this function will ensure that the width and height of aClutter.Rectare positive values. All functions taking aClutter.Rectas an argument will implicitly normalize it before computing eventual results. For this reason it is safer to access the contents of aClutter.Rectby using the provided API at all times, instead of directly accessing the structure members.New in version 1.12.
- classmethod alloc()¶
- Returns:
the newly allocated
Clutter.Rect. UseClutter.Rect.free() to free its resources- Return type:
Creates a new, empty
Clutter.Rect.You can use
Clutter.Rect.init() to initialize the returned rectangle, for instance:rect = clutter_rect_init (clutter_rect_alloc (), x, y, width, height);New in version 1.12.
- classmethod zero()¶
- Returns:
a rectangle with origin in (0, 0) and a size of 0. The returned
Clutter.Rectis owned by Clutter and it should not be modified or freed.- Return type:
A
Clutter.Rectwith Clutter.Rect.origin set at (0, 0) and a size of 0.The returned value can be used as a guard.
New in version 1.12.
- clamp_to_pixel()¶
Rounds the origin of self downwards to the nearest integer, and rounds the size of self upwards to the nearest integer, so that self is updated to the smallest rectangle capable of fully containing the original, fractional rectangle.
New in version 1.12.
- contains_point(point)¶
- Parameters:
point (
Clutter.Point) – the point to check- Returns:
Trueif the point is contained by self.- Return type:
Checks whether point is contained by self, after normalizing the rectangle.
New in version 1.12.
- contains_rect(b)¶
- Parameters:
b (
Clutter.Rect) – aClutter.Rect- Returns:
Trueif the first rectangle contains the second.- Return type:
Checks whether self contains b.
The first rectangle contains the second if the union of the two
Clutter.Rectis equal to the first rectangle.New in version 1.12.
- copy()¶
- Returns:
the newly allocate copy of self. Use
Clutter.Rect.free() to free the associated resources- Return type:
Copies self into a new
Clutter.Rectinstance.New in version 1.12.
- equals(b)¶
- Parameters:
b (
Clutter.Rect) – aClutter.Rect- Returns:
Trueif the rectangles match in origin and size.- Return type:
Checks whether self and b are equals.
This function will normalize both self and b before comparing their origin and size.
New in version 1.12.
- free()¶
Frees the resources allocated by self.
New in version 1.12.
- get_center()¶
- Returns:
- Return type:
center:
Clutter.Point
Retrieves the center of self, after normalizing the rectangle, and updates center with the correct coordinates.
New in version 1.12.
- get_height()¶
- Returns:
the height of the rectangle
- Return type:
Retrieves the height of self.
New in version 1.12.
- get_width()¶
- Returns:
the width of the rectangle
- Return type:
Retrieves the width of self.
New in version 1.12.
- get_x()¶
- Returns:
the X coordinate of the origin of the rectangle
- Return type:
Retrieves the X coordinate of the origin of self.
New in version 1.12.
- get_y()¶
- Returns:
the Y coordinate of the origin of the rectangle
- Return type:
Retrieves the Y coordinate of the origin of self.
New in version 1.12.
- init(x, y, width, height)¶
- Parameters:
- Returns:
the updated rectangle
- Return type:
Initializes a
Clutter.Rectwith the given origin and size.New in version 1.12.
- inset(d_x, d_y)¶
- Parameters:
Normalizes the self and offsets its origin by the d_x and d_y values; the size is adjusted by (2 * d_x, 2 * d_y).
If d_x and d_y are positive the size of the rectangle is decreased; if the values are negative, the size of the rectangle is increased.
If the resulting rectangle has a negative width or height, the size is set to 0.
New in version 1.12.
- intersection(b)¶
- Parameters:
b (
Clutter.Rect) – aClutter.Rect- Returns:
Trueif the intersection of self and b is not empty- res:
a
Clutter.Rect, orNone
- Return type:
(
bool, res:Clutter.Rect)
Computes the intersection of self and b, and places it in res, if res is not
None.This function will normalize both self and b prior to computing their intersection.
This function can be used to simply check if the intersection of self and b is not empty, by using
Nonefor res.New in version 1.12.
- normalize()¶
- Return type:
Normalizes a
Clutter.Rect.A
Clutter.Rectis defined by the area covered by its size; this means that aClutter.Rectwith Clutter.Rect.origin in [ 0, 0 ] and a Clutter.Rect.size of [ 10, 10 ] is equivalent to aClutter.Rectwith Clutter.Rect.origin in [ 10, 10 ] and a Clutter.Rect.size of [ -10, -10 ].This function is useful to ensure that a rectangle has positive width and height; it will modify the passed self and normalize its size.
New in version 1.12.
- offset(d_x, d_y)¶
-
Offsets the origin of self by the given values, after normalizing the rectangle.
New in version 1.12.
- union(b)¶
- Parameters:
b (
Clutter.Rect) – aClutter.Rect- Returns:
- Return type:
res:
Clutter.Rect
Computes the smallest possible rectangle capable of fully containing both self and b, and places it into res.
This function will normalize both self and b prior to computing their union.
New in version 1.12.