wxRuby Documentation Home

# Wx::Region

A Region represents a simple or complex region on a device context or window. It uses
reference counting, so copying and assignment operations are fast.

## Derived from

GDIObject
Object

## Methods

- Region.new
- Region#clear
- Region#contains
- Region#convert_to_bitmap
- Region#get_box
- Region#intersect
- Region#is_empty
- Region#subtract
- Region#offset
- Region#union
- Region#xor

### Region.new

Region.new(%(arg-type)Integer% x, Integer y, Integer width, Integer height)

Constructs a rectangular region with the given position and size.

Region.new(%(arg-type)Point% topLeft, Point bottomRight)

Constructs a rectangular region from the top left point and the bottom right point.

Region.new(%(arg-type)Rect% rect)

Constructs a rectangular region a Rect object.

Region.new(%(arg-type)Region% region)

Constructs a region by copying another region.

Region.new(%(arg-type)Integer% n, Point points, Integer fillStyle = WINDING_RULE)

Constructs a region corresponding to the polygon made of n points in the
provided array. fillStyle parameter may have values
`WINDING_RULE` or `ODDEVEN_RULE`.

NB: This constructor is only implemented for Win32 and GTK+ Widgets ports.

Region.new(%(arg-type)Bitmap% bmp) Region.new(%(arg-type)Bitmap% bmp, Colour transColour, Integer tolerance = 0)

Constructs a region using the non-transparent pixels of a bitmap. See
Union for more details.

destructor()

Destructor.

### Region#clear

clear()

Clears the current region.

### Region#contains

Integer contains(%(arg-type)Integer% x, Integer y) Integer contains(%(arg-type)Point% pt)

Returns a false or true value indicating whether the given point is
contained within the region.

Integer contains(%(arg-type)Rect% rect) Integer contains(%(arg-type)Integer% x, Integer y, Integer width, Integer height)

Returns a false or true value indicating whether the given rectangle is
contained within the region.

#### Return value

All these methods test whether a given point or rectangle is contained
with the region. If the point or rectangle is completely outside the
rectangle, returns `false`. If the point or rectangle is contained,
returns an integer (which will be true in Ruby).

If testing a Rectangle the return value will distinguish between a
wholly-contained rectangle (which will return value equal to
`Wx::IN_REGION`) and a partly overlapping rectangle (which will have a
return value of `Wx::PART_REGION`). Note that on Windows, this
distinction is not made; the return value will always be `false` or
`Wx::IN_REGION`)

### Region#convert_to_bitmap

Bitmap convert_to_bitmap()

Convert the region to a black and white bitmap with the white pixels
being inside the region.

### Region#get_box

Rect get_box()

Returns the outer bounds of the region.

### Region#intersect

Boolean intersect(%(arg-type)Integer% x, Integer y, Integer width, Integer height)

Finds the intersection of this region and another, rectangular region, specified using position and size.

Boolean intersect(%(arg-type)Rect% rect)

Finds the intersection of this region and another, rectangular region.

Boolean intersect(%(arg-type)Region% region)

Finds the intersection of this region and another region.

#### Return value

`true` if successful, `false` otherwise.

#### Remarks

Creates the intersection of the two regions, that is, the parts which are in both regions. The result
is stored in this region.

### Region#is_empty

Boolean is_empty()

Returns `true` if the region is empty, `false` otherwise.

### Region#subtract

Boolean subtract(%(arg-type)Rect% rect)

Subtracts a rectangular region from this region.

Boolean subtract(%(arg-type)Region% region)

Subtracts a region from this region.

#### Return value

`true` if successful, `false` otherwise.

#### Remarks

This operation combines the parts of ‘this’ region that are not part of the second region.
The result is stored in this region.

### Region#offset

Boolean offset(%(arg-type)Integer% x, Integer y)

Moves the region by the specified offsets in horizontal and vertical
directions.

#### Return value

`true` if successful, `false` otherwise (the region is unchanged then).

### Region#union

Boolean union(%(arg-type)Integer% x, Integer y, Integer width, Integer height)

Finds the union of this region and another, rectangular region, specified using position and size.

Boolean union(%(arg-type)Rect% rect)

Finds the union of this region and another, rectangular region.

Boolean union(%(arg-type)Region% region)

Finds the union of this region and another region.

Boolean union(%(arg-type)Bitmap% 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.

Boolean union(%(arg-type)Bitmap% bmp, Colour transColour, Integer 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.

#### Return value

`true` if successful, `false` otherwise.

#### Remarks

This operation creates a region that combines all of this region and the second region.
The result is stored in this region.

### Region#xor

Boolean xor(%(arg-type)Integer% x, Integer y, Integer width, Integer height)

Finds the Xor of this region and another, rectangular region, specified using position and size.

Boolean xor(%(arg-type)Rect% rect)

Finds the Xor of this region and another, rectangular region.

Boolean xor(%(arg-type)Region% region)

Finds the Xor of this region and another region.

#### Return value

`true` if successful, `false` otherwise.

#### Remarks

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.

### Region#=

operator $=$(%(arg-type)Region% region)

Copies region by reference counting.

[This page automatically generated from the Textile source at 2023-06-09 00:45:36 +0000]