1 <!-- ##### SECTION Title ##### -->
2 Points, Rectangles and Regions
4 <!-- ##### SECTION Short_Description ##### -->
5 simple graphical data types.
7 <!-- ##### SECTION Long_Description ##### -->
9 GDK provides the #GdkPoint, #GdkRectangle, #GdkRegion and #GdkSpan data types
10 for representing pixels and sets of pixels on the screen.
13 #GdkPoint is a simple structure containing an x and y coordinate of a point.
16 #GdkRectangle is a structure holding the position and size of a rectangle.
17 The intersection of two rectangles can be computed with
18 gdk_rectangle_intersect(). To find the union of two rectangles use
19 gdk_rectangle_union().
22 #GdkRegion is an opaque data type holding a set of arbitrary pixels, and is
23 usually used for clipping graphical operations (see gdk_gc_set_clip_region()).
26 #GdkSpan is a structure holding a spanline. A spanline is a horizontal line that
27 is one pixel wide. It is mainly used when rasterizing other graphics primitives.
28 It can be intersected to regions by using gdk_region_spans_intersect_foreach().
31 <!-- ##### SECTION See_Also ##### -->
36 <!-- ##### STRUCT GdkPoint ##### -->
38 Defines the x and y coordinates of a point.
41 @x: the x coordinate of the point.
42 @y: the y coordinate of the point.
44 <!-- ##### STRUCT GdkRectangle ##### -->
46 Defines the position and size of a rectangle.
49 @x: the x coordinate of the left edge of the rectangle.
50 @y: the y coordinate of the top of the rectangle.
51 @width: the width of the rectangle.
52 @height: the height of the rectangle.
54 <!-- ##### FUNCTION gdk_rectangle_intersect ##### -->
56 Calculates the intersection of two rectangles.
59 @src1: a #GdkRectangle.
60 @src2: a #GdkRectangle.
61 @dest: the intersection of @src1 and @src2.
62 @Returns: %TRUE if the rectangles intersect.
65 <!-- ##### FUNCTION gdk_rectangle_union ##### -->
67 Calculates the union of two rectangles.
68 The union of rectangles @src1 and @src2 is the smallest rectangle which
69 includes both @src1 and @src2 within it.
72 @src1: a #GdkRectangle.
73 @src2: a #GdkRectangle.
74 @dest: the union of @src1 and @src2.
77 <!-- ##### STRUCT GdkRegion ##### -->
79 A GdkRegion represents a set of pixels on the screen.
80 The only user-visible field of the structure is the user_data member, which
81 can be used to attach arbitrary data to the #GdkRegion.
85 <!-- ##### FUNCTION gdk_region_new ##### -->
87 Creates a new empty #GdkRegion.
90 @Returns: a new empty #GdkRegion.
93 <!-- ##### FUNCTION gdk_region_polygon ##### -->
95 Creates a new #GdkRegion using the polygon defined by a number of points.
99 @points: an array of #GdkPoint structs.
100 @npoints: the number of elements in the @points array.
101 @fill_rule: specifies which pixels are included in the region when the polygon
103 @Returns: a new #GdkRegion based on the given polygon.
106 <!-- ##### ENUM GdkFillRule ##### -->
108 The method for determining which pixels are included in a region, when
109 creating a #GdkRegion from a polygon.
110 The fill rule is only relevant for polygons which overlap themselves.
113 @GDK_EVEN_ODD_RULE: areas which are overlapped an odd number of times are
114 included in the region, while areas overlapped an even number of times are not.
115 @GDK_WINDING_RULE: overlapping areas are always included.
117 <!-- ##### FUNCTION gdk_region_copy ##### -->
126 <!-- ##### FUNCTION gdk_region_rectangle ##### -->
135 <!-- ##### FUNCTION gdk_region_destroy ##### -->
137 Destroys a #GdkRegion.
140 @region: a #GdkRegion.
143 <!-- ##### FUNCTION gdk_region_get_clipbox ##### -->
145 Returns the smallest rectangle which includes the entire #GdkRegion.
148 @region: a #GdkRegion.
149 @rectangle: returns the smallest rectangle which includes all of @region.
152 <!-- ##### FUNCTION gdk_region_get_rectangles ##### -->
162 <!-- ##### FUNCTION gdk_region_empty ##### -->
164 Returns %TRUE if the #GdkRegion is empty.
167 @region: a #GdkRegion.
168 @Returns: %TRUE if @region is empty.
171 <!-- ##### FUNCTION gdk_region_equal ##### -->
173 Returns %TRUE if the two regions are the same.
176 @region1: a #GdkRegion.
177 @region2: a #GdkRegion.
178 @Returns: %TRUE if @region1 and @region2 are equal.
181 <!-- ##### FUNCTION gdk_region_point_in ##### -->
183 Returns %TRUE if a point is in a region.
186 @region: a #GdkRegion.
187 @x: the x coordinate of a point.
188 @y: the y coordinate of a point.
189 @Returns: %TRUE if the point is in @region.
192 <!-- ##### FUNCTION gdk_region_rect_in ##### -->
194 Tests whether a rectangle is within a region.
197 @region: a #GdkRegion.
198 @rect: a #GdkRectangle.
199 @Returns: %GDK_OVERLAP_RECTANGLE_IN, %GDK_OVERLAP_RECTANGLE_OUT, or
200 %GDK_OVERLAP_RECTANGLE_PART, depending on whether the rectangle is inside,
201 outside, or partly inside the #GdkRegion, respectively.
204 <!-- ##### ENUM GdkOverlapType ##### -->
206 Specifies the possible values returned by gdk_region_rect_in().
209 @GDK_OVERLAP_RECTANGLE_IN: if the rectangle is inside the #GdkRegion.
210 @GDK_OVERLAP_RECTANGLE_OUT: if the rectangle is outside the #GdkRegion.
211 @GDK_OVERLAP_RECTANGLE_PART: if the rectangle is partly inside the #GdkRegion.
213 <!-- ##### FUNCTION gdk_region_offset ##### -->
215 Moves a region the specified distance.
218 @region: a #GdkRegion.
219 @dx: the distance to move the region horizontally.
220 @dy: the distance to move the region vertically.
223 <!-- ##### FUNCTION gdk_region_shrink ##### -->
225 Resizes a region by the specified amount.
226 Positive values shrink the region. Negative values expand it.
229 @region: a #GdkRegion.
230 @dx: the number of pixels to shrink the region horizontally.
231 @dy: the number of pixels to shrink the region vertically.
234 <!-- ##### FUNCTION gdk_region_union_with_rect ##### -->
243 <!-- ##### FUNCTION gdk_region_intersect ##### -->
251 <!-- ##### FUNCTION gdk_region_union ##### -->
260 <!-- ##### FUNCTION gdk_region_subtract ##### -->
268 <!-- ##### FUNCTION gdk_region_xor ##### -->
276 <!-- ##### STRUCT GdkSpan ##### -->
278 A GdkSpan represents a horizontal line of pixels starting
279 at the pixel with coordinates @x, @y and ending before @x + @width, @y.
282 @x: x coordinate of the first pixel.
283 @y: y coordinate of the first pixel.
284 @width: number of pixels in the span.
286 <!-- ##### USER_FUNCTION GdkSpanFunc ##### -->
288 This defines the type of the function passed to
289 gdk_region_spans_intersect_foreach().
293 @data: the user data passed to gdk_region_spans_intersect_foreach().
296 <!-- ##### FUNCTION gdk_region_spans_intersect_foreach ##### -->
298 Calls a function on each span in the intersection of @region and
302 @region: a #GdkRegion.
303 @spans: an array of #GdkSpans.
304 @n_spans: the length of @spans.
305 @sorted: %TRUE if @spans is sorted wrt. the y coordinate.
306 @function: function to call on each span in the intersection.
307 @data: data to pass to @function.