Region
Region — Representing a pixel-aligned area
class Region()
Region is a simple graphical data type representing an area of integer-aligned rectangles. They are often used on raster surfaces to track areas of interest, such as change or clip areas.
- class cairo.Region([rectangle_int|rectangle_ints])
- Parameters:
rectangle_int (
RectangleInt
or [RectangleInt
]) – a rectangle or a list of rectangle
Allocates a new empty region object or a region object with the containing rectangle(s).
New in version 1.11.0.
- copy()
-
Allocates a new Region object copying the area from original.
- get_extents()
- Returns:
The bounding rectangle of region
- Return type:
- num_rectangles()
- Returns:
The number of rectangles contained in region
- Return type:
int
- get_rectangle(nth)
- Parameters:
nth (int) – a number indicating which rectangle should be returned
- Returns:
The nth rectangle from the region
- Return type:
- is_empty()
- Returns:
Whether region is empty
- Return type:
bool
- contains_point(x, y)
- Parameters:
x (int) – The x coordinate of a point
y (int) – The y coordinate of a point
- Returns:
Whether (x , y) is contained in the region
- Return type:
bool
- contains_rectangle(rectangle)
- Parameters:
rectangle (RectangleInt) –
- Returns:
region overlap
- Return type:
Checks whether rectangle is inside, outside or partially contained in region
- equal(region)
- Parameters:
region (Region) –
- Returns:
Whether both regions contained the same coverage
- Return type:
bool
- translate(dx, dy)
- Parameters:
dx (int) – Amount to translate in the x direction
dy (int) – Amount to translate in the y direction
Translates region by (dx , dy ).
- intersect(other)
- Parameters:
other (
Region
orRectangleInt
) –- Returns:
The intersection of the region and the passed region or rectangle
- Return type:
- subtract(other)
- Parameters:
other (
Region
orRectangleInt
) –- Returns:
The result of the subtraction of the region and the passed region or rectangle
- Return type:
- union(other)
- Parameters:
other (
Region
orRectangleInt
) –- Returns:
The union of the region and the passed region or rectangle
- Return type:
- xor(other)
- Parameters:
other (
Region
orRectangleInt
) –- Returns:
The exclusive difference of the region and the passed region or rectangle
- Return type:
class RectangleInt()
RectangleInt is a data structure for holding a rectangle with integer coordinates.
- class cairo.RectangleInt(x=0, y=0, width=0, height=0)
- Parameters:
x (int) – X coordinate of the left side of the rectangle
y (int) – Y coordinate of the the top side of the rectangle
width (int) – width of the rectangle
height (int) – height of the rectangle
Allocates a new RectangleInt object.
New in version 1.11.0.
- x
int
- y
int
- width
int
- height
int