phoenix_title 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:

  • SetXXX functions, which keep the other corners at their position whenever sensible

  • MoveXXX functions, which keep the size of the rectangle and move the other corners appropriately


class_hierarchy Class Hierarchy

Inheritance diagram for class Rect2D:

method_summary Methods Summary

__init__

Default constructor.

ConstrainTo

Resizes the rectangle to fit within the dimensions of another rectangle.

Contains

Returns True if the given point is inside the rectangle (or on its boundary) and False otherwise.

CreateIntersection

Returns the intersecting rectangle of this rectangle with another one.

CreateUnion

Returns the union of this rectangle with another one.

Deflate

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Get

Get() . (x, y, width, height)

GetBottom

Returns the bottom point of the rectangle.

GetCentre

Returns the centre point of the rectangle.

GetHeight

Returns the height.

GetIM

Returns an immutable representation of the wx.Rect2D object, based on namedtuple.

GetLeft

Returns the left point of the rectangle (the same as GetX ).

GetLeftBottom

Returns the position of the bottom left corner.

GetLeftTop

Returns the position of the top left corner of the rectangle, same as GetPosition .

GetOutCode

Returns the relative location of a point to the rectangle (e.g., inside or to the left of it).

GetPosition

Returns the position.

GetRight

Returns the right point of the rectangle.

GetRightBottom

Returns the position of the bottom right corner.

GetRightTop

Returns the position of the top right corner.

GetSize

Returns the size.

GetTop

Returns the top point of the rectangle (the same as GetY ).

GetWidth

Returns the width.

GetX

Returns the left position of the rectangle.

GetY

Returns the top position of the rect.

HaveEqualSize

Returns True if another rectangle has the same width and height.

Inflate

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Inset

Offsets the rectangle by x and y , but maintains the bottom right corner.

Interpolate

Intersect

Constrains the rectangle to the intersection of another rectangle.

Intersects

Returns True if this rectangle has a non-empty intersection with the rectangle rect and False otherwise.

IsEmpty

Returns True if this rectangle has a width or height less than or equal to 0 and False otherwise.

MoveBottomTo

Set the bottom edge of the rectangle, preserving the height.

MoveCentreTo

An alias for MoveCentreTo .

MoveLeftBottomTo

Set the bottom-left point of the rectangle, while preserving the width and height of the rectangle.

MoveLeftTo

Sets the left position, which may adjust the width of the rectangle.

MoveLeftTopTo

Set the top-left point of the rectangle, while preserving the width and height of the rectangle.

MoveRightBottomTo

Set the bottom-right point of the rectangle, while preserving the width and height of the rectangle.

MoveRightTo

Set the right side of the rectangle, preserving the width.

MoveRightTopTo

Set the top-right point of the rectangle, while preserving the width and height of the rectangle.

MoveTopTo

Set the top edge of the rectangle, preserving the height.

Offset

Moves the rectangle by the specified offset.

Scale

SetBottom

Set the bottom edge of the rectangle.

SetCentre

Recenters (i.e., moves) the rectangle to the given point.

SetHeight

Sets the height.

SetLeft

Set the left side of the rectangle.

SetLeftBottom

Set the bottom-left point of the rectangle.

SetLeftTop

Set the top-left point of the rectangle.

SetRight

Set the right side of the rectangle.

SetRightBottom

Set the bottom-right point of the rectangle.

SetRightTop

Set the top-right point of the rectangle.

SetTop

Set the top edge of the rectangle.

SetWidth

Sets the width.

ToRect

Returns the rectangle as a wx.Rect.

Union

Expands the rectangle to the union with another rectangle.

__bool__

__getitem__

__len__

__nonzero__

__reduce__

__repr__

__setitem__

__str__

__ne__

Inequality operator.

__eq__

Equality operator.


property_summary Properties Summary

Bottom

See GetBottom and SetBottom

Centre

See GetCentre and SetCentre

Height

See GetHeight and SetHeight

IM

See GetIM

Left

See GetLeft and SetLeft

LeftBottom

See GetLeftBottom and SetLeftBottom

LeftTop

See GetLeftTop and SetLeftTop

Position

See GetPosition

Right

See GetRight and SetRight

RightBottom

See GetRightBottom and SetRightBottom

RightTop

See GetRightTop and SetRightTop

Size

See GetSize

Top

See GetTop and SetTop

Width

See GetWidth and SetWidth

X

See GetX

Y

See GetY

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 .


api 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)

overload Overloaded Implementations:



__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)

overload Overloaded Implementations:



Contains (self, pt)

Returns True if the given point is inside the rectangle (or on its boundary) and False otherwise.

Parameters:

pt (Point2DDouble)

Return type:

bool



Contains (self, rect)

Returns True if the given rectangle is completely inside this rectangle (or touches its boundary) and False otherwise.

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.

overload Overloaded Implementations:



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.Rect2D object, based on namedtuple.

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.Rect2D with a simple statement like this: obj = wx.Rect2D(imObj).



GetLeft(self)

Returns the left point of the rectangle (the same as GetX ).

Return type:

float



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:

wx.OutCode



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



GetSize(self)

Returns the size.

Return type:

wx.Size



GetTop(self)

Returns the top point of the rectangle (the same as GetY ).

Return type:

float



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 True if 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.

overload Overloaded Implementations:



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)

overload Overloaded Implementations:



Inset (self, x, y)

Offsets the rectangle by x and y , 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)

overload Overloaded Implementations:



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 True if this rectangle has a non-empty intersection with the rectangle rect and False otherwise.

Parameters:

rect (Rect2DDouble)

Return type:

bool



IsEmpty(self)

Returns True if this rectangle has a width or height less than or equal to 0 and False otherwise.

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)

overload Overloaded Implementations:



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)

overload Overloaded Implementations:



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 MoveBottomTo to 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 MoveLeftTo to 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 MoveLeftBottomTo to 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 MoveLeftTopTo to 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 MoveRightTo to 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 MoveRightBottomTo to 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 MoveRightTopTo to 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 MoveTopTo to 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:

wx.Rect

Added in version 4.3/wxWidgets-3.3.0.



Union(self, *args, **kw)

overload Overloaded Implementations:



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

Bottom

See GetBottom and SetBottom



Centre

See GetCentre and SetCentre



Height

See GetHeight and SetHeight



IM

See GetIM



Left

See GetLeft and SetLeft



LeftBottom

See GetLeftBottom and SetLeftBottom



LeftTop

See GetLeftTop and SetLeftTop



Position

See GetPosition



Right

See GetRight and SetRight



RightBottom

See GetRightBottom and SetRightBottom



RightTop

See GetRightTop and SetRightTop



Size

See GetSize



Top

See GetTop and SetTop



Width

See GetWidth and SetWidth



X

See GetX



Y

See GetY



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 .