Package evas :: Module c_evas :: Class Rect
[hide private]
[frames] | no frames]

Class Rect

object --+
         |
        Rect

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.

Useful properties are:

Useful methods are:

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 Rectangle.

Instance Methods [hide private]
 
__contains__(x, y)
y in x
 
__eq__(x, y)
x==y
 
__ge__(x, y)
x>=y
 
__gt__(x, y)
x>y
 
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
__le__(x, y)
x<=y
 
__lt__(x, y)
x<y
 
__ne__(x, y)
x!=y
a new object with type S, a subtype of T
__new__(T, S, ...)
 
__nonzero__(x)
x != 0
 
__repr__(...)
repr(x)
 
__str__(...)
str(x)
 
clamp(...)
Returns a new Rect that represents current moved inside given parameter.
 
clip(...)
Returns a new Rect that represents current cropped inside parameter.
 
contains(...)
Checks if contains given rectangle.
 
contains_point(...)
Checks if contains the given point.
 
inflate(...)
Returns a new Rect that represents current inflated by given amount.
 
intercepts(...)
Checks if intercepts given rectangle.
 
move_by(...)
Returns a new Rect that represents current moved by given offsets.
 
normalize(...)
Normalize coordinates so both width and height are positive.
 
union(...)
Returns a new Rect that covers both rectangles.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]
  area
  bottom
  bottom_left
  bottom_right
  center
  center_x
  center_y
  h
  height
  left
  pos
  right
  size
  top
  top_left
  top_right
  w
  width
  x
  y

Inherited from object: __class__

Method Details [hide private]

__init__(...)
(Constructor)

 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__

__new__(T, S, ...)

 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__

__repr__(...)
(Representation operator)

 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__str__(...)
(Informal representation operator)

 

str(x)

Overrides: object.__str__
(inherited documentation)

clamp(...)

 

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

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