
What is a Region?Think of a region as a mask, a bit like a stencil, which you can paint through but which will prevent the paint going outside a defined area. Regions are used to create cutout shapes or limit painting to certain areas or create specially shaped windows or controls. Regions can also be used to detect if a point is in a certain irregular shape. This technique is called Hit-Testing and is used in interactive graphics programs to see if the user has clicked on a particular part of an image. Internally, a Region object consists of a collection of rectangles that are tiled to cover the area of interest. Any irregular shape can be represented in a region and a region might even have several disconnected shapes in them. Figure 1 shows how a region is constructed. The small image shows the actual size region, the larger image shows how rectangles tessellate to cover the area defined.
Figure 1. The secrets of a region |