Previous topic

efl.evas Module

Next topic

efl.evas.Canvas Class

efl.evas.Rect Class

class efl.evas.Rect

Bases: object

Type to store and manipulate rectangular coordinates.

This class provides the description of a rectangle and means to access and modify its properties in an easy way.

Usage example:

>>> r1 = Rect(10, 20, 30, 40)
>>> r2 = Rect((0, 0), (100, 100))
>>> r1
Rect(x=10, y=20, w=30, h=40)
>>> r2
Rect(x=0, y=0, w=100, h=100)
>>> r1.contains(r2)
False
>>> r2.contains(r1)
True
>>> r1 in r2 # same as r2.contains(r1)
True
>>> r1.intercepts(r2)
True

Attention

This is not a graphical object! Do not confuse with efl.evas.Rectangle.

area
Type :(int w, int h)
bottom
Type :int
bottom_left
Type :(int x, int y)
bottom_right
Type :(int x, int y)
center
Type :(int x, int y)
center_x
Type :int
center_y
Type :int
clamp(obj) → Rect

Returns a new Rect that represents current moved inside given parameter.

If given rectangle is smaller, it’ll be centered.

Parameters:obj
Return type:Rect
clip(obj) → Rect

Returns a new Rect that represents current cropped inside parameter.

Parameters:obj
Return type:Rect
contains(obj) → bool

Checks if contains given rectangle.

Parameters:obj
Return type:bool
contains_point(x, y) → bool

Checks if contains the given point.

Parameters:
  • x (int) –
  • y (int) –
Return type:

bool

h
Type :int
height
Type :int
inflate(int amount_w, int amount_h)

Returns a new Rect that represents current inflated by given amount.

Parameters:
  • amount_x (int) –
  • amount_y (int) –
Return type:

Rect

intercepts(obj) → bool

Checks if intercepts given rectangle.

Parameters:obj
Return type:bool
left
Type :int
move_by(int offset_x, int offset_y) → Rect

Returns a new Rect that represents current moved by given offsets.

Parameters:
  • offset_x (int) –
  • offset_y (int) –
Return type:

Rect

normalize()

Normalize coordinates so both width and height are positive.

pos
Type :(int x, int y)
right
Type :int
size
Type :(int w, int h)
top
Type :int
top_left
Type :(int x, int y)
top_right
Type :(int x, int y)
union(obj) → Rect

Returns a new Rect that covers both rectangles.

Parameters:obj
Return type:Rect
w
Type :int
width
Type :int
x
Type :int
y
Type :int