********* wx.Region ********* Inheritance diagram for `wx.Region`: | .. inheritance-diagram:: wx.Region | Description =========== A `wx.Region` represents a simple or complex region on a device context or window. This class uses reference counting and copy-on-write internally so that assignments between two instances of this class are very cheap. You can therefore use actual objects instead of pointers without efficiency problems. If an instance of this class is changed it will create its own data internally so that other instances, which previously shared the data using the reference counting, are not affected. .. seealso:: `wx.RegionIterator `_ Derived From ^^^^^^^^^^^^^ * `wx.GDIObject `_ * `wx.Object `_ Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `Clear <#Clear>`_ * `Contains <#Contains>`_ * `ContainsPoint <#ContainsPoint>`_ * `ContainsRect <#ContainsRect>`_ * `ContainsRectDim <#ContainsRectDim>`_ * `ConvertToBitmap <#ConvertToBitmap>`_ * `GetBox <#GetBox>`_ * `Intersect <#Intersect>`_ * `IntersectRect <#IntersectRect>`_ * `IntersectRegion <#IntersectRegion>`_ * `IsEmpty <#IsEmpty>`_ * `IsEqual <#IsEqual>`_ * `Offset <#Offset>`_ * `Subtract <#Subtract>`_ * `SubtractRect <#SubtractRect>`_ * `SubtractRegion <#SubtractRegion>`_ * `Union <#Union>`_ * `UnionBitmap <#UnionBitmap>`_ * `UnionBitmapColour <#UnionBitmapColour>`_ * `UnionRect <#UnionRect>`_ * `UnionRegion <#UnionRegion>`_ * `Xor <#Xor>`_ * `XorRect <#XorRect>`_ * `XorRegion <#XorRegion>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `Box <#Box>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(x=0, y=0, width=0, height=0) Constructs a rectangular region with the given position and size. **Parameters:** * `x` (int) * `y` (int) * `width` (int) * `height` (int) | **Returns:** `wx.Region `_ -------- .. method:: Clear() Clears the current region. -------- .. method:: Contains(x, y) Returns a value indicating whether the given point is contained within the region. **Parameters:** * `x` (long) * `y` (long) | **Returns:** `int` -------- .. method:: ContainsPoint(pt) Returns a value indicating whether the given point is contained within the region. **Parameters:** * `pt` (`wx.Point `_) | **Returns:** `int` -------- .. method:: ContainsRect(rect) Returns a value indicating whether the given rectangle is contained within the region. **Parameters:** * `rect` (`wx.Rect `_) | **Returns:** `int` -------- .. method:: ContainsRectDim(x, y, w, h) Returns a value indicating whether the given point is contained within the region. **Parameters:** * `x` (int) * `y` (int) * `w` (int) * `h` (int) | **Returns:** `int` -------- .. method:: ConvertToBitmap() Convert the region to a black and white bitmap with the white pixels being inside the region. | **Returns:** `wx.Bitmap `_ -------- .. method:: GetBox() Returns the outer bounds of the region. | **Returns:** `wx.Rect `_ -------- .. method:: Intersect(x, y, width, height) Finds the intersection of this rectangle and another region. **Parameters:** * `x` (int) * `y` (int) * `width` (int) * `height` (int) | **Returns:** `bool` .. note:: Creates the intersection of the two regions, that is, the parts which are in both regions. The result is stored in this region. -------- .. method:: IntersectRect(rect) Finds the intersection of this rectangle and another region. **Parameters:** * `rect` (`wx.Rect `_) | **Returns:** `bool` .. note:: Creates the intersection of the two regions, that is, the parts which are in both regions. The result is stored in this region. -------- .. method:: IntersectRegion(region) Finds the intersection of this region and another region. **Parameters:** * `region` (`wx.Region `_) | **Returns:** `bool` .. note:: Creates the intersection of the two regions, that is, the parts which are in both regions. The result is stored in this region. -------- .. method:: IsEmpty() Returns ``True`` if the region is empty, ``False`` otherwise. | **Returns:** `bool` -------- .. method:: IsEqual(region) Returns ``True`` if the region is equal to, i.e. covers the same area as, another one. **Parameters:** * `region` (`wx.Region `_) | **Returns:** `bool` .. note:: Note that if both this region and `region` are invalid, they are considered to be equal. -------- .. method:: Offset(x, y) Moves the region by the specified offsets in horizontal and vertical directions. **Parameters:** * `x` (int) * `y` (int) | **Returns:** `bool` -------- .. method:: Subtract(x, y, width, height) Subtracts a rectangle from this region. **Parameters:** * `x` (int) * `y` (int) * `width` (int) * `height` (int) | **Returns:** `bool` .. note:: This operation combines the parts of 'this' region that are not part of the second region. The result is stored in this region. -------- .. method:: SubtractRect(rect) Subtracts a rectangle from this region. **Parameters:** * `rect` (`wx.Rect `_) | **Returns:** `bool` .. note:: This operation combines the parts of 'this' region that are not part of the second region. The result is stored in this region. -------- .. method:: SubtractRegion(region) Subtracts a region from this region. **Parameters:** * `region` (`wx.Region `_) | **Returns:** `bool` .. note:: This operation combines the parts of 'this' region that are not part of the second region. The result is stored in this region. -------- .. method:: Union(x, y, width, height) Finds the union of this region and another, rectangular region, specified using position and size. **Parameters:** * `x` (int) * `y` (int) * `width` (int) * `height` (int) | **Returns:** `bool` .. note:: This operation creates a region that combines all of this region and the second region. The result is stored in this region. -------- .. method:: UnionBitmap(bmp) Finds the union of this region and the non-transparent pixels of a bitmap. Bitmap's mask is used to determine transparency. If the bitmap doesn't have a mask, solid rectangle of bitmap's dimensions is used. **Parameters:** * `bmp` (`wx.Bitmap `_) | **Returns:** `bool` .. note:: This operation creates a region that combines all of this region and the second region. The result is stored in this region. -------- .. method:: UnionBitmapColour(bmp, transColour, tolerance=0) Finds the union of this region and the non-transparent pixels of a bitmap. Colour to be treated as transparent is specified in the `transColour` argument, along with an optional colour tolerance value. **Parameters:** * `bmp` (`wx.Bitmap `_) * `transColour` (`wx.Colour `_) * `tolerance` (int) | **Returns:** `bool` .. note:: This operation creates a region that combines all of this region and the second region. The result is stored in this region. -------- .. method:: UnionRect(rect) Finds the union of this region and another, rectangular region. **Parameters:** * `rect` (`wx.Rect `_) | **Returns:** `bool` .. note:: This operation creates a region that combines all of this region and the second region. The result is stored in this region. -------- .. method:: UnionRegion(region) Finds the union of this region and another region. **Parameters:** * `region` (`wx.Region `_) | **Returns:** `bool` .. note:: This operation creates a region that combines all of this region and the second region. The result is stored in this region. -------- .. method:: Xor(x, y, width, height) Finds the Xor of this region and another region. **Parameters:** * `x` (int) * `y` (int) * `width` (int) * `height` (int) | **Returns:** `bool` .. note:: This operation creates a region that combines all of this region and the second region, except for any overlapping areas. The result is stored in this region. -------- .. method:: XorRect(rect) Finds the Xor of this region and another, rectangular region. **Parameters:** * `rect` (`wx.Rect `_) | **Returns:** `bool` .. note:: This operation creates a region that combines all of this region and the second region, except for any overlapping areas. The result is stored in this region. -------- .. method:: XorRegion(region) Finds the Xor of this region and another region. **Parameters:** * `region` (`wx.Region `_) | **Returns:** `bool` .. note:: This operation creates a region that combines all of this region and the second region, except for any overlapping areas. The result is stored in this region. -------- Properties ^^^^^^^^^^ .. attribute:: Box See `GetBox <#GetBox>`_