Package horizons :: Package util :: Package shapes :: Module rect :: Class Rect
[hide private]
[frames] | no frames]

Class Rect

source code

Shape --+
        |
       Rect

Instance Methods [hide private]
 
__init__(self, *args) source code
 
height(self) source code
 
width(self) source code
 
copy(self) source code
 
get_radius_coordinates(self, radius, include_self=False)
Returns list of all coordinates (as tuples), that are in the radius This is a generator.
source code
 
center(self)
Returns the center point of the rect.
source code
 
__contains__(self, point) source code
 
contains(self, point)
Returns if this rect (self) contains the point.
source code
 
contains_without_border(self, point)
Same as contains, see iter_without_border for difference
source code
 
contains_tuple(self, tup)
Same as contains, but takes a tuple (x, y) as parameter (overloaded function)
source code
 
intersect(self, rect)
Returns a rect that is the intersection of this rect and the rect parameter.
source code
 
intersects(self, rect)
Returns if the rectangle intersects with the rect parameter.
source code
 
get_corners(self)
Returns corners of rect in this order: topleft topright bottomright bottomleft
source code
 
get_surrounding(self, include_corners=True)
Returns neighboring coords of the rect.
source code
 
__str__(self) source code
 
__eq__(self, other) source code
 
__ne__(self, other) source code
 
__lt__(self, other) source code
 
__hash__(self) source code
 
tuple_iter(self)
Generates an iterator, that returns tuples
source code
 
iter_without_border(self)
There are 2 possible interpretations about what *width* means.
source code
    Inherited from Shape
 
__iter__(self)
Return all coordinates in the shape as points.
source code
 
distance(self, other) source code
 
get_coordinates(self)
Return all coordinates in the shape.
source code
 
get_distance_function(self, other) source code
Class Methods [hide private]
 
init_from_borders(cls, left, top, right, bottom) source code
 
init_from_topleft_and_size(cls, x, y, width, height) source code
 
init_from_topleft_and_size_tuples(cls, coords, size) source code
 
init_from_corners(cls, point1, point2)
Init rect with 2 points interpreted as 2 corner points
source code
 
get_surrounding_offsets(cls, size) source code
Method Details [hide private]

height(self)

source code 
Decorators:
  • @property

width(self)

source code 
Decorators:
  • @property

get_radius_coordinates(self, radius, include_self=False)

source code 

Returns list of all coordinates (as tuples), that are in the radius This is a generator.

Parameters:
  • include_self - whether to include coords in self

center(self)

source code 

Returns the center point of the rect. Implemented with integer division, which means the upper left is preferred.

Decorators:
  • @property

contains(self, point)

source code 

Returns if this rect (self) contains the point.

Parameters:
  • point - Point that is checked to be in this rect
Returns:
Returns whether the Point point is in this rect (self).

intersect(self, rect)

source code 

Returns a rect that is the intersection of this rect and the rect parameter.

Parameters:
  • rect - Rect that will be intersected with this rect.
Returns:
A Rect which is the intersection of self and rect or None if the intersection is empty.

intersects(self, rect)

source code 

Returns if the rectangle intersects with the rect parameter.

Parameters:
  • rect - Rect that will be intersected with this rect.
Returns:
A bool.

get_corners(self)

source code 

Returns corners of rect in this order: topleft topright bottomright bottomleft

Returns:
tuple of coord-tuples

get_surrounding(self, include_corners=True)

source code 

Returns neighboring coords of the rect.

Parameters:
  • include_corners - whether to also move diagonally from the rect corners

tuple_iter(self)

source code 

Generates an iterator, that returns tuples

Overrides: Shape.tuple_iter

iter_without_border(self)

source code 

There are 2 possible interpretations about what *width* means. You can either include the last point in the area calculation or just consider points without any extensions. This method iterates over the points without extensions, while the default iteration behavior in other methods is to include said area.