Next: , Previous: GdkScreen, Up: Top


6 Points, Rectangles and Regions

Simple graphical data types

6.1 Overview

GDK provides the <gdk-point>, <gdk-rectangle>, <gdk-region> and <gdk-span> data types for representing pixels and sets of pixels on the screen.

<gdk-point> is a simple structure containing an x and y coordinate of a point.

<gdk-rectangle> is a structure holding the position and size of a rectangle. The intersection of two rectangles can be computed with gdk-rectangle-intersect. To find the union of two rectangles use gdk-rectangle-union.

<gdk-region> is an opaque data type holding a set of arbitrary pixels, and is usually used for clipping graphical operations (see gdk-gc-set-clip-region).

<gdk-span> is a structure holding a spanline. A spanline is a horizontal line that is one pixel wide. It is mainly used when rasterizing other graphics primitives. It can be intersected to regions by using gdk-region-spans-intersect-foreach.

6.2 Usage

— Class: <gdk-rectangle>

Derives from <gboxed>.

This class defines no direct slots.

— Class: <gdk-region>

Opaque pointer.

This class defines no direct slots.

— Function: gdk-region-new ⇒  (ret <gdk-region>)

Creates a new empty <gdk-region>.

ret
a new empty <gdk-region>
— Function: gdk-region-copy (self <gdk-region>) ⇒  (ret <gdk-region>)

Copies region, creating an identical new region.

region
a <gdk-region>
ret
a new region identical to region
— Function: gdk-region-rectangle (rectangle <gdk-rectangle>) ⇒  (ret <gdk-region>)

Creates a new region containing the area rectangle.

rectangle
a <gdk-rectangle>
ret
a new region
— Function: gdk-region-destroy (self <gdk-region>)

Destroys a <gdk-region>.

region
a <gdk-region>
— Function: gdk-region-empty (self <gdk-region>) ⇒  (ret bool)

Finds out if the <gdk-region> is empty.

region
a <gdk-region>
ret
#t’ if region is empty.
— Function: gdk-region-equal (self <gdk-region>) (region2 <gdk-region>) ⇒  (ret bool)

Finds out if the two regions are the same.

region1
a <gdk-region>
region2
a <gdk-region>
ret
#t’ if region1 and region2 are equal.
— Function: gdk-region-point-in (self <gdk-region>) (int) (int) ⇒  (ret bool)

Finds out if a point is in a region.

region
a <gdk-region>
x
the x coordinate of a point
y
the y coordinate of a point
ret
#t’ if the point is in region.
— Function: gdk-region-rect-in (self <gdk-region>) (rectangle <gdk-rectangle>) ⇒  (ret <gdk-overlap-type>)

Tests whether a rectangle is within a region.

region
a <gdk-region>.
rectangle
a <gdk-rectangle>.
ret
GDK_OVERLAP_RECTANGLE_IN’, ‘GDK_OVERLAP_RECTANGLE_OUT’, or ‘GDK_OVERLAP_RECTANGLE_PART’, depending on whether the rectangle is inside, outside, or partly inside the <gdk-region>, respectively.
— Function: gdk-region-offset (self <gdk-region>) (dx int) (dy int)

Moves a region the specified distance.

region
a <gdk-region>
dx
the distance to move the region horizontally
dy
the distance to move the region vertically
— Function: gdk-region-shrink (self <gdk-region>) (dx int) (dy int)

Resizes a region by the specified amount. Positive values shrink the region. Negative values expand it.

region
a <gdk-region>
dx
the number of pixels to shrink the region horizontally
dy
the number of pixels to shrink the region vertically
— Function: gdk-region-union-with-rect (self <gdk-region>) (rect <gdk-rectangle>)

Sets the area of region to the union of the areas of region and rect. The resulting area is the set of pixels contained in either region or rect.

region
a <gdk-region>.
rect
a <gdk-rectangle>.
— Function: gdk-region-intersect (self <gdk-region>) (source2 <gdk-region>)

Sets the area of source1 to the intersection of the areas of source1 and source2. The resulting area is the set of pixels contained in both source1 and source2.

source1
a <gdk-region>
source2
another <gdk-region>
— Function: gdk-region-union (self <gdk-region>) (source2 <gdk-region>)

Sets the area of source1 to the union of the areas of source1 and source2. The resulting area is the set of pixels contained in either source1 or source2.

source1
a <gdk-region>
source2
a <gdk-region>
— Function: gdk-region-subtract (self <gdk-region>) (source2 <gdk-region>)

Subtracts the area of source2 from the area source1. The resulting area is the set of pixels contained in source1 but not in source2.

source1
a <gdk-region>
source2
another <gdk-region>
— Function: gdk-region-xor (self <gdk-region>) (source2 <gdk-region>)

Sets the area of source1 to the exclusive-OR of the areas of source1 and source2. The resulting area is the set of pixels contained in one or the other of the two sources but not in both.

source1
a <gdk-region>
source2
another <gdk-region>