source: appstream-generator/src/asgen/bindings/cairo.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 4.4 KB
Line 
1/*
2 * Copyright (C) 2016 Matthias Klumpp <matthias@tenstral.net>
3 *
4 * Licensed under the GNU Lesser General Public License Version 3
5 *
6 * This library is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the license, or
9 * (at your option) any later version.
10 *
11 * This software is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20module asgen.bindings.cairo;
21
22extern(C):
23nothrow:
24@nogc:
25static if (!is(typeof(usize))) private alias usize = size_t;
26
27struct _cairo {}
28alias cairo_p = _cairo*;
29
30struct _cairo_surface {}
31alias cairo_surface_p = _cairo_surface*;
32
33struct _cairo_font_face {}
34alias cairo_font_face_p = _cairo_font_face*;
35
36struct cairo_text_extents_t {
37    double x_bearing;
38    double y_bearing;
39    double width;
40    double height;
41    double x_advance;
42    double y_advance;
43};
44
45enum cairo_status_t {
46    STATUS_SUCCESS = 0,
47
48    STATUS_NO_MEMORY,
49    STATUS_INVALID_RESTORE,
50    STATUS_INVALID_POP_GROUP,
51    STATUS_NO_CURRENT_POINT,
52    STATUS_INVALID_MATRIX,
53    STATUS_INVALID_STATUS,
54    STATUS_NULL_POINTER,
55    STATUS_INVALID_STRING,
56    STATUS_INVALID_PATH_DATA,
57    STATUS_READ_ERROR,
58    STATUS_WRITE_ERROR,
59    STATUS_SURFACE_FINISHED,
60    STATUS_SURFACE_TYPE_MISMATCH,
61    STATUS_PATTERN_TYPE_MISMATCH,
62    STATUS_INVALID_CONTENT,
63    STATUS_INVALID_FORMAT,
64    STATUS_INVALID_VISUAL,
65    STATUS_FILE_NOT_FOUND,
66    STATUS_INVALID_DASH,
67    STATUS_INVALID_DSC_COMMENT,
68    STATUS_INVALID_INDEX,
69    STATUS_CLIP_NOT_REPRESENTABLE,
70    STATUS_TEMP_FILE_ERROR,
71    STATUS_INVALID_STRIDE,
72    STATUS_FONT_TYPE_MISMATCH,
73    STATUS_USER_FONT_IMMUTABLE,
74    STATUS_USER_FONT_ERROR,
75    STATUS_NEGATIVE_COUNT,
76    STATUS_INVALID_CLUSTERS,
77    STATUS_INVALID_SLANT,
78    STATUS_INVALID_WEIGHT,
79    STATUS_INVALID_SIZE,
80    STATUS_USER_FONT_NOT_IMPLEMENTED,
81    STATUS_DEVICE_TYPE_MISMATCH,
82    STATUS_DEVICE_ERROR,
83    STATUS_INVALID_MESH_CONSTRUCTION,
84    STATUS_DEVICE_FINISHED,
85    STATUS_JBIG2_GLOBAL_MISSING,
86
87    STATUS_LAST_STATUS
88};
89
90enum cairo_format_t {
91    FORMAT_INVALID   = -1,
92    FORMAT_ARGB32    = 0,
93    FORMAT_RGB24     = 1,
94    FORMAT_A8        = 2,
95    FORMAT_A1        = 3,
96    FORMAT_RGB16_565 = 4,
97    FORMAT_RGB30     = 5
98};
99
100// Context
101cairo_p cairo_create (cairo_surface_p target);
102cairo_p cairo_reference (cairo_p cr);
103void cairo_destroy (cairo_p cr);
104void cairo_set_source_surface (cairo_p cr, cairo_surface_p surface, double x, double y);
105void cairo_paint (cairo_p cr);
106
107void cairo_save (cairo_p cr);
108void cairo_restore (cairo_p cr);
109
110
111// Surface
112cairo_surface_p cairo_image_surface_create (cairo_format_t format, int width, int height);
113cairo_surface_p cairo_image_surface_create_from_png (const(char) *filename); // Toy API
114void cairo_surface_destroy (cairo_surface_p surface);
115cairo_status_t cairo_surface_status (cairo_surface_p surface);
116int cairo_image_surface_get_width (cairo_surface_p surface);
117int cairo_image_surface_get_height (cairo_surface_p surface);
118cairo_status_t cairo_surface_write_to_png (cairo_surface_p surface, const(char) *filename); // Toy API
119
120void cairo_surface_flush (cairo_surface_p surface);
121ubyte* cairo_image_surface_get_data (cairo_surface_p surface);
122
123// Transformations
124void cairo_scale (cairo_p cr, double sx, double sy);
125void cairo_translate (cairo_p cr, double tx, double ty);
126
127// Drawing
128void cairo_move_to (cairo_p cr, double x, double y);
129void cairo_set_source_rgb (cairo_p cr, double red, double green, double blue);
130
131// Fonts
132import asgen.bindings.freetype;
133cairo_font_face_p cairo_ft_font_face_create_for_ft_face (const(FT_Face) face, int load_flags);
134void cairo_font_face_destroy (cairo_font_face_p font_face);
135cairo_status_t cairo_font_face_status (cairo_font_face_p font_face);
136
137cairo_font_face_p cairo_get_font_face (cairo_p cr);
138void cairo_set_font_face (cairo_p cr, cairo_font_face_p font_face);
139
140void cairo_set_font_size (cairo_p cr, double size);
141void cairo_show_text (cairo_p cr, const(char) *utf8); // Toy API
142
143void cairo_text_extents (cairo_p cr, const(char) *utf8, cairo_text_extents_t *extents);
Note: See TracBrowser for help on using the repository browser.