wx.Rect2D¶
Rect2DDouble is an axis-aligned rectangle; each side of the rect is parallel to the X or Y axis.
The rectangle is either defined by the top left and bottom right corner, or by the top left corner and size.
A point is contained within the rectangle if left <= m_x < right and top <= m_y < bottom; thus, it is a half open interval.
Note
Rect2DDouble has subtle differences from wx.Rect in how its edge and corner functions work. With Rect2DDouble , there are two counterparts:
SetXXXfunctions, which keep the other corners at their position whenever sensibleMoveXXXfunctions, which keep the size of the rectangle and move the other corners appropriately
Class Hierarchy¶
Methods Summary¶
Default constructor. |
|
Resizes the rectangle to fit within the dimensions of another rectangle. |
|
Returns |
|
Returns the intersecting rectangle of this rectangle with another one. |
|
Returns the union of this rectangle with another one. |
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. |
|
Get() . (x, y, width, height) |
|
Returns the bottom point of the rectangle. |
|
Returns the centre point of the rectangle. |
|
Returns the height. |
|
Returns an immutable representation of the |
|
Returns the left point of the rectangle (the same as |
|
Returns the position of the bottom left corner. |
|
Returns the position of the top left corner of the rectangle, same as |
|
Returns the relative location of a point to the rectangle (e.g., inside or to the left of it). |
|
Returns the position. |
|
Returns the right point of the rectangle. |
|
Returns the position of the bottom right corner. |
|
Returns the position of the top right corner. |
|
Returns the size. |
|
Returns the top point of the rectangle (the same as |
|
Returns the width. |
|
Returns the left position of the rectangle. |
|
Returns the top position of the rect. |
|
Returns |
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. |
|
Offsets the rectangle by |
|
Constrains the rectangle to the intersection of another rectangle. |
|
Returns |
|
Returns |
|
Set the bottom edge of the rectangle, preserving the height. |
|
An alias for |
|
Set the bottom-left point of the rectangle, while preserving the width and height of the rectangle. |
|
Sets the left position, which may adjust the width of the rectangle. |
|
Set the top-left point of the rectangle, while preserving the width and height of the rectangle. |
|
Set the bottom-right point of the rectangle, while preserving the width and height of the rectangle. |
|
Set the right side of the rectangle, preserving the width. |
|
Set the top-right point of the rectangle, while preserving the width and height of the rectangle. |
|
Set the top edge of the rectangle, preserving the height. |
|
Moves the rectangle by the specified offset. |
|
Set the bottom edge of the rectangle. |
|
Recenters (i.e., moves) the rectangle to the given point. |
|
Sets the height. |
|
Set the left side of the rectangle. |
|
Set the bottom-left point of the rectangle. |
|
Set the top-left point of the rectangle. |
|
Set the right side of the rectangle. |
|
Set the bottom-right point of the rectangle. |
|
Set the top-right point of the rectangle. |
|
Set the top edge of the rectangle. |
|
Sets the width. |
|
Returns the rectangle as a wx.Rect. |
|
Expands the rectangle to the union with another rectangle. |
|
Inequality operator. |
|
Equality operator. |
Properties Summary¶
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
A public C++ attribute of type Double . |
|
A public C++ attribute of type Double . |
|
A public C++ attribute of type Double . |
|
A public C++ attribute of type Double . |
Class API¶
- class wx.Rect2D(object)¶
Possible constructors:
Rect2DDouble() -> None Rect2DDouble(x, y, width, height) -> None Rect2DDouble(rect) -> None
Rect2DDouble is an axis-aligned rectangle; each side of the rect is parallel to the X or Y axis.
Methods¶
- __init__(self, *args, **kw)¶
-
__init__ (self)
Default constructor.
Initializes to zero the internal m_x, m_y, m_width and m_height members.
- Return type:
None
__init__ (self, x, y, width, height)
Creates a Rect2DDouble object from x, y, width and height values.
- Parameters:
x (wx.Double)
y (wx.Double)
width (wx.Double)
height (wx.Double)
- Return type:
None
__init__ (self, rect)
Constructs a Rect2DDouble from a wx.Rect.
- Parameters:
rect (wx.Rect)
- Return type:
None
Added in version 4.3/wxWidgets-3.3.0.
- ConstrainTo(self, rect)¶
Resizes the rectangle to fit within the dimensions of another rectangle.
- Parameters:
rect (Rect2DDouble)
- Return type:
None
- Contains(self, *args, **kw)¶
-
Contains (self, pt)
Returns
Trueif the given point is inside the rectangle (or on its boundary) andFalseotherwise.- Parameters:
pt (Point2DDouble)
- Return type:
bool
Contains (self, rect)
Returns
Trueif the given rectangle is completely inside this rectangle (or touches its boundary) andFalseotherwise.- Parameters:
rect (Rect2DDouble)
- Return type:
bool
- CreateIntersection(self, otherRect)¶
Returns the intersecting rectangle of this rectangle with another one.
- Parameters:
otherRect (Rect2DDouble)
- Return type:
Rect2DDouble
- CreateUnion(self, otherRect)¶
Returns the union of this rectangle with another one.
- Parameters:
otherRect (Rect2DDouble)
- Return type:
Rect2DDouble
- Deflate(self, *args, **kw)¶
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Deflate (self, d)
- Parameters:
d (wx.Size)
- Return type:
Rect2DDouble
Deflate (self, d)
- Parameters:
d (wx.Double)
- Return type:
Rect2DDouble
Deflate (self, dx, dy)
- Parameters:
dx (wx.Double)
dy (wx.Double)
- Return type:
Rect2DDouble
- Get(self)¶
Get() . (x, y, width, height)
Return the rectangle’s properties as a tuple.
- Return type:
Any
- GetBottom(self)¶
Returns the bottom point of the rectangle.
- Return type:
float
- GetCentre(self)¶
Returns the centre point of the rectangle.
- Return type:
Point2DDouble
- GetHeight(self)¶
Returns the height.
- Return type:
float
Added in version 4.3/wxWidgets-3.3.0.
- GetIM(self)¶
Returns an immutable representation of the
wx.Rect2Dobject, based onnamedtuple.This new object is hashable and can be used as a dictionary key, be added to sets, etc. It can be converted back into a real
wx.Rect2Dwith a simple statement like this:obj = wx.Rect2D(imObj).
- GetLeftBottom(self)¶
Returns the position of the bottom left corner.
- Return type:
Point2DDouble
- GetLeftTop(self)¶
Returns the position of the top left corner of the rectangle, same as
GetPosition.- Return type:
Point2DDouble
- GetOutCode(self, pt)¶
Returns the relative location of a point to the rectangle (e.g., inside or to the left of it).
- Parameters:
pt (Point2DDouble)
- Return type:
- GetPosition(self)¶
Returns the position.
- Return type:
Point2DDouble
- GetRight(self)¶
Returns the right point of the rectangle.
- Return type:
float
- GetRightBottom(self)¶
Returns the position of the bottom right corner.
- Return type:
Point2DDouble
- GetRightTop(self)¶
Returns the position of the top right corner.
- Return type:
Point2DDouble
- GetWidth(self)¶
Returns the width.
- Return type:
float
Added in version 4.3/wxWidgets-3.3.0.
- GetX(self)¶
Returns the left position of the rectangle.
- Return type:
float
Added in version 4.3/wxWidgets-3.3.0.
- GetY(self)¶
Returns the top position of the rect.
- Return type:
float
Added in version 4.3/wxWidgets-3.3.0.
- HaveEqualSize(self, rect)¶
Returns
Trueif another rectangle has the same width and height.- Parameters:
rect (Rect2DDouble)
- Return type:
bool
- Inflate(self, *args, **kw)¶
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Inflate (self, d)
- Parameters:
d (wx.Size)
- Return type:
Rect2DDouble
Inflate (self, d)
- Parameters:
d (wx.Double)
- Return type:
Rect2DDouble
Inflate (self, dx, dy)
- Parameters:
dx (wx.Double)
dy (wx.Double)
- Return type:
Rect2DDouble
- Inset(self, *args, **kw)¶
-
Inset (self, x, y)
Offsets the rectangle by
xandy, but maintains the bottom right corner.- Parameters:
x (wx.Double)
y (wx.Double)
- Return type:
None
Note
This will affect the width and height of the rectangle.
Inset (self, left, top, right, bottom)
- Parameters:
left (wx.Double)
top (wx.Double)
right (wx.Double)
bottom (wx.Double)
- Return type:
None
- Interpolate(self, widthfactor, heightfactor)¶
- Parameters:
widthfactor (wx.int)
heightfactor (wx.int)
- Return type:
Point2DDouble
- Intersect(self, *args, **kw)¶
-
Intersect (self, otherRect)
Constrains the rectangle to the intersection of another rectangle.
- Parameters:
otherRect (Rect2DDouble)
- Return type:
None
Intersect (src1, src2, dest)
Returns the intersecting rectangle of two rectangles.
- Parameters:
src1 (Rect2DDouble)
src2 (Rect2DDouble)
dest (Rect2DDouble)
- Return type:
None
- Intersects(self, rect)¶
Returns
Trueif this rectangle has a non-empty intersection with the rectangle rect andFalseotherwise.- Parameters:
rect (Rect2DDouble)
- Return type:
bool
- IsEmpty(self)¶
Returns
Trueif this rectangle has a width or height less than or equal to 0 andFalseotherwise.- Return type:
bool
- MoveBottomTo(self, n)¶
Set the bottom edge of the rectangle, preserving the height.
- Parameters:
n (wx.Double)
- Return type:
None
- MoveCentreTo(self, pt)¶
An alias for
MoveCentreTo.- Parameters:
pt (Point2DDouble)
- Return type:
None
- MoveLeftBottomTo(self, pt)¶
Set the bottom-left point of the rectangle, while preserving the width and height of the rectangle.
- Parameters:
pt (Point2DDouble)
- Return type:
None
- MoveLeftTo(self, n)¶
Sets the left position, which may adjust the width of the rectangle.
- Parameters:
n (wx.Double)
- Return type:
None
- MoveLeftTopTo(self, pt)¶
Set the top-left point of the rectangle, while preserving the width and height of the rectangle.
- Parameters:
pt (Point2DDouble)
- Return type:
None
- MoveRightBottomTo(self, pt)¶
Set the bottom-right point of the rectangle, while preserving the width and height of the rectangle.
- Parameters:
pt (Point2DDouble)
- Return type:
None
- MoveRightTo(self, n)¶
Set the right side of the rectangle, preserving the width.
- Parameters:
n (wx.Double)
- Return type:
None
- MoveRightTopTo(self, pt)¶
Set the top-right point of the rectangle, while preserving the width and height of the rectangle.
- Parameters:
pt (Point2DDouble)
- Return type:
None
- MoveTopTo(self, n)¶
Set the top edge of the rectangle, preserving the height.
- Parameters:
n (wx.Double)
- Return type:
None
- Offset(self, *args, **kw)¶
-
Offset (self, pt)
Moves the rectangle by the specified offset.
If X of pt is positive, the rectangle is moved to the right, if Y of pt is positive, it is moved to the bottom, otherwise it is moved to the left or top respectively.
- Parameters:
pt (Point2DDouble)
- Return type:
None
Offset (self, dx, dy)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
dx (wx.Double)
dy (wx.Double)
- Return type:
None
Added in version 4.3/wxWidgets-3.3.0.
- Scale(self, *args, **kw)¶
-
Scale (self, f)
- Parameters:
f (wx.Double)
- Return type:
None
Scale (self, num, denum)
- Parameters:
num (wx.int)
denum (wx.int)
- Return type:
None
- SetBottom(self, n)¶
Set the bottom edge of the rectangle.
- Parameters:
n (wx.Double)
- Return type:
None
Note
This will preserve the top position and alter the height of the rectangle. Use
MoveBottomToto only move the bottom.
- SetCentre(self, pt)¶
Recenters (i.e., moves) the rectangle to the given point.
- Parameters:
pt (Point2DDouble)
- Return type:
None
- SetHeight(self, h)¶
Sets the height.
- Parameters:
h (wx.Double)
- Return type:
None
Added in version 4.3/wxWidgets-3.3.0.
- SetLeft(self, n)¶
Set the left side of the rectangle.
- Parameters:
n (wx.Double)
- Return type:
None
Note
This will preserve the width of the rectangle. Use
MoveLeftToto change the left position of the rectangle, adjusting its width accordingly.
- SetLeftBottom(self, pt)¶
Set the bottom-left point of the rectangle.
- Parameters:
pt (Point2DDouble)
- Return type:
None
Note
This will alter the width and height of the rectangle. Use
MoveLeftBottomToto only move the left bottom corner.
- SetLeftTop(self, pt)¶
Set the top-left point of the rectangle.
- Parameters:
pt (Point2DDouble)
- Return type:
None
Note
This will alter the height of the rectangle. Use
MoveLeftTopToto only move the top.
- SetRight(self, n)¶
Set the right side of the rectangle.
- Parameters:
n (wx.Double)
- Return type:
None
Note
This will preserve the left position and alter the width of the rectangle. Use
MoveRightToto only move the bottom.
- SetRightBottom(self, pt)¶
Set the bottom-right point of the rectangle.
- Parameters:
pt (Point2DDouble)
- Return type:
None
Note
This will alter the width and height of the rectangle. Use
MoveRightBottomToto only move the right bottom corner.
- SetRightTop(self, pt)¶
Set the top-right point of the rectangle.
- Parameters:
pt (Point2DDouble)
- Return type:
None
Note
This will alter the width and height of the rectangle. Use
MoveRightTopToto only move the right top corner.
- SetTop(self, n)¶
Set the top edge of the rectangle.
- Parameters:
n (wx.Double)
- Return type:
None
Note
This will alter the height of the rectangle. Use
MoveTopToto only move the top.
- SetWidth(self, w)¶
Sets the width.
- Parameters:
w (wx.Double)
- Return type:
None
Added in version 4.3/wxWidgets-3.3.0.
- ToRect(self)¶
Returns the rectangle as a wx.Rect.
- Return type:
Added in version 4.3/wxWidgets-3.3.0.
- Union(self, *args, **kw)¶
-
Union (self, otherRect)
Expands the rectangle to the union with another rectangle.
- Parameters:
otherRect (Rect2DDouble)
- Return type:
None
Union (self, pt)
Expands the rectangle to include the point at
pt.- Parameters:
pt (Point2DDouble)
- Return type:
None
Union (src1, src2, dest)
Returns the union rectangle of two rectangles.
- Parameters:
src1 (Rect2DDouble)
src2 (Rect2DDouble)
dest (Rect2DDouble)
- Return type:
None
- __bool__(self)¶
- __getitem__(self, idx)¶
- __len__(self)¶
- __nonzero__(self)¶
- __reduce__(self)¶
- __repr__(self)¶
- __setitem__(self, idx, val)¶
- __str__(self)¶
- __ne__(self, rect)¶
Inequality operator.
- Parameters:
rect (Rect2DDouble)
- Return type:
bool
- __eq__(self, rect)¶
Equality operator.
- Parameters:
rect (Rect2DDouble)
- Return type:
bool
Properties¶
- LeftBottom¶
See
GetLeftBottomandSetLeftBottom
- LeftTop¶
See
GetLeftTopandSetLeftTop
- Position¶
See
GetPosition
- RightBottom¶
See
GetRightBottomandSetRightBottom
- RightTop¶
See
GetRightTopandSetRightTop
- m_height¶
A public C++ attribute of type Double .
- m_width¶
A public C++ attribute of type Double .
- m_x¶
A public C++ attribute of type Double .
- m_y¶
A public C++ attribute of type Double .
