3 * Copyright (C) 2006-2009 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")]
26 [CCode (ref_function = "cairo_reference", unref_function = "cairo_destroy", cname = "cairo_t", cprefix = "cairo_", cheader_filename = "cairo.h")]
27 public class Context {
28 [CCode (cname = "cairo_create")]
29 public Context (Surface target);
30 public Status status ();
32 public void restore ();
34 public weak Surface get_target ();
35 public void push_group ();
36 public void push_group_with_content (Content content);
37 public Pattern pop_group ();
38 public void pop_group_to_source ();
39 public weak Surface get_group_target ();
41 public void set_source_rgb (double red, double green, double blue);
42 public void set_source_rgba (double red, double green, double blue, double alpha);
43 public void set_source (Pattern source);
44 public void set_source_surface (Surface surface, double x, double y);
45 public weak Pattern get_source ();
47 public void set_matrix (Matrix matrix);
48 public void get_matrix (out Matrix matrix);
50 public void set_antialias (Antialias antialias);
51 public Antialias get_antialias ();
53 public void set_dash (double[]? 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);
119 public void glyph_path (Glyph[] glyphs);
120 public void text_path (string utf8);
122 public void rel_curve_to (double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
123 public void rel_line_to (double dx, double dy);
124 public void rel_move_to (double dx, double dy);
126 public void translate (double tx, double ty);
127 public void scale (double sx, double sy);
128 public void rotate (double angle);
129 public void transform (Matrix matrix);
130 public void identity_matrix ();
132 public void user_to_device (ref double x, ref double y);
133 public void user_to_device_distance (ref double dx, ref double dy);
134 public void device_to_user (ref double x, ref double y);
135 public void device_to_user_distance (ref double dx, ref double dy);
137 public void select_font_face (string family, FontSlant slant, FontWeight weight);
138 public void set_font_size (double size);
139 public void set_font_matrix (Matrix matrix);
140 public void get_font_matrix (out Matrix matrix);
141 public void set_font_options (ref FontOptions options);
142 public void get_font_options (ref FontOptions options);
144 public void show_text (string utf8);
145 public void show_glyphs (Glyph[] glyphs);
147 public weak FontFace get_font_face ();
148 public void font_extents (out FontExtents extents);
149 public void set_font_face (FontFace font_face);
150 public void set_scaled_font (ScaledFont font);
151 public void text_extents (string utf8, out TextExtents extents);
152 public void glyph_extents (Glyph[] glyphs, out TextExtents extents);
155 public enum Antialias {
162 public enum FillRule {
167 public enum LineCap {
173 public enum LineJoin {
179 public enum Operator {
197 [CCode (free_function = "cairo_path_destroy", cname = "cairo_path_t")]
199 public Status status;
200 [CCode (array_length = false)]
201 public PathData[] data;
205 [CCode (cname = "cairo_path_data_t")]
206 public struct PathData {
207 public PathDataHeader header;
208 public PathDataPoint point;
211 public struct PathDataHeader {
212 public PathDataType type;
216 public struct PathDataPoint {
221 [CCode (cprefix = "CAIRO_PATH_")]
222 public enum PathDataType {
230 [CCode (ref_function = "cairo_pattern_reference", unref_function = "cairo_pattern_destroy", cname = "cairo_pattern_t")]
231 public class Pattern {
232 public void add_color_stop_rgb (double offset, double red, double green, double blue);
233 public void add_color_stop_rgba (double offset, double red, double green, double blue, double alpha);
235 [CCode (cname = "cairo_pattern_create_rgb")]
236 public Pattern.rgb (double red, double green, double blue);
237 [CCode (cname = "cairo_pattern_create_rgba")]
238 public Pattern.rgba (double red, double green, double blue, double alpha);
239 [CCode (cname = "cairo_pattern_create_for_surface")]
240 public Pattern.for_surface (Surface surface);
241 [CCode (cname = "cairo_pattern_create_linear")]
242 public Pattern.linear (double x0, double y0, double x1, double y1);
243 [CCode (cname = "cairo_pattern_create_radial")]
244 public Pattern.radial (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
246 public Status status ();
248 public void set_extend (Extend extend);
249 public Extend get_extend ();
251 public void set_filter (Filter filter);
252 public Filter get_filter ();
254 public void set_matrix (Matrix matrix);
255 public void get_matrix (out Matrix matrix);
257 public PatternType get_type ();
260 [CCode (cname = "cairo_extend_t")]
268 [CCode (cname = "cairo_filter_t")]
278 [CCode (cname = "cairo_pattern_type_t")]
279 public enum PatternType {
286 [CCode (cname = "cairo_glyph_t")]
290 [CCode (cname = "cairo_font_slant_t")]
291 public enum FontSlant {
297 [CCode (cname = "cairo_font_weight_t")]
298 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 {
319 [CCode (ref_function = "cairo_scaled_font_reference", unref_function = "cairo_scaled_font_destroy", cname = "cairo_scaled_font_t")]
320 public class ScaledFont {
321 [CCode (cname = "cairo_scaled_font_create")]
322 public ScaledFont (Matrix font_matrix, Matrix ctm, ref FontOptions options);
323 public Status status ();
324 public void extents (ref FontExtents extents);
325 public void text_extents (string utf8, ref TextExtents extents);
326 public void glyph_extents (Glyph[] 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 (out Matrix font_matrix);
330 public void get_ctm (out 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;
354 [CCode (copy_function = "cairo_font_options_copy", free_function = "cairo_font_options_destroy", cname = "cairo_font_options_t")]
355 public class FontOptions {
356 [CCode (cname = "cairo_font_options_create")]
357 public FontOptions ();
358 public Status status ();
359 public void merge (FontOptions other);
360 public ulong hash ();
361 public bool equal (FontOptions other);
362 public void set_antialias (Antialias antialias);
363 public Antialias get_antialias ();
364 public void set_subpixel_order (SubpixelOrder subpixel_order);
365 public SubpixelOrder get_subpixel_order ();
366 public void set_hint_style (HintStyle hint_style);
367 public HintStyle get_hint_style ();
368 public void set_hint_metrics (HintMetrics hint_metrics);
369 public HintMetrics get_hint_metrics ();
372 [CCode (cname = "cairo_subpixel_order_t")]
373 public enum SubpixelOrder {
381 [CCode (cname = "cairo_hint_style_t")]
382 public enum HintStyle {
390 [CCode (cname = "cairo_hint_metrics_t")]
391 public enum HintMetrics {
398 [CCode (ref_function = "cairo_surface_reference", unref_function = "cairo_surface_destroy", cname = "cairo_surface_t", cheader_filename = "cairo.h")]
399 public class Surface {
400 [CCode (cname = "cairo_surface_create_similar")]
401 public Surface.similar (Surface other, Content content, int width, int height);
402 public void finish ();
403 public void flush ();
404 public void get_font_options (ref FontOptions options);
405 public Content get_content ();
406 public void mark_dirty ();
407 public void mark_dirty_rectangle (int x, int y, int width, int height);
408 public void set_device_offset (double x_offset, double y_offset);
409 public void get_device_offset (ref double x_offset, ref double y_offset);
410 public void set_fallback_resolution (double x_pixels_per_inch, double y_pixels_per_inch);
411 public Status status ();
412 public SurfaceType get_type ();
414 public Status write_to_png (string filename);
415 public Status write_to_png_stream (WriteFunc write_func, void* closure);
418 public enum Content {
424 public enum SurfaceType {
447 [CCode (cname = "cairo_surface_t")]
448 public class ImageSurface : Surface {
449 [CCode (cname = "cairo_image_surface_create")]
450 public ImageSurface (Format format, int width, int height);
451 [CCode (cname = "cairo_image_surface_create_for_data")]
452 public ImageSurface.for_data ([CCode (array_length = false)] uchar[] data, Format format, int width, int height, int stride);
453 public uchar[] get_data ();
454 public Format get_format ();
455 public int get_width ();
456 public int get_height ();
457 public int get_stride ();
459 [CCode (cname = "cairo_image_surface_create_from_png")]
460 public ImageSurface.from_png (string filename);
461 [CCode (cname = "cairo_image_surface_create_from_png_stream")]
462 public ImageSurface.from_png_stream (ReadFunc read_func, void* closure);
466 [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-pdf.h")]
467 public class PdfSurface : Surface {
468 [CCode (cname = "cairo_pdf_surface_create")]
469 public PdfSurface (string filename, double width_in_points, double height_in_points);
470 [CCode (cname = "cairo_pdf_surface_create_for_stream")]
471 public PdfSurface.for_stream (WriteFunc write_func, void* closure, double width_in_points, double height_in_points);
472 public void set_size (double width_in_points, double height_in_points);
475 public static delegate Status ReadFunc (void* closure, uchar[] data);
476 public static delegate Status WriteFunc (void* closure, uchar[] data);
479 [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-ps.h")]
480 public class PsSurface : Surface {
481 [CCode (cname = "cairo_ps_surface_create")]
482 public PsSurface (string filename, double width_in_points, double height_in_points);
483 [CCode (cname = "cairo_ps_surface_create_for_stream")]
484 public PsSurface.for_stream (WriteFunc write_func, void* closure, double width_in_points, double height_in_points);
485 public void set_size (double width_in_points, double height_in_points);
486 public void dsc_begin_setup ();
487 public void dsc_begin_page_setup ();
488 public void dsc_comment (string comment);
492 [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-svg.h")]
493 public class SvgSurface : Surface {
494 [CCode (cname = "cairo_svg_surface_create")]
495 public SvgSurface (string filename, double width_in_points, double height_in_points);
496 [CCode (cname = "cairo_svg_surface_create_for_stream")]
497 public SvgSurface.for_stream (WriteFunc write_func, void* closure, double width_in_points, double height_in_points);
498 public void restrict_to_version (SvgVersion version);
499 public static void get_versions (out SvgVersion[] versions);
502 [CCode (cname = "cairo_svg_version_t", cprefix = "CAIRO_SVG_")]
503 public enum SvgVersion {
509 [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-xlib.h")]
510 public class XlibSurface : Surface {
511 [CCode (cname = "cairo_xlib_surface_create")]
512 public XlibSurface (void* dpy, int drawable, void* visual, int width, int height);
513 [CCode (cname = "cairo_xlib_surface_create_for_bitmap")]
514 public XlibSurface.for_bitmap (void* dpy, int bitmap, void* screen, int width, int height);
515 public void set_size (int width, int height);
516 public void* get_display ();
517 public void* get_screen ();
518 public void set_drawable (int drawable, int width, int height);
519 public int get_drawable ();
520 public void* get_visual ();
521 public int get_width ();
522 public int get_height ();
523 public int get_depth ();
526 [CCode (cname = "cairo_matrix_t")]
527 public struct Matrix {
528 [CCode (cname = "cairo_matrix_init")]
529 public Matrix (double xx, double yx, double xy, double yy, double x0, double y0);
530 [CCode (cname = "cairo_matrix_init_identity")]
531 public Matrix.identity ();
533 public void translate (double tx, double ty);
534 public void scale (double sx, double sy);
535 public void rotate (double radians);
536 public Status invert ();
537 public void multiply (Matrix a, Matrix b);
538 public void transform_distance (ref double dx, ref double dy);
539 public void transform_point (ref double x, ref double y);
556 SURFACE_TYPE_MISMATCH,
557 PATTERN_TYPE_MISMATCH,
566 public int version ();
567 public weak string version_string ();