1Cairo(3)              User Contributed Perl Documentation             Cairo(3)
2
3
4

NAME

6       Cairo - Perl interface to the cairo library
7

SYNOPSIS

9         use Cairo;
10
11         my $surface = Cairo::ImageSurface->create ('argb32', 100, 100);
12         my $cr = Cairo::Context->create ($surface);
13
14         $cr->rectangle (10, 10, 40, 40);
15         $cr->set_source_rgb (0, 0, 0);
16         $cr->fill;
17
18         $cr->rectangle (50, 50, 40, 40);
19         $cr->set_source_rgb (1, 1, 1);
20         $cr->fill;
21
22         $cr->show_page;
23
24         $surface->write_to_png ("output.png");
25

ABSTRACT

27       Cairo provides Perl bindings for the vector graphics library cairo.  It
28       supports multiple output targets, including PNG, PDF and SVG.  Cairo
29       produces identical output on all those targets.
30

API DOCUMENTATION

32       Note that this listing still lacks entries for Cairo::Surfaces and some
33       utility methods.
34
35       Drawing
36
37       Cairo::Context -- The cairo drawing context
38
39       Cairo::Context is the main object used when drawing with Cairo. To draw
40       with Cairo, you create a Cairo::Context, set the target surface, and
41       drawing options for the Cairo::Context, create shapes with methods like
42       "$cr-"move_to> and "$cr->line_to", and then draw shapes with
43       "$cr->stroke" or "$cr->fill".
44
45       Cairo::Context's can be pushed to a stack via "$cr->save". They may
46       then safely be changed, without loosing the current state. Use
47       "$cr->restore" to restore to the saved state.  =over
48
49       $cr = Cairo::Context->create ($surface)
50
51       $surface: Cairo::Surface
52
53       $cr->save
54
55       $cr->restore
56
57       $status = $cr->status
58
59       $surface = $cr->get_target
60
61       $cr->push_group
62
63       $cr->push_group_with_content ($content)
64
65       $content: Cairo::Content
66
67       $pattern = $cr->pop_group
68
69       $cr->pop_group_to_source
70
71       $surface = $cr->get_group_target
72
73       $cr->set_source_rgb ($red, $green, $blue)
74
75       $red: double
76       $green: double
77       $blue: double
78
79       $cr->set_source_rgba ($red, $green, $blue, $alpha)
80
81       $red: double
82       $green: double
83       $blue: double
84       $alpha: double
85
86       $cr->set_source ($source)
87
88       $source: Cairo::Pattern
89
90       $cr->set_source_surface ($surface, $x, $y)
91
92       $surface: Cairo::Surface
93       $x: double
94       $y: double
95
96       $source = $cr->get_source
97
98       $cr->set_antialias ($antialias)
99
100       $antialias: Cairo::Antialias
101
102       $antialias = $cr->get_antialias
103
104       $cr->set_dash ($offset, ...)
105
106       $offset: double
107       ...: list of doubles
108
109       $cr->set_fill_rule ($fill_rule)
110
111       $fill_rule: Cairo::FillRule
112
113       $fill_rule = $cr->get_fill_rule
114
115       $cr->set_line_cap ($line_cap)
116
117       $line_cap: Cairo::LineCap
118
119       $line_cap = $cr->get_line_cap
120
121       $cr->set_line_join ($line_join)
122
123       $line_join: Cairo::LineJoin
124
125       $line_join = $cr->get_line_join
126
127       $cr->set_line_width ($width)
128
129       $width: double
130
131       $width = $cr->get_line_width
132
133       $cr->set_miter_limit ($ limit)
134
135       $limit: double
136
137       $limit = $cr->get_miter_limit
138
139       $cr->set_operator ($op)
140
141       $op: Cairo::Operator
142
143       $op = $cr->get_operator
144
145       $cr->set_tolerance ($tolerance)
146
147       $tolerance: double
148
149       $tolerance = $cr->get_tolerance
150
151       $cr->clip
152
153       $cr->clip_preserve
154
155       $cr->reset_clip
156
157       $cr->fill
158
159       $cr->fill_preserve
160
161       ($x1, $y1, $x2, $y2) = $cr->fill_extents
162
163       $bool = $cr->in_fill ($x, $y)
164
165       $x: double
166       $y: double
167
168       $cr->mask ($pattern)
169
170       $pattern: Cairo::Pattern
171
172       $cr->mask_surface ($surface, $surface_x, $surface_y)
173
174       $surface: Cairo::Surface
175       $surface_x: double
176       $surface_y: double
177
178       $cr->paint
179
180       $cr->paint_with_alpha ($alpha)
181
182       $alpha: double
183
184       $cr->stroke
185
186       $cr->stroke_preserve
187
188       ($x1, $y1, $x2, $y2) = $cr->stroke_extents
189
190       $bool = $cr->in_stroke ($x, $y)
191
192       $x: double
193       $y: double
194
195       $cr->copy_page
196
197       $cr->show_page
198
199       Paths -- Creating paths and manipulating path data
200
201         $path = [
202           { type => "move-to", points => [[1, 2]] },
203           { type => "line-to", points => [[3, 4]] },
204           { type => "curve-to", points => [[5, 6], [7, 8], [9, 10]] },
205           ...
206           { type => "close-path", points => [] },
207         ];
208
209       Cairo::Path is a data structure for holding a path. This data structure
210       serves as the return value for "$cr->copy_path_data" and
211       "$cr->copy_path_data_flat" as well the input value for
212       "$cr->append_path".
213
214       Cairo::Path is represented as an array reference that contains path
215       elements, represented by hash references with two keys: type and
216       points.  The value for type can be either of the following:
217
218       "move-to"
219       "line-to"
220       "curve-to"
221       "close-path"
222
223       The value for points is an array reference which contains zero or more
224       points.  Points are represented as array references that contain two
225       doubles: x and y.  The necessary number of points depends on the type
226       of the path element:
227
228       "move-to": 1 point
229       "line_to": 1 point
230       "curve-to": 3 points
231       "close-path": 0 points
232
233       The semantics and ordering of the coordinate values are consistent with
234       "$cr->move_to", "$cr->line_to", "$cr->curve_to", and "$cr->close_path".
235
236       $path = $cr->copy_path
237
238       $path = $cr->copy_path_flat
239
240       $cr->append_path ($path)
241
242       $path: Cairo::Path
243
244       ($x, $y) = $cr->get_current_point
245
246       $cr->new_path
247
248       $cr->new_sub_path
249
250       $cr->close_path
251
252       $cr->arc ($xc, $yc, $radius, $angle1, $angle2)
253
254       $xc: double
255       $yc: double
256       $radius: double
257       $angle1: double
258       $angle2: double
259
260       $cr->arc_negative ($xc, $yc, $radius, $angle1, $angle2)
261
262       $xc: double
263       $yc: double
264       $radius: double
265       $angle1: double
266       $angle2: double
267
268       $cr->curve_to ($x1, $y1, $x2, $y2, $x3, $y3)
269
270       $x1: double
271       $y1: double
272       $x2: double
273       $y2: double
274       $x3: double
275       $y3: double
276
277       $cr->line_to ($x, $y)
278
279       $x: double
280       $y: double
281
282       $cr->move_to ($x, $y)
283
284       $x: double
285       $y: double
286
287       $cr->rectangle ($x, $y, $width, $height)
288
289       $x: double
290       $y: double
291       $width: double
292       $height: double
293
294       $cr->glyph_path (...)
295
296       ...: list of Cairo::Glyph's
297
298       $cr->text_path ($utf8)
299
300       $utf8: string in utf8 encoding
301
302       $cr->rel_curve_to ($dx1, $dy1, $dx2, $dy2, $dx3, $dy3)
303
304       $dx1: double
305       $dy1: double
306       $dx2: double
307       $dy2: double
308       $dx3: double
309       $dy3: double
310
311       $cr->rel_line_to ($dx, $dy)
312
313       $dx: double
314       $dy: double
315
316       $cr->rel_move_to ($dx, $dy)
317
318       $dx: double
319       $dy: double
320
321       Patterns -- Gradients and filtered sources
322
323       $status = $pattern->status
324
325       $type = $pattern->get_type
326
327       $pattern->set_matrix ($matrix)
328
329       $matrix: Cairo::Matrix
330
331       $matrix = $pattern->get_matrix
332
333       $pattern = Cairo::SolidPattern->create_rgb ($red, $green, $blue)
334
335       $red: double
336       $green: double
337       $blue: double
338
339       $pattern = Cairo::SolidPattern->create_rgba ($red, $green, $blue,
340       $alpha)
341
342       $red: double
343       $green: double
344       $blue: double
345       $alpha: double
346
347       $matrix = $pattern->get_matrix
348
349       $pattern = Cairo::SurfacePattern->create ($surface)
350
351       $surface: Cairo::Surface
352
353       $pattern->set_extend ($extend)
354
355       $extend: Cairo::Extend
356
357       $extend = $pattern->get_extend
358
359       $pattern->set_filter ($filter)
360
361       $filter: Cairo::Filter
362
363       $filter = $pattern->get_filter
364
365       $pattern = Cairo::LinearGradient->create ($x0, $y0, $x1, $y1)
366
367       $x0: double
368       $y0: double
369       $x1: double
370       $y1: double
371
372       $pattern = Cairo::RadialGradient->create ($cx0, $cy0, $radius0, $cx1,
373       $cy1, $radius1)
374
375       $cx0: double
376       $cy0: double
377       $radius0: double
378       $cx1: double
379       $cy1: double
380       $radius1: double
381
382       $pattern->add_color_stop_rgb (double offset, double red, double green,
383       double blue)
384
385       $offset: double
386       $red: double
387       $green: double
388       $blue: double
389
390       $pattern->add_color_stop_rgba (double offset, double red, double green,
391       double blue, double alpha)
392
393       $offset: double
394       $red: double
395       $green: double
396       $blue: double
397       $alpha: double
398
399       Transformations -- Manipulating the current transformation matrix
400
401       $cr->translate ($tx, $ty)
402
403       $tx: double
404       $ty: double
405
406       $cr->scale ($sx, $sy)
407
408       $sx: double
409       $sy: double
410
411       $cr->rotate ($angle)
412
413       $angle: double
414
415       $cr->transform ($matrix)
416
417       $matrix: Cairo::Matrix
418
419       $cr->set_matrix ($matrix)
420
421       $matrix: Cairo::Matrix
422
423       $matrix = $cr->get_matrix
424
425       $cr->identity_matrix
426
427       ($x, $y) = $cr->user_to_device ($x, $y)
428
429       $x: double
430       $y: double
431
432       ($dx, $dy) = $cr->user_to_device_distance ($dx, $dy)
433
434       $dx: double
435       $dy: double
436
437       ($x, $y) = $cr->device_to_user ($x, $y)
438
439       $x: double
440       $y: double
441
442       ($dx, $dy) = $cr->device_to_user_distance ($dx, $dy)
443
444       $dx: double
445       $dy: double
446
447       Text -- Rendering text and sets of glyphs
448
449       Glyphs are represented as anonymous hash references with three keys:
450       index, x and y.  Example:
451
452         my @glyphs = ({ index => 1, x => 2, y => 3 },
453                       { index => 2, x => 3, y => 4 },
454                       { index => 3, x => 4, y => 5 });
455
456       $cr->select_font_face ($family, $slant, $weight)
457
458       $family: string
459       $slant: Cairo::FontSlant
460       $weight: Cairo::FontWeight
461
462       $cr->set_font_size ($size)
463
464       $size: double
465
466       $cr->set_font_matrix ($matrix)
467
468       $matrix: Cairo::Matrix
469
470       $matrix = $cr->get_font_matrix
471
472       $cr->set_font_options ($options)
473
474       $options: Cairo::FontOptions
475
476       $options = $cr->get_font_options
477
478       $cr->set_scaled_font ($scaled_font)
479
480       $scaled_font: Cairo::ScaledFont
481
482       $cr->show_text ($utf8)
483
484       $utf8: string
485
486       $cr->show_glyphs (...)
487
488       ...: list of glyphs
489
490       $face = $cr->get_font_face
491
492       $extents = $cr->font_extents
493
494       $cr->set_font_face ($font_face)
495
496       $font_face: Cairo::FontFace
497
498       $cr->set_scaled_font ($scaled_font)
499
500       $scaled_font: Cairo::ScaledFont
501
502       $extents = $cr->text_extents ($utf8)
503
504       $utf8: string
505
506       $extents = $cr->glyph_extents (...)
507
508       ...: list of glyphs
509
510       Fonts
511
512       Cairo::FontFace -- Base class for fonts
513
514       $status = $font_face->status
515
516       $type = $font_face->get_type
517
518       Scaled Fonts -- Caching metrics for a particular font size
519
520       $scaled_font = Cairo::ScaledFont->create ($font_face, $font_matrix,
521       $ctm, $options)
522
523       $font_face: Cairo::FontFace
524       $font_matrix: Cairo::Matrix
525       $ctm: Cairo::Matrix
526       $options: Cairo::FontOptions
527
528       $status = $scaled_font->status
529
530       $extents = $scaled_font->extents
531
532       $extents = $scaled_font->text_extents ($utf8)
533
534       $utf8: string
535
536       $extents = $scaled_font->glyph_extents (...)
537
538       ...: list of glyphs
539
540       $font_face = $scaled_font->get_font_face
541
542       $options = $scaled_font->get_font_options
543
544       $font_matrix = $scaled_font->get_font_matrix
545
546       $ctm = $scaled_font->get_ctm
547
548       $type = $scaled_font->get_type
549
550       Font Options -- How a font should be rendered
551
552       $font_options = Cairo::FontOptions->create
553
554       $status = $font_options->status
555
556       $font_options->merge ($other)
557
558       $other: Cairo::FontOptions
559
560       $hash = $font_options->hash
561
562       $bools = $font_options->equal ($other)
563
564       $other: Cairo::FontOptions
565
566       $font_options->set_antialias ($antialias)
567
568       $antialias: Cairo::AntiAlias
569
570       $antialias = $font_options->get_antialias
571
572       $font_options->set_subpixel_order ($subpixel_order)
573
574       $subpixel_order: Cairo::SubpixelOrder
575
576       $subpixel_order = $font_options->get_subpixel_order
577
578       $font_options->set_hint_style ($hint_style)
579
580       $hint_style: Cairo::HintStyle
581
582       $hint_style = $font_options->get_hint_style
583
584       $font_options->set_hint_metrics ($hint_metrics)
585
586       $hint_metrics: Cairo::HintMetrics
587
588       $hint_metrics = $font_options->get_hint_metrics
589
590       Utilities
591
592       Version Information -- Run-time and compile-time version checks.
593
594       $version = Cairo->version
595
596       $string = Cairo->version_string
597
598       $version_code = Cairo->VERSION
599
600       $version_code = Cairo->VERSION_ENCODE ($major, $minor, $micro)
601
602       $major: integer
603       $minor: integer
604       $micro: integer
605

SEE ALSO

607       http://cairographics.org/documentation
608           Lists many available resources including tutorials and examples
609
610       http://cairographics.org/manual/
611           Contains the reference manual
612

AUTHORS

614       Ross McFarland <rwmcfa1 at neces dot com>
615       Torsten Schoenfeld <kaffeetisch at gmx dot de>
616
618       Copyright (C) 2004-2007 by the cairo perl team
619
620
621
622perl v5.8.8                       2007-02-25                          Cairo(3)
Impressum