Rect Class Reference

Class defining a 2D rectangle with top-left corner coordinates and width/height in pixels. More...

Functions

int width (self)
 Width of the rectangle in pixels.
 
int height (self)
 Height of the rectangle in pixels.
 
int x (self)
 x coordinates of top-left corner.
 
int y (self)
 y coordinates of top-left corner.
 
int area (self)
 Returns the area of the rectangle.
 
bool is_empty (self)
 Tests if the given sl.Rect is empty (width or/and height is null).
 
bool contains (self, Rect target, proper=False)
 Tests if this sl.Rect contains the target sl.Rect. More...
 
bool is_contained_in_resolution (self, Resolution, resolution, bool, proper=False)
 Tests if this sl.Rect is contained inside the given resolution sl.Resolution. More...
 
bool is_contained (self, Rect target, proper=False)
 Tests if this sl.Rect is contained inside the given target sl.Rect. More...
 

Detailed Description

Class defining a 2D rectangle with top-left corner coordinates and width/height in pixels.

Functions

◆ contains()

bool contains (   self,
Rect  target,
  proper = False 
)

Tests if this sl.Rect contains the target sl.Rect.

Returns
True if this rectangle contains the <target> rectangle, otherwise False.
Note
By default (proper False) a target whose edges land exactly on this rectangle's edges is contained. Pass proper True to require a strict interior and exclude the edge.

◆ is_contained_in_resolution()

bool is_contained_in_resolution (   self,
  Resolution,
  resolution,
  bool,
  proper = False 
)

Tests if this sl.Rect is contained inside the given resolution sl.Resolution.

It tests if the current rectangle is contained inside a sl::Rect defined by Rect(0, 0, resolution.width, resolution.height).

Returns
Ttrue if this rectangle is inside the rectangle defined by Rect(0, 0, resolution.width, resolution.height), otherwise false.
Note
By default (proper False) a rectangle whose far edge lands exactly on the resolution is contained, since the last valid column is width - 1. Pass proper True to require a strict interior and exclude the edge.

◆ is_contained()

bool is_contained (   self,
Rect  target,
  proper = False 
)

Tests if this sl.Rect is contained inside the given target sl.Rect.

Returns
True if this rectangle is inside the current target sl.Rect, otherwise False.
Note
By default (proper False) a rectangle whose edges land exactly on the target's edges is contained. Pass proper True to require a strict interior and exclude the edge.