Debian Codegraph @

doc/defuns-cairo-pattern.xml.texi

raw
1
2 @c %start of fragment
3
4 @deffn Function cairo-pattern-add-color-stop-rgb (@var{pattern}@tie{}@code{<cairo-pattern-t>}) (@var{offset}@tie{}@code{<double>}) (@var{red}@tie{}@code{<double>}) (@var{green}@tie{}@code{<double>}) (@var{blue}@tie{}@code{<double>})
5 Adds an opaque color stop to a gradient pattern. The offset specifies
6 the location along the gradient's control vector. For example, a linear
7 gradient's control vector is from (x0,y0) to (x1,y1) while a radial
8 gradient's control vector is from any point on the start circle to the
9 corresponding point on the end circle.
10
11 The color is specified in the same way as in
12 @code{cairo-set-source-rgb}.
13
14 If two (or more) stops are specified with identical offset values, they
15 will be sorted according to the order in which the stops are added,
16 (stops added earlier will compare less than stops added later). This can
17 be useful for reliably making sharp color transitions instead of the
18 typical blend.
19
20 Note: If the pattern is not a gradient pattern, (eg. a linear or radial
21 pattern), then the pattern will be put into an error status with a
22 status of @samp{CAIRO_STATUS_PATTERN_TYPE_MISMATCH}.
23
24 @table @var
25 @item pattern
26 a @code{<cairo-pattern-t>}
27
28 @item offset
29 an offset in the range [0.0 .. 1.0]
30
31 @item red
32 red component of color
33
34 @item green
35 green component of color
36
37 @item blue
38 blue component of color
39
40 @end table
41
42 @end deffn
43
44 @deffn Function cairo-pattern-add-color-stop-rgba (@var{pattern}@tie{}@code{<cairo-pattern-t>}) (@var{offset}@tie{}@code{<double>}) (@var{red}@tie{}@code{<double>}) (@var{green}@tie{}@code{<double>}) (@var{blue}@tie{}@code{<double>}) (@var{alpha}@tie{}@code{<double>})
45 Adds a translucent color stop to a gradient pattern. The offset
46 specifies the location along the gradient's control vector. For example,
47 a linear gradient's control vector is from (x0,y0) to (x1,y1) while a
48 radial gradient's control vector is from any point on the start circle
49 to the corresponding point on the end circle.
50
51 The color is specified in the same way as in
52 @code{cairo-set-source-rgba}.
53
54 If two (or more) stops are specified with identical offset values, they
55 will be sorted according to the order in which the stops are added,
56 (stops added earlier will compare less than stops added later). This can
57 be useful for reliably making sharp color transitions instead of the
58 typical blend.
59
60 Note: If the pattern is not a gradient pattern, (eg. a linear or radial
61 pattern), then the pattern will be put into an error status with a
62 status of @samp{CAIRO_STATUS_PATTERN_TYPE_MISMATCH}.
63
64 @table @var
65 @item pattern
66 a @code{<cairo-pattern-t>}
67
68 @item offset
69 an offset in the range [0.0 .. 1.0]
70
71 @item red
72 red component of color
73
74 @item green
75 green component of color
76
77 @item blue
78 blue component of color
79
80 @item alpha
81 alpha component of color
82
83 @end table
84
85 @end deffn
86
87 @deffn Function cairo-pattern-get-color-stop-rgba (@var{pattern}@tie{}@code{<cairo-pattern-t>}) (@var{index}@tie{}@code{<int>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-status-t>}) (@var{offset}@tie{}@code{<double>}) (@var{red}@tie{}@code{<double>}) (@var{green}@tie{}@code{<double>}) (@var{blue}@tie{}@code{<double>}) (@var{alpha}@tie{}@code{<double>})
88 Gets the color and offset information at the given @var{index} for a
89 gradient pattern. Values of @var{index} are 0 to 1 less than the number
90 returned by @code{cairo-pattern-get-color-stop-count}.
91
92 @table @var
93 @item pattern
94 a @code{<cairo-pattern-t>}
95
96 @item index
97 index of the stop to return data for
98
99 @item offset
100 return value for the offset of the stop, or @samp{@code{#f}}
101
102 @item red
103 return value for red component of color, or @samp{@code{#f}}
104
105 @item green
106 return value for green component of color, or @samp{@code{#f}}
107
108 @item blue
109 return value for blue component of color, or @samp{@code{#f}}
110
111 @item alpha
112 return value for alpha component of color, or @samp{@code{#f}}
113
114 @item ret
115 @samp{CAIRO_STATUS_SUCCESS}, or @samp{CAIRO_STATUS_INVALID_INDEX} if
116 @var{index} is not valid for the given pattern. If the pattern is not a
117 gradient pattern, @samp{CAIRO_STATUS_PATTERN_TYPE_MISMATCH} is returned.
118
119 @end table
120
121 Since 1.4
122
123 @end deffn
124
125 @deffn Function cairo-pattern-create-rgb (@var{red}@tie{}@code{<double>}) (@var{green}@tie{}@code{<double>}) (@var{blue}@tie{}@code{<double>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-pattern-t >})
126 Creates a new @code{<cairo-pattern-t>} corresponding to an opaque color.
127 The color components are floating point numbers in the range 0 to 1. If
128 the values passed in are outside that range, they will be clamped.
129
130 @table @var
131 @item red
132 red component of the color
133
134 @item green
135 green component of the color
136
137 @item blue
138 blue component of the color
139
140 @item ret
141 the newly created @code{<cairo-pattern-t>} if successful, or an error
142 pattern in case of no memory. The caller owns the returned object and
143 should call @code{cairo-pattern-destroy} when finished with it. This
144 function will always return a valid pointer, but if an error occurred
145 the pattern status will be set to an error. To inspect the status of a
146 pattern use @code{cairo-pattern-status}.
147
148 @end table
149
150 @end deffn
151
152 @deffn Function cairo-pattern-create-rgba (@var{red}@tie{}@code{<double>}) (@var{green}@tie{}@code{<double>}) (@var{blue}@tie{}@code{<double>}) (@var{alpha}@tie{}@code{<double>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-pattern-t >})
153 Creates a new @code{<cairo-pattern-t>} corresponding to a translucent
154 color. The color components are floating point numbers in the range 0 to
155 1. If the values passed in are outside that range, they will be clamped.
156
157 @table @var
158 @item red
159 red component of the color
160
161 @item green
162 green component of the color
163
164 @item blue
165 blue component of the color
166
167 @item alpha
168 alpha component of the color
169
170 @item ret
171 the newly created @code{<cairo-pattern-t>} if successful, or an error
172 pattern in case of no memory. The caller owns the returned object and
173 should call @code{cairo-pattern-destroy} when finished with it. This
174 function will always return a valid pointer, but if an error occurred
175 the pattern status will be set to an error. To inspect the status of a
176 pattern use @code{cairo-pattern-status}.
177
178 @end table
179
180 @end deffn
181
182 @deffn Function cairo-pattern-get-rgba (@var{pattern}@tie{}@code{<cairo-pattern-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-status-t>}) (@var{red}@tie{}@code{<double>}) (@var{green}@tie{}@code{<double>}) (@var{blue}@tie{}@code{<double>}) (@var{alpha}@tie{}@code{<double>})
183 Gets the solid color for a solid color pattern.
184
185 @table @var
186 @item pattern
187 a @code{<cairo-pattern-t>}
188
189 @item red
190 return value for red component of color, or @samp{@code{#f}}
191
192 @item green
193 return value for green component of color, or @samp{@code{#f}}
194
195 @item blue
196 return value for blue component of color, or @samp{@code{#f}}
197
198 @item alpha
199 return value for alpha component of color, or @samp{@code{#f}}
200
201 @item ret
202 @samp{CAIRO_STATUS_SUCCESS}, or
203 @samp{CAIRO_STATUS_PATTERN_TYPE_MISMATCH} if the pattern is not a solid
204 color pattern.
205
206 @end table
207
208 Since 1.4
209
210 @end deffn
211
212 @deffn Function cairo-pattern-create-for-surface (@var{surface}@tie{}@code{<cairo-surface-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-pattern-t >})
213 Create a new @code{<cairo-pattern-t>} for the given surface.
214
215 @table @var
216 @item surface
217 the surface
218
219 @item ret
220 the newly created @code{<cairo-pattern-t>} if successful, or an error
221 pattern in case of no memory. The caller owns the returned object and
222 should call @code{cairo-pattern-destroy} when finished with it. This
223 function will always return a valid pointer, but if an error occurred
224 the pattern status will be set to an error. To inspect the status of a
225 pattern use @code{cairo-pattern-status}.
226
227 @end table
228
229 @end deffn
230
231 @deffn Function cairo-pattern-get-surface (@var{pattern}@tie{}@code{<cairo-pattern-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-status-t>}) (@var{surface}@tie{}@code{<cairo-surface-t*>})
232 Gets the surface of a surface pattern. The reference returned in
233 @var{surface} is owned by the pattern; the caller should call
234 @code{cairo-surface-reference} if the surface is to be retained.
235
236 @table @var
237 @item pattern
238 a @code{<cairo-pattern-t>}
239
240 @item surface
241 return value for surface of pattern, or @samp{@code{#f}}
242
243 @item ret
244 @samp{CAIRO_STATUS_SUCCESS}, or
245 @samp{CAIRO_STATUS_PATTERN_TYPE_MISMATCH} if the pattern is not a
246 surface pattern.
247
248 @end table
249
250 Since 1.4
251
252 @end deffn
253
254 @deffn Function cairo-pattern-create-linear (@var{x0}@tie{}@code{<double>}) (@var{y0}@tie{}@code{<double>}) (@var{x1}@tie{}@code{<double>}) (@var{y1}@tie{}@code{<double>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-pattern-t >})
255 Create a new linear gradient @code{<cairo-pattern-t>} along the line
256 defined by (x0, y0) and (x1, y1). Before using the gradient pattern, a
257 number of color stops should be defined using
258 @code{cairo-pattern-add-color-stop-rgb} or
259 @code{cairo-pattern-add-color-stop-rgba}.
260
261 Note: The coordinates here are in pattern space. For a new pattern,
262 pattern space is identical to user space, but the relationship between
263 the spaces can be changed with @code{cairo-pattern-set-matrix}.
264
265 @table @var
266 @item x0
267 x coordinate of the start point
268
269 @item y0
270 y coordinate of the start point
271
272 @item x1
273 x coordinate of the end point
274
275 @item y1
276 y coordinate of the end point
277
278 @item ret
279 the newly created @code{<cairo-pattern-t>} if successful, or an error
280 pattern in case of no memory. The caller owns the returned object and
281 should call @code{cairo-pattern-destroy} when finished with it. This
282 function will always return a valid pointer, but if an error occurred
283 the pattern status will be set to an error. To inspect the status of a
284 pattern use @code{cairo-pattern-status}.
285
286 @end table
287
288 @end deffn
289
290 @deffn Function cairo-pattern-get-linear-points (@var{pattern}@tie{}@code{<cairo-pattern-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-status-t>}) (@var{x0}@tie{}@code{<double>}) (@var{y0}@tie{}@code{<double>}) (@var{x1}@tie{}@code{<double>}) (@var{y1}@tie{}@code{<double>})
291 Gets the gradient endpoints for a linear gradient.
292
293 @table @var
294 @item pattern
295 a @code{<cairo-pattern-t>}
296
297 @item x0
298 return value for the x coordinate of the first point, or
299 @samp{@code{#f}}
300
301 @item y0
302 return value for the y coordinate of the first point, or
303 @samp{@code{#f}}
304
305 @item x1
306 return value for the x coordinate of the second point, or
307 @samp{@code{#f}}
308
309 @item y1
310 return value for the y coordinate of the second point, or
311 @samp{@code{#f}}
312
313 @item ret
314 @samp{CAIRO_STATUS_SUCCESS}, or
315 @samp{CAIRO_STATUS_PATTERN_TYPE_MISMATCH} if @var{pattern} is not a
316 linear gradient pattern.
317
318 @end table
319
320 Since 1.4
321
322 @end deffn
323
324 @deffn Function cairo-pattern-create-radial (@var{cx0}@tie{}@code{<double>}) (@var{cy0}@tie{}@code{<double>}) (@var{radius0}@tie{}@code{<double>}) (@var{cx1}@tie{}@code{<double>}) (@var{cy1}@tie{}@code{<double>}) (@var{radius1}@tie{}@code{<double>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-pattern-t >})
325 Creates a new radial gradient @code{<cairo-pattern-t>} between the two
326 circles defined by (cx0, cy0, radius0) and (cx1, cy1, radius1). Before
327 using the gradient pattern, a number of color stops should be defined
328 using @code{cairo-pattern-add-color-stop-rgb} or
329 @code{cairo-pattern-add-color-stop-rgba}.
330
331 Note: The coordinates here are in pattern space. For a new pattern,
332 pattern space is identical to user space, but the relationship between
333 the spaces can be changed with @code{cairo-pattern-set-matrix}.
334
335 @table @var
336 @item cx0
337 x coordinate for the center of the start circle
338
339 @item cy0
340 y coordinate for the center of the start circle
341
342 @item radius0
343 radius of the start circle
344
345 @item cx1
346 x coordinate for the center of the end circle
347
348 @item cy1
349 y coordinate for the center of the end circle
350
351 @item radius1
352 radius of the end circle
353
354 @item ret
355 the newly created @code{<cairo-pattern-t>} if successful, or an error
356 pattern in case of no memory. The caller owns the returned object and
357 should call @code{cairo-pattern-destroy} when finished with it. This
358 function will always return a valid pointer, but if an error occurred
359 the pattern status will be set to an error. To inspect the status of a
360 pattern use @code{cairo-pattern-status}.
361
362 @end table
363
364 @end deffn
365
366 @deffn Function cairo-pattern-get-radial-circles (@var{pattern}@tie{}@code{<cairo-pattern-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-status-t>}) (@var{x0}@tie{}@code{<double>}) (@var{y0}@tie{}@code{<double>}) (@var{r0}@tie{}@code{<double>}) (@var{x1}@tie{}@code{<double>}) (@var{y1}@tie{}@code{<double>}) (@var{r1}@tie{}@code{<double>})
367 Gets the gradient endpoint circles for a radial gradient, each specified
368 as a center coordinate and a radius.
369
370 @table @var
371 @item pattern
372 a @code{<cairo-pattern-t>}
373
374 @item x0
375 return value for the x coordinate of the center of the first circle, or
376 @samp{@code{#f}}
377
378 @item y0
379 return value for the y coordinate of the center of the first circle, or
380 @samp{@code{#f}}
381
382 @item r0
383 return value for the radius of the first circle, or @samp{@code{#f}}
384
385 @item x1
386 return value for the x coordinate of the center of the second circle, or
387 @samp{@code{#f}}
388
389 @item y1
390 return value for the y coordinate of the center of the second circle, or
391 @samp{@code{#f}}
392
393 @item r1
394 return value for the radius of the second circle, or @samp{@code{#f}}
395
396 @item ret
397 @samp{CAIRO_STATUS_SUCCESS}, or
398 @samp{CAIRO_STATUS_PATTERN_TYPE_MISMATCH} if @var{pattern} is not a
399 radial gradient pattern.
400
401 @end table
402
403 Since 1.4
404
405 @end deffn
406
407 @deffn Function cairo-pattern-set-extend (@var{pattern}@tie{}@code{<cairo-pattern-t>}) (@var{extend}@tie{}@code{<cairo-extend-t>})
408 Sets the mode to be used for drawing outside the area of a pattern. See
409 @code{<cairo-extend-t>} for details on the semantics of each extend
410 strategy.
411
412 The default extend mode is @samp{CAIRO_EXTEND_NONE} for surface patterns
413 and @samp{CAIRO_EXTEND_PAD} for gradient patterns.
414
415 @table @var
416 @item pattern
417 a @code{<cairo-pattern-t>}
418
419 @item extend
420 a @code{<cairo-extend-t>} describing how the area outside of the pattern
421 will be drawn
422
423 @end table
424
425 @end deffn
426
427 @deffn Function cairo-pattern-get-extend (@var{pattern}@tie{}@code{<cairo-pattern-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-extend-t>})
428 Gets the current extend mode for a pattern. See @code{<cairo-extend-t>}
429 for details on the semantics of each extend strategy.
430
431 @table @var
432 @item pattern
433 a @code{<cairo-pattern-t>}
434
435 @item ret
436 the current extend strategy used for drawing the pattern.
437
438 @end table
439
440 @end deffn
441
442 @deffn Function cairo-pattern-set-filter (@var{pattern}@tie{}@code{<cairo-pattern-t>}) (@var{filter}@tie{}@code{<cairo-filter-t>})
443 Sets the filter to be used for resizing when using this pattern. See
444 @code{<cairo-filter-t>} for details on each filter.
445
446 * Note that you might want to control filtering even when you do not
447 have an explicit @code{<cairo-pattern-t>} object, (for example when
448 using @code{cairo-set-source-surface}). In these cases, it is convenient
449 to use @code{cairo-get-source} to get access to the pattern that cairo
450 creates implicitly. For example:
451
452 @example
453
454 cairo_set_source_surface (cr, image, x, y);
455 cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
456 @end example
457
458 @table @var
459 @item pattern
460 a @code{<cairo-pattern-t>}
461
462 @item filter
463 a @code{<cairo-filter-t>} describing the filter to use for resizing the
464 pattern
465
466 @end table
467
468 @end deffn
469
470 @deffn Function cairo-pattern-get-filter (@var{pattern}@tie{}@code{<cairo-pattern-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-filter-t>})
471 Gets the current filter for a pattern. See @code{<cairo-filter-t>} for
472 details on each filter.
473
474 @table @var
475 @item pattern
476 a @code{<cairo-pattern-t>}
477
478 @item ret
479 the current filter used for resizing the pattern.
480
481 @end table
482
483 @end deffn
484
485 @deffn Function cairo-pattern-set-matrix (@var{pattern}@tie{}@code{<cairo-pattern-t>}) (@var{matrix}@tie{}@code{<cairo-matrix-t>})
486 Sets the pattern's transformation matrix to @var{matrix}. This matrix is
487 a transformation from user space to pattern space.
488
489 When a pattern is first created it always has the identity matrix for
490 its transformation matrix, which means that pattern space is initially
491 identical to user space.
492
493 Important: Please note that the direction of this transformation matrix
494 is from user space to pattern space. This means that if you imagine the
495 flow from a pattern to user space (and on to device space), then
496 coordinates in that flow will be transformed by the inverse of the
497 pattern matrix.
498
499 For example, if you want to make a pattern appear twice as large as it
500 does by default the correct code to use is:
501
502 @example
503
504 cairo_matrix_init_scale (&matrix, 0.5, 0.5);
505 cairo_pattern_set_matrix (pattern, &matrix);
506 @end example
507
508 Meanwhile, using values of 2.0 rather than 0.5 in the code above would
509 cause the pattern to appear at half of its default size.
510
511 Also, please note the discussion of the user-space locking semantics of
512 @code{cairo-set-source}.
513
514 @table @var
515 @item pattern
516 a @code{<cairo-pattern-t>}
517
518 @item matrix
519 a @code{<cairo-matrix-t>}
520
521 @end table
522
523 @end deffn
524
525 @deffn Function cairo-pattern-get-matrix (@var{pattern}@tie{}@code{<cairo-pattern-t>}) (@var{matrix}@tie{}@code{<cairo-matrix-t>})
526 Stores the pattern's transformation matrix into @var{matrix}.
527
528 @table @var
529 @item pattern
530 a @code{<cairo-pattern-t>}
531
532 @item matrix
533 return value for the matrix
534
535 @end table
536
537 @end deffn
538
539 @deffn Function cairo-pattern-get-type (@var{pattern}@tie{}@code{<cairo-pattern-t>}) @result{}@tie{} (@var{ret}@tie{}@code{<cairo-pattern-type-t>})
540 This function returns the type a pattern. See
541 @code{<cairo-pattern-type-t>} for available types.
542
543 @table @var
544 @item pattern
545 a @code{<cairo-pattern-t>}
546
547 @item ret
548 The type of @var{pattern}.
549
550 @end table
551
552 Since 1.2
553
554 @end deffn
555
556
557 @c %end of fragment