efl.evas.Rect Class

class efl.evas.Rect(*args, **kargs)

Bases: object

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)

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)

Returns a new Rect that represents current cropped inside parameter.

Parameters:obj
Return type:Rect
contains(obj)

Checks if this rectangle contains given rectangle.

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

Checks if this rectangle contains the given point.

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

bool

cx

cx: ‘int’

cy

cy: ‘int’

h
Type:int
height
Type:int
inflate(amount_w, 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)

Deprecated since version 1.14: Use intersects() instead

intersects(obj)

Checks if this rectangle and the given rectangle intersect.

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

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)

Returns a new Rect that covers both rectangles.

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

x0: ‘int’

x1

x1: ‘int’

y
Type:int
y0

y0: ‘int’

y1

y1: ‘int’