vecrec.accept_anything_as_rectangle

vecrec.accept_anything_as_rectangle(function)[source]

Method decorator that converts an argument to a rectangle.

Example:

>>> import vecrec
>>> from collections import namedtuple
>>> class MyClass:
...     @vecrec.accept_anything_as_rectangle
...     def f(self, r):
...         return r
... 
>>> ShapeLike = namedtuple('_', 'bottom left width height')
>>> shape = ShapeLike(1, 2, 3, 4)
>>> x = MyClass()
>>> x.f(shape)
Rect(2.000000, 1.000000, 3.000000, 4.000000)