Clutter.Rect

Fields

Name

Type

Access

Description

origin

Clutter.Point

r/w

the origin of the rectangle

size

Clutter.Size

r/w

the size of the rectangle

Methods

class

alloc ()

class

zero ()

clamp_to_pixel ()

contains_point (point)

contains_rect (b)

copy ()

equals (b)

free ()

get_center ()

get_height ()

get_width ()

get_x ()

get_y ()

init (x, y, width, height)

inset (d_x, d_y)

intersection (b)

normalize ()

offset (d_x, d_y)

union (b)

Details

class Clutter.Rect

The location and size of a rectangle.

The width and height of a Clutter.Rect can 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 a Clutter.Rect are positive values. All functions taking a Clutter.Rect as an argument will implicitly normalize it before computing eventual results. For this reason it is safer to access the contents of a Clutter.Rect by 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. Use Clutter.Rect.free() to free its resources

Return type:

Clutter.Rect

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.Rect is owned by Clutter and it should not be modified or freed.

Return type:

Clutter.Rect

A Clutter.Rect with 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:

True if the point is contained by self.

Return type:

bool

Checks whether point is contained by self, after normalizing the rectangle.

New in version 1.12.

contains_rect(b)
Parameters:

b (Clutter.Rect) – a Clutter.Rect

Returns:

True if the first rectangle contains the second.

Return type:

bool

Checks whether self contains b.

The first rectangle contains the second if the union of the two Clutter.Rect is 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:

Clutter.Rect

Copies self into a new Clutter.Rect instance.

New in version 1.12.

equals(b)
Parameters:

b (Clutter.Rect) – a Clutter.Rect

Returns:

True if the rectangles match in origin and size.

Return type:

bool

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:

a Clutter.Point

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:

float

Retrieves the height of self.

New in version 1.12.

get_width()
Returns:

the width of the rectangle

Return type:

float

Retrieves the width of self.

New in version 1.12.

get_x()
Returns:

the X coordinate of the origin of the rectangle

Return type:

float

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:

float

Retrieves the Y coordinate of the origin of self.

New in version 1.12.

init(x, y, width, height)
Parameters:
  • x (float) – X coordinate of the origin

  • y (float) – Y coordinate of the origin

  • width (float) – width of the rectangle

  • height (float) – height of the rectangle

Returns:

the updated rectangle

Return type:

Clutter.Rect

Initializes a Clutter.Rect with the given origin and size.

New in version 1.12.

inset(d_x, d_y)
Parameters:
  • d_x (float) – an horizontal value; a positive d_x will create an inset rectangle, and a negative value will create a larger rectangle

  • d_y (float) – a vertical value; a positive d_x will create an inset rectangle, and a negative value will create a larger rectangle

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) – a Clutter.Rect

Returns:

True if the intersection of self and b is not empty

res:

a Clutter.Rect, or None

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 None for res.

New in version 1.12.

normalize()
Return type:

Clutter.Rect

Normalizes a Clutter.Rect.

A Clutter.Rect is defined by the area covered by its size; this means that a Clutter.Rect with Clutter.Rect.origin in [ 0, 0 ] and a Clutter.Rect.size of [ 10, 10 ] is equivalent to a Clutter.Rect with 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)
Parameters:
  • d_x (float) – the horizontal offset value

  • d_y (float) – the vertical offset value

Offsets the origin of self by the given values, after normalizing the rectangle.

New in version 1.12.

union(b)
Parameters:

b (Clutter.Rect) – a Clutter.Rect

Returns:

a Clutter.Rect

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.