]> Pileus Git - ~andy/gtk/blob - docs/reference/gdk/tmpl/drawing.sgml
new section from Lee Mallabone.
[~andy/gtk] / docs / reference / gdk / tmpl / drawing.sgml
1 <!-- ##### SECTION Title ##### -->
2 Drawing Primitives
3
4 <!-- ##### SECTION Short_Description ##### -->
5 functions for drawing points, lines, arcs, and text.
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 These functions provide support for drawing points, lines, arcs and text
10 onto what are called 'drawables'. Drawables, as the name suggests, are things
11 which support drawing onto them, and are either #GdkWindow or #GdkPixmap
12 objects.
13 </para>
14 <para>
15 Many of the drawing operations take a #GdkGC argument, which represents a
16 graphics context. This #GdkGC contains a number of drawing attributes such
17 as foreground color, background color and line width, and is used to reduce
18 the number of arguments needed for each drawing operation. See the
19 <link linkend="gdk-Graphics-Contexts">Graphics Contexts</link> section for
20 more information.
21 </para>
22
23 <!-- ##### SECTION See_Also ##### -->
24 <para>
25
26 </para>
27
28 <!-- ##### ENUM GdkFill ##### -->
29 <para>
30 Used to specify the way in which drawing operations are performed.
31 See gdk_gc_set_fill().
32 </para>
33
34 @GDK_SOLID: graphics are drawn in a solid color, usually the foreground color
35 of the #GdkGC.
36 @GDK_TILED: graphics are drawn using a tile pixmap. See gdk_gc_set_tile().
37 @GDK_STIPPLED: graphics are drawn with a stipple (a pixmap with a depth of 1).
38 Bits set in the stipple are drawn in the foreground color. Bits not set in the
39 stipple are left as they are. See gdk_gc_set_stipple().
40 @GDK_OPAQUE_STIPPLED: graphics are drawn with a stipple, as in @GDK_STIPPLED,
41 except that the bits not set in the stipple are drawn in the background color
42 instead of being left as they are. See gdk_gc_set_stipple().
43
44 <!-- ##### ENUM GdkFillRule ##### -->
45 <para>
46 The method for determining which pixels are included in a region, when
47 creating a #GdkRegion from a polygon.
48 The fill rule is only relevant for polygons which overlap themselves.
49 </para>
50
51 @GDK_EVEN_ODD_RULE: areas which are overlapped an odd number of times are
52 included in the region, while areas overlapped an even number of times are not.
53 @GDK_WINDING_RULE: overlapping areas are always included.
54
55
56 <!-- ##### ENUM GdkLineStyle ##### -->
57 <para>
58 Used to specify how lines are drawn. See gdk_gc_set_line_attributes().
59 </para>
60
61 @GDK_LINE_SOLID: lines are drawn in a solid color, the foreground color.
62 @GDK_LINE_ON_OFF_DASH: dashed lines are drawn, with the pixels between the
63 dashes left as they are. The #GdkCapStyle is applied to each end of the dashes.
64 @GDK_LINE_DOUBLE_DASH: dashed lines are drawn, alternating between the
65 foreground and background colors. The %GDK_CAP_BUTT style is used where
66 dashes and gaps meet.
67
68 <!-- ##### ENUM GdkCapStyle ##### -->
69 <para>
70 Used to specify how the ends of lines and dashes are drawn.
71 See gdk_gc_set_line_attributes().
72 </para>
73
74 @GDK_CAP_NOT_LAST: this is equivalent to %GDK_CAP_BUTT, except that for a line
75 width of 0 the final endpoint is not drawn.
76 @GDK_CAP_BUTT: the ends of the line are square with no projection beyond the
77 endpoint.
78 @GDK_CAP_ROUND: the ends of the line are rounded using a circular arc centered
79 on the endpoint. This is equivalent to %GDK_CAP_BUTT when the line width is 0.
80 @GDK_CAP_PROJECTING: the ends of the line are square, but project beyond the
81 endpoint to a distance of half the line width.
82 This is equivalent to %GDK_CAP_BUTT when the line width is 0.
83
84 <!-- ##### ENUM GdkJoinStyle ##### -->
85 <para>
86 Used to specify how the the joins between lines are drawn.
87 See gdk_gc_set_line_attributes().
88 </para>
89
90 @GDK_JOIN_MITER: the ends of the lines are extended to meet at a point.
91 If the angle between the lines is less than 11 degrees, %GDK_JOIN_BEVEL is
92 used instead.
93 @GDK_JOIN_ROUND: the ends of the lines are rounded with a circular arc
94 centered on the joinpoint, with a diameter equal to the line width.
95 @GDK_JOIN_BEVEL: the lines have %GDK_CAP_BUTT cap styles, with the triangular
96 notch filled.
97
98 <!-- ##### FUNCTION gdk_draw_point ##### -->
99 <para>
100 Draws a point, using the foreground color and other attributes of the #GdkGC.
101 </para>
102
103 @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
104 @gc: a #GdkGC.
105 @x: the x coordinate of the point.
106 @y: the y coordinate of the point.
107
108
109 <!-- ##### FUNCTION gdk_draw_line ##### -->
110 <para>
111 Draws a line, using the foreground color and other attributes of the #GdkGC.
112 </para>
113
114 @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
115 @gc: a #GdkGC.
116 @x1: the x coordinate of the start point.
117 @y1: the y coordinate of the start point.
118 @x2: the x coordinate of the end point.
119 @y2: the y coordinate of the end point.
120
121
122 <!-- ##### FUNCTION gdk_draw_rectangle ##### -->
123 <para>
124 Draws a rectangular outline or filled rectangle, using the foreground color
125 and other attributes of the #GdkGC.
126 </para>
127 <note>
128 <para>
129 A rectangle drawn filled is 1 pixel smaller in both dimensions than a rectangle
130 outlined. Calling gdk_draw_rectangle (window, gc, TRUE, 0, 0, 20, 20) results
131 in a filled rectangle 20 pixels wide and 20 pixels high. Calling
132 gdk_draw_rectangle (window, gc, FALSE, 0, 0, 20, 20) results in an outlined
133 rectangle with corners at (0, 0), (0, 20), (20, 20), and (20, 0), which
134 makes it 21 pixels wide and 21 pixels high.
135 </para>
136 </note>
137
138 @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
139 @gc: a #GdkGC.
140 @filled: TRUE if the rectangle should be filled.
141 @x: the x coordinate of the left edge of the rectangle.
142 @y: the y coordinate of the top edge of the rectangle.
143 @width: the width of the rectangle.
144 @height: the height of the rectangle.
145
146
147 <!-- ##### FUNCTION gdk_draw_arc ##### -->
148 <para>
149 Draws an arc or a filled 'pie slice'. The arc is defined by the bounding
150 rectangle of the entire ellipse, and the start and end angles of the part of
151 the ellipse to be drawn.
152 </para>
153
154 @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
155 @gc: a #GdkGC.
156 @filled: TRUE if the arc should be filled, producing a 'pie slice'.
157 @x: the x coordinate of the left edge of the bounding rectangle.
158 @y: the y coordinate of the top edge of the bounding rectangle.
159 @width: the width of the bounding rectangle.
160 @height: the height of the bounding rectangle.
161 @angle1: the start angle of the arc, relative to the 3 o'clock position,
162 counter-clockwise, in 1/64ths of a degree.
163 @angle2: the end angle of the arc, similar to @angle1.
164
165
166 <!-- ##### FUNCTION gdk_draw_polygon ##### -->
167 <para>
168 Draws an outlined or filled polygon.
169 </para>
170
171 @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
172 @gc: a #GdkGC.
173 @filled: TRUE if the polygon should be filled. The polygon is closed
174 automatically, connecting the last point to the first point if necessary.
175 @points: an array of #GdkPoint structures specifying the points making up the
176 polygon.
177 @npoints: the number of points.
178
179
180 <!-- ##### FUNCTION gdk_draw_string ##### -->
181 <para>
182 Draws a string of characters in the given font or fontset.
183 </para>
184
185 @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
186 @font: a #GdkFont.
187 q@gc: a #GdkGC.
188 @x: the x coordinate of the left edge of the text.
189 @y: the y coordinate of the baseline of the text.
190 @string: the string of characters to draw.
191
192
193 <!-- ##### FUNCTION gdk_draw_text ##### -->
194 <para>
195 Draws a number of characters in the given font or fontset.
196 </para>
197
198 @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
199 @font: a #GdkFont.
200 @gc: a #GdkGC.
201 @x: the x coordinate of the left edge of the text.
202 @y: the y coordinate of the baseline of the text.
203 @text: the characters to draw.
204 @text_length: the number of characters of @text to draw.
205
206
207 <!-- ##### FUNCTION gdk_draw_text_wc ##### -->
208 <para>
209 Draws a number of wide characters using the given font of fontset.
210 If the font is a 1-byte font, the string is converted into 1-byte characters
211 (discarding the high bytes) before output.
212 </para>
213
214 @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
215 @font: a #GdkFont.
216 @gc: a #GdkGC.
217 @x: the x coordinate of the left edge of the text.
218 @y: the y coordinate of the baseline of the text.
219 @text: the wide characters to draw.
220 @text_length: the number of characters to draw.
221
222
223 <!-- ##### FUNCTION gdk_draw_pixmap ##### -->
224 <para>
225 Draws a pixmap, or a part of a pixmap, onto another drawable.
226 </para>
227
228 @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
229 @gc: a #GdkGC.
230 @src: the source #GdkPixmap to draw.
231 @xsrc: the left edge of the source rectangle within @src.
232 @ysrc: the top of the source rectangle within @src.
233 @xdest: the x coordinate of the destination within @drawable.
234 @ydest: the y coordinate of the destination within @drawable.
235 @width: the width of the area to be copied, or -1 to make the area extend to
236 the right edge of the source pixmap.
237 @height: the height of the area to be copied, or -1 to make the area extend
238 to the bottom edge of the source pixmap.
239
240
241 <!-- ##### FUNCTION gdk_draw_bitmap ##### -->
242 <para>
243
244 </para>
245
246 @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
247 @gc: 
248 @src: 
249 @xsrc: 
250 @ysrc: 
251 @xdest: 
252 @ydest: 
253 @width: 
254 @height: 
255
256
257 <!-- ##### FUNCTION gdk_draw_image ##### -->
258 <para>
259
260 </para>
261
262 @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
263 @gc: 
264 @image: 
265 @xsrc: 
266 @ysrc: 
267 @xdest: 
268 @ydest: 
269 @width: 
270 @height: 
271
272
273 <!-- ##### FUNCTION gdk_draw_points ##### -->
274 <para>
275 Draws a number of points, using the foreground color and other attributes of
276 the #GdkGC.
277 </para>
278
279 @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
280 @gc: a #GdkGC.
281 @points: an array of #GdkPoint structures.
282 @npoints: the number of points to be drawn.
283
284
285 <!-- ##### FUNCTION gdk_draw_segments ##### -->
286 <para>
287
288 </para>
289
290 @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
291 @gc: 
292 @segs: 
293 @nsegs: 
294
295
296 <!-- ##### STRUCT GdkSegment ##### -->
297 <para>
298
299 </para>
300
301 @x1: 
302 @y1: 
303 @x2: 
304 @y2: 
305
306 <!-- ##### FUNCTION gdk_draw_lines ##### -->
307 <para>
308 Draws a series of lines connecting the given points.
309 The way in which joins between lines are draw is determined by the
310 #GdkCapStyle value in the #GdkGC. This can be set with
311 gdk_gc_set_line_attributes().
312 </para>
313
314 @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
315 @gc: a #GdkGC.
316 @points: an array of #GdkPoint structures specifying the endpoints of the
317 lines.
318 @npoints: the number of endpoints.
319
320