3
* Copyright (C) 2006-2007 Jürg Billeter
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
* Jürg Billeter <j@bitron.ch>
23
[CCode (cheader_filename = "cairo.h")]
25
[CCode (ref_function = "cairo_reference", unref_function = "cairo_destroy", cname = "cairo_t", cprefix = "cairo_", cheader_filename = "cairo.h")]
26
public class Context {
27
[CCode (cname = "cairo_create")]
28
public Context (Surface target);
29
public Status status ();
31
public void restore ();
33
public weak Surface get_target ();
34
public void push_group ();
35
public void push_group_with_content (Content content);
36
public Pattern pop_group ();
37
public void pop_group_to_source ();
38
public weak Surface get_group_target ();
40
public void set_source_rgb (double red, double green, double blue);
41
public void set_source_rgba (double red, double green, double blue, double alpha);
42
public void set_source (Pattern source);
43
public void set_source_surface (Surface surface, double x, double y);
44
public weak Pattern get_source ();
46
public void set_matrix (Matrix matrix);
47
public void get_matrix (Matrix matrix);
49
public void set_antialias (Antialias antialias);
50
public Antialias get_antialias ();
53
public void set_dash (double[] dashes, int num_dashes, double offset);
55
public void set_fill_rule (FillRule fill_rule);
56
public FillRule get_fill_rule ();
58
public void set_line_cap (LineCap line_cap);
59
public LineCap get_line_cap ();
61
public void set_line_join (LineJoin line_join);
62
public LineJoin get_line_join ();
64
public void set_line_width (double width);
65
public double get_line_width ();
67
public void set_miter_limit (double limit);
68
public double get_miter_limit ();
70
public void set_operator (Operator op);
71
public Operator get_operator ();
73
public void set_tolerance (double tolerance);
74
public double get_tolerance ();
77
public void clip_preserve ();
78
public void reset_clip ();
81
public void fill_preserve ();
82
public void fill_extents (ref double x1, ref double y1, ref double x2, ref double y2);
83
public bool in_fill (double x, double y);
85
public void mask (Pattern pattern);
86
public void mask_surface (Surface surface, double surface_x, double surface_y);
89
public void paint_with_alpha (double alpha);
91
public void stroke ();
92
public void stroke_preserve ();
93
public void stroke_extents (ref double x1, ref double y1, ref double x2, ref double y2);
94
public bool in_stroke (double x, double y);
96
public void copy_page ();
97
public void show_page ();
99
public Path copy_path ();
100
public Path copy_path_flat ();
102
public void append_path (Path path);
104
public void get_current_point (ref double x, ref double y);
106
public void new_path ();
107
public void new_sub_path ();
108
public void close_path ();
110
public void arc (double xc, double yc, double radius, double angle1, double angle2);
111
public void arc_negative (double xc, double yc, double radius, double angle1, double angle2);
113
public void curve_to (double x1, double y1, double x2, double y2, double x3, double y3);
114
public void line_to (double x, double y);
115
public void move_to (double x, double y);
117
public void rectangle (double x, double y, double width, double height);
120
public void glyph_path (Glyph[] glyphs, int num_glyphs);
121
public void text_path (string! utf8);
123
public void rel_curve_to (double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
124
public void rel_line_to (double dx, double dy);
125
public void rel_move_to (double dx, double dy);
127
public void translate (double tx, double ty);
128
public void scale (double sx, double sy);
129
public void rotate (double angle);
130
public void transform (Matrix matrix);
131
public void identity_matrix ();
133
public void user_to_device (ref double x, ref double y);
134
public void user_to_device_distance (ref double dx, ref double dy);
135
public void device_to_user (ref double x, ref double y);
136
public void device_to_user_distance (ref double dx, ref double dy);
138
public void select_font_face (string! family, FontSlant slant, FontWeight weight);
139
public void set_font_size (double size);
140
public void set_font_matrix (Matrix! matrix);
141
public void get_font_matrix (Matrix matrix);
142
public void set_font_options (ref FontOptions! options);
143
public void get_font_options (ref FontOptions options);
145
public void show_text (string! utf8);
147
public void show_glyphs (Glyph[] glyphs, int num_glyphs);
149
public weak FontFace get_font_face ();
150
public void font_extents (ref FontExtents extents);
151
public void set_font_face (FontFace font_face);
152
public void set_scaled_font (ScaledFont! font);
153
public void text_extents (string! utf8, ref TextExtents extents);
155
public void glyph_extents (Glyph[] glyphs, int num_glyphs, ref TextExtents extents);
158
public enum Antialias {
165
public enum FillRule {
170
public enum LineCap {
176
public enum LineJoin {
182
public enum Operator {
199
[CCode (free_function = "cairo_path_destroy", cname = "cairo_path_t")]
201
public Status status;
203
public PathData[] data;
207
[CCode (cname = "cairo_path_data_t")]
208
public struct PathData {
209
public PathDataHeader header;
210
public PathDataPoint point;
213
public struct PathDataHeader {
214
public PathDataType type;
218
public struct PathDataPoint {
223
[CCode (cprefix = "CAIRO_PATH_")]
224
public enum PathDataType {
231
[CCode (ref_function = "cairo_pattern_reference", unref_function = "cairo_pattern_destroy", cname = "cairo_pattern_t")]
232
public class Pattern {
233
public void add_color_stop_rgb (double offset, double red, double green, double blue);
234
public void add_color_stop_rgba (double offset, double red, double green, double blue, double alpha);
236
[CCode (cname = "cairo_pattern_create_rgb")]
237
public Pattern.rgb (double red, double green, double blue);
238
[CCode (cname = "cairo_pattern_create_rgba")]
239
public Pattern.rgba (double red, double green, double blue, double alpha);
240
[CCode (cname = "cairo_pattern_create_for_surface")]
241
public Pattern.for_surface (Surface! surface);
242
[CCode (cname = "cairo_pattern_create_linear")]
243
public Pattern.linear (double x0, double y0, double x1, double y1);
244
[CCode (cname = "cairo_pattern_create_radial")]
245
public Pattern.radial (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
247
public Status status ();
249
public void set_extend (Extend extend);
250
public Extend get_extend ();
252
public void set_filter (Filter filter);
253
public Filter get_filter ();
255
public void set_matrix (Matrix matrix);
256
public void get_matrix (Matrix matrix);
258
public PatternType get_type ();
261
[CCode (cname = "cairo_extend_t")]
269
[CCode (cname = "cairo_filter_t")]
279
[CCode (cname = "cairo_pattern_type_t")]
280
public enum PatternType {
287
[CCode (cname = "cairo_glyph_t")]
291
[CCode (cname = "cairo_font_slant_t")]
292
public enum FontSlant {
298
[CCode (cname = "cairo_font_weight_t")]
299
public enum FontWeight {
304
[CCode (ref_function = "cairo_font_face_reference", unref_function = "cairo_font_face_destroy", cname = "cairo_font_face_t")]
305
public class FontFace {
306
public Status status ();
307
public FontType get_type ();
310
[CCode (cname = "cairo_font_type_t")]
311
public enum FontType {
318
[CCode (ref_function = "cairo_scaled_font_reference", unref_function = "cairo_scaled_font_destroy", cname = "cairo_scaled_font_t")]
319
public class ScaledFont {
320
[CCode (cname = "cairo_scaled_font_create")]
321
public ScaledFont (Matrix font_matrix, Matrix ctm, ref FontOptions options);
322
public Status status ();
323
public void extents (ref FontExtents extents);
324
public void text_extents (string! utf8, ref TextExtents extents);
326
public void glyph_extents (Glyph[] glyphs, int num_glyphs, ref TextExtents extents);
327
public weak FontFace get_font_face ();
328
public void get_font_options (ref FontOptions options);
329
public void get_font_matrix (Matrix font_matrix);
330
public void get_ctm (Matrix ctm);
331
public FontType get_type ();
334
[CCode (cname = "cairo_font_extents_t")]
335
public struct FontExtents {
336
public double ascent;
337
public double descent;
338
public double height;
339
public double max_x_advance;
340
public double max_y_advance;
343
[CCode (cname = "cairo_text_extents_t")]
344
public struct TextExtents {
345
public double x_bearing;
346
public double y_bearing;
348
public double height;
349
public double x_advance;
350
public double y_advance;
353
[CCode (copy_function = "cairo_font_options_copy", free_function = "cairo_font_options_destroy", cname = "cairo_font_options_t")]
354
public class FontOptions {
355
[CCode (cname = "cairo_font_options_create")]
356
public FontOptions ();
357
public Status status ();
358
public void merge (FontOptions other);
359
public ulong hash ();
360
public bool equal (FontOptions other);
361
public void set_antialias (Antialias antialias);
362
public Antialias get_antialias ();
363
public void set_subpixel_order (SubpixelOrder subpixel_order);
364
public SubpixelOrder get_subpixel_order ();
365
public void set_hint_style (HintStyle hint_style);
366
public HintStyle get_hint_style ();
367
public void set_hint_metrics (HintMetrics hint_metrics);
368
public HintMetrics get_hint_metrics ();
371
[CCode (cname = "cairo_subpixel_order_t")]
372
public enum SubpixelOrder {
380
[CCode (cname = "cairo_hint_style_t")]
381
public enum HintStyle {
389
[CCode (cname = "cairo_hint_metrics_t")]
390
public enum HintMetrics {
396
[CCode (ref_function = "cairo_surface_reference", unref_function = "cairo_surface_destroy", cname = "cairo_surface_t", cheader_filename = "cairo.h")]
397
public class Surface {
398
[CCode (cname = "cairo_surface_create_similar")]
399
public Surface.similar (Surface! other, Content content, int width, int height);
400
public void finish ();
401
public void flush ();
402
public void get_font_options (ref FontOptions options);
403
public Content get_content ();
404
public void mark_dirty ();
405
public void mark_dirty_rectangle (int x, int y, int width, int height);
406
public void set_device_offset (double x_offset, double y_offset);
407
public void get_device_offset (ref double x_offset, ref double y_offset);
408
public void set_fallback_resolution (double x_pixels_per_inch, double y_pixels_per_inch);
409
public Status status ();
410
public SurfaceType get_type ();
412
public Status write_to_png (string! filename);
413
public Status write_to_png_stream (WriteFunc write_func, pointer closure);
416
public enum Content {
422
public enum SurfaceType {
444
[CCode (cname = "cairo_surface_t")]
445
public class ImageSurface : Surface {
446
[CCode (cname = "cairo_image_surface_create")]
447
public ImageSurface (Format format, int width, int height);
448
[CCode (cname = "cairo_image_surface_create_for_data")]
450
public ImageSurface.for_data (uchar[] data, Format format, int width, int height, int stride);
451
public uchar[] get_data ();
452
public Format get_format ();
453
public int get_width ();
454
public int get_height ();
455
public int get_stride ();
457
[CCode (cname = "cairo_image_surface_create_from_png")]
458
public ImageSurface.from_png (string! filename);
459
[CCode (cname = "cairo_image_surface_create_from_png_stream")]
460
public ImageSurface.from_png_stream (ReadFunc read_func, pointer closure);
463
[CCode (cname = "cairo_surface_t", cheader_filename = "cairo-pdf.h")]
464
public class PdfSurface : Surface {
465
[CCode (cname = "cairo_pdf_surface_create")]
466
public PdfSurface (string! filename, double width_in_points, double height_in_points);
467
[CCode (cname = "cairo_pdf_surface_create_for_stream")]
468
public PdfSurface.for_stream (WriteFunc write_func, pointer closure, double width_in_points, double height_in_points);
469
public void set_size (double width_in_points, double height_in_points);
473
public static delegate Status ReadFunc (pointer closure, uchar[] data, uint length);
475
public static delegate Status WriteFunc (pointer closure, uchar[] data, uint length);
477
[CCode (cname = "cairo_surface_t", cheader_filename = "cairo-ps.h")]
478
public class PsSurface : Surface {
479
[CCode (cname = "cairo_ps_surface_create")]
480
public PsSurface (string! filename, double width_in_points, double height_in_points);
481
[CCode (cname = "cairo_ps_surface_create_for_stream")]
482
public PsSurface.for_stream (WriteFunc write_func, pointer closure, double width_in_points, double height_in_points);
483
public void set_size (double width_in_points, double height_in_points);
484
public void dsc_begin_setup ();
485
public void dsc_begin_page_setup ();
486
public void dsc_comment (string! comment);
489
[CCode (cname = "cairo_surface_t", cheader_filename = "cairo-svg.h")]
490
public class SvgSurface : Surface {
491
[CCode (cname = "cairo_svg_surface_create")]
492
public SvgSurface (string! filename, double width_in_points, double height_in_points);
493
[CCode (cname = "cairo_svg_surface_create_for_stream")]
494
public SvgSurface.for_stream (WriteFunc write_func, pointer closure, double width_in_points, double height_in_points);
495
public void restrict_to_version (SvgVersion version);
497
public static void get_versions (out SvgVersion[] versions, ref int num_versions);
500
[CCode (cname = "cairo_svg_version_t", cprefix = "CAIRO_SVG_")]
501
public enum SvgVersion {
506
[CCode (cname = "cairo_surface_t", cheader_filename = "cairo-xlib.h")]
507
public class XlibSurface : Surface {
508
[CCode (cname = "cairo_xlib_surface_create")]
509
public XlibSurface (pointer dpy, int drawable, pointer visual, int width, int height);
510
[CCode (cname = "cairo_xlib_surface_create_for_bitmap")]
511
public XlibSurface.for_bitmap (pointer dpy, int bitmap, pointer screen, int width, int height);
512
public void set_size (int width, int height);
513
public pointer get_display ();
514
public pointer get_screen ();
515
public void set_drawable (int drawable, int width, int height);
516
public int get_drawable ();
517
public pointer get_visual ();
518
public int get_width ();
519
public int get_height ();
520
public int get_depth ();
523
[CCode (free_function = "g_free", cname = "cairo_matrix_t")]
524
public class Matrix {
525
public void init (double xx, double yx, double xy, double yy, double x0, double y0);
526
public void init_identity ();
527
public void init_translate (double tx, double ty);
528
public void init_scale (double sx, double sy);
529
public void init_rotate (double radians);
530
public void translate (double tx, double ty);
531
public void scale (double sx, double sy);
532
public void rotate (double radians);
533
public Status invert ();
534
public void multiply (Matrix a, Matrix b);
535
public void transform_distance (ref double dx, ref double dy);
536
public void transform_point (ref double x, ref double y);
553
SURFACE_TYPE_MISMATCH,
554
PATTERN_TYPE_MISMATCH,
563
public int version ();
564
public weak string! version_string ();