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 <!-- ##### SECTION Stability_Level ##### -->
39 <!-- ##### STRUCT GdkPoint ##### -->
41 Defines the x and y coordinates of a point.
44 @x: the x coordinate of the point.
45 @y: the y coordinate of the point.
47 <!-- ##### STRUCT GdkRectangle ##### -->
49 Defines the position and size of a rectangle.
52 @x: the x coordinate of the left edge of the rectangle.
53 @y: the y coordinate of the top of the rectangle.
54 @width: the width of the rectangle.
55 @height: the height of the rectangle.
57 <!-- ##### FUNCTION gdk_rectangle_intersect ##### -->
59 Calculates the intersection of two rectangles.
62 @src1: a #GdkRectangle.
63 @src2: a #GdkRectangle.
64 @dest: the intersection of @src1 and @src2.
65 @Returns: %TRUE if the rectangles intersect.
68 <!-- ##### FUNCTION gdk_rectangle_union ##### -->
70 Calculates the union of two rectangles.
71 The union of rectangles @src1 and @src2 is the smallest rectangle which
72 includes both @src1 and @src2 within it.
75 @src1: a #GdkRectangle.
76 @src2: a #GdkRectangle.
77 @dest: the union of @src1 and @src2.
80 <!-- ##### STRUCT GdkRegion ##### -->
82 A GdkRegion represents a set of pixels on the screen.
83 The only user-visible field of the structure is the user_data member, which
84 can be used to attach arbitrary data to the #GdkRegion.
88 <!-- ##### FUNCTION gdk_region_new ##### -->
90 Creates a new empty #GdkRegion.
93 @Returns: a new empty #GdkRegion.
96 <!-- ##### FUNCTION gdk_region_polygon ##### -->
98 Creates a new #GdkRegion using the polygon defined by a number of points.
102 @points: an array of #GdkPoint structs.
103 @npoints: the number of elements in the @points array.
104 @fill_rule: specifies which pixels are included in the region when the polygon
106 @Returns: a new #GdkRegion based on the given polygon.
109 <!-- ##### ENUM GdkFillRule ##### -->
111 The method for determining which pixels are included in a region, when
112 creating a #GdkRegion from a polygon.
113 The fill rule is only relevant for polygons which overlap themselves.
116 @GDK_EVEN_ODD_RULE: areas which are overlapped an odd number of times are
117 included in the region, while areas overlapped an even number of times are not.
118 @GDK_WINDING_RULE: overlapping areas are always included.
120 <!-- ##### FUNCTION gdk_region_copy ##### -->
129 <!-- ##### FUNCTION gdk_region_rectangle ##### -->
138 <!-- ##### FUNCTION gdk_region_destroy ##### -->
140 Destroys a #GdkRegion.
143 @region: a #GdkRegion.
146 <!-- ##### FUNCTION gdk_region_get_clipbox ##### -->
148 Returns the smallest rectangle which includes the entire #GdkRegion.
151 @region: a #GdkRegion.
152 @rectangle: returns the smallest rectangle which includes all of @region.
155 <!-- ##### FUNCTION gdk_region_get_rectangles ##### -->
165 <!-- ##### FUNCTION gdk_region_empty ##### -->
167 Returns %TRUE if the #GdkRegion is empty.
170 @region: a #GdkRegion.
171 @Returns: %TRUE if @region is empty.
174 <!-- ##### FUNCTION gdk_region_equal ##### -->
176 Returns %TRUE if the two regions are the same.
179 @region1: a #GdkRegion.
180 @region2: a #GdkRegion.
181 @Returns: %TRUE if @region1 and @region2 are equal.
184 <!-- ##### FUNCTION gdk_region_point_in ##### -->
186 Returns %TRUE if a point is in a region.
189 @region: a #GdkRegion.
190 @x: the x coordinate of a point.
191 @y: the y coordinate of a point.
192 @Returns: %TRUE if the point is in @region.
195 <!-- ##### FUNCTION gdk_region_rect_in ##### -->
197 Tests whether a rectangle is within a region.
200 @region: a #GdkRegion.
201 @rect: a #GdkRectangle.
202 @Returns: %GDK_OVERLAP_RECTANGLE_IN, %GDK_OVERLAP_RECTANGLE_OUT, or
203 %GDK_OVERLAP_RECTANGLE_PART, depending on whether the rectangle is inside,
204 outside, or partly inside the #GdkRegion, respectively.
207 <!-- ##### ENUM GdkOverlapType ##### -->
209 Specifies the possible values returned by gdk_region_rect_in().
212 @GDK_OVERLAP_RECTANGLE_IN: if the rectangle is inside the #GdkRegion.
213 @GDK_OVERLAP_RECTANGLE_OUT: if the rectangle is outside the #GdkRegion.
214 @GDK_OVERLAP_RECTANGLE_PART: if the rectangle is partly inside the #GdkRegion.
216 <!-- ##### FUNCTION gdk_region_offset ##### -->
218 Moves a region the specified distance.
221 @region: a #GdkRegion.
222 @dx: the distance to move the region horizontally.
223 @dy: the distance to move the region vertically.
226 <!-- ##### FUNCTION gdk_region_shrink ##### -->
228 Resizes a region by the specified amount.
229 Positive values shrink the region. Negative values expand it.
232 @region: a #GdkRegion.
233 @dx: the number of pixels to shrink the region horizontally.
234 @dy: the number of pixels to shrink the region vertically.
237 <!-- ##### FUNCTION gdk_region_union_with_rect ##### -->
246 <!-- ##### FUNCTION gdk_region_intersect ##### -->
254 <!-- ##### FUNCTION gdk_region_union ##### -->
263 <!-- ##### FUNCTION gdk_region_subtract ##### -->
271 <!-- ##### FUNCTION gdk_region_xor ##### -->
279 <!-- ##### STRUCT GdkSpan ##### -->
281 A GdkSpan represents a horizontal line of pixels starting
282 at the pixel with coordinates @x, @y and ending before @x + @width, @y.
285 @x: x coordinate of the first pixel.
286 @y: y coordinate of the first pixel.
287 @width: number of pixels in the span.
289 <!-- ##### USER_FUNCTION GdkSpanFunc ##### -->
291 This defines the type of the function passed to
292 gdk_region_spans_intersect_foreach().
296 @data: the user data passed to gdk_region_spans_intersect_foreach().
299 <!-- ##### FUNCTION gdk_region_spans_intersect_foreach ##### -->
301 Calls a function on each span in the intersection of @region and
305 @region: a #GdkRegion.
306 @spans: an array of #GdkSpans.
307 @n_spans: the length of @spans.
308 @sorted: %TRUE if @spans is sorted wrt. the y coordinate.
309 @function: function to call on each span in the intersection.
310 @data: data to pass to @function.