PageRenderTime 56ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/binding/cairo/cairo.d

http://github.com/wilkie/djehuty
D | 1775 lines | 467 code | 509 blank | 799 comment | 0 complexity | 0a57629c2ff5fe800e1c40d24287ba0e MD5 | raw file
  1. /*
  2. * cairo.d
  3. *
  4. * This file holds bindings to cairo. The original copyright
  5. * is displayed below, but does not pertain to this file.
  6. *
  7. * Author: Dave Wilkinson
  8. *
  9. */
  10. /* Converted to D from cairo.h by htod */
  11. module binding.cairo.cairo;
  12. /* cairo - a vector graphics library with display and print output
  13. *
  14. * Copyright © 2002 University of Southern California
  15. * Copyright © 2005 Red Hat, Inc.
  16. *
  17. * This library is free software; you can redistribute it and/or
  18. * modify it either under the terms of the GNU Lesser General Public
  19. * License version 2.1 as published by the Free Software Foundation
  20. * (the "LGPL") or, at your option, under the terms of the Mozilla
  21. * Public License Version 1.1 (the "MPL"). If you do not alter this
  22. * notice, a recipient may use your version of this file under either
  23. * the MPL or the LGPL.
  24. *
  25. * You should have received a copy of the LGPL along with this library
  26. * in the file COPYING-LGPL-2.1; if not, write to the Free Software
  27. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  28. * You should have received a copy of the MPL along with this library
  29. * in the file COPYING-MPL-1.1
  30. *
  31. * The contents of this file are subject to the Mozilla Public License
  32. * Version 1.1 (the "License"); you may not use this file except in
  33. * compliance with the License. You may obtain a copy of the License at
  34. * http://www.mozilla.org/MPL/
  35. *
  36. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
  37. * OF ANY KIND, either express or implied. See the LGPL or the MPL for
  38. * the specific language governing rights and limitations.
  39. *
  40. * The Original Code is the cairo graphics library.
  41. *
  42. * The Initial Developer of the Original Code is University of Southern
  43. * California.
  44. *
  45. * Contributor(s):
  46. * Carl D. Worth <cworth@cworth.org>
  47. */
  48. public import binding.cairo.features;
  49. public import core.definitions;
  50. extern (C):
  51. int cairo_version();
  52. char * cairo_version_string();
  53. /**
  54. * cairo_bool_t:
  55. *
  56. * #cairo_bool_t is used for boolean values. Returns of type
  57. * #cairo_bool_t will always be either 0 or 1, but testing against
  58. * these values explicitly is not encouraged; just use the
  59. * value as a boolean condition.
  60. *
  61. * <informalexample><programlisting>
  62. * if (cairo_in_stroke (cr, x, y)) {
  63. * /<!-- -->* do something *<!-- -->/
  64. * }
  65. * </programlisting></informalexample>
  66. **/
  67. alias int cairo_bool_t;
  68. /**
  69. * cairo_t:
  70. *
  71. * A #cairo_t contains the current state of the rendering device,
  72. * including coordinates of yet to be drawn shapes.
  73. *
  74. * Cairo contexts, as #cairo_t objects are named, are central to
  75. * cairo and all drawing with cairo is always done to a #cairo_t
  76. * object.
  77. *
  78. * Memory management of #cairo_t is done with
  79. * cairo_reference() and cairo_destroy().
  80. **/
  81. extern (C) struct _cairo;
  82. alias _cairo cairo_t;
  83. /**
  84. * cairo_surface_t:
  85. *
  86. * A #cairo_surface_t represents an image, either as the destination
  87. * of a drawing operation or as source when drawing onto another
  88. * surface. To draw to a #cairo_surface_t, create a cairo context
  89. * with the surface as the target, using cairo_create().
  90. *
  91. * There are different subtypes of #cairo_surface_t for
  92. * different drawing backends; for example, cairo_image_surface_create()
  93. * creates a bitmap image in memory.
  94. * The type of a surface can be queried with cairo_surface_get_type().
  95. *
  96. * Memory management of #cairo_surface_t is done with
  97. * cairo_surface_reference() and cairo_surface_destroy().
  98. **/
  99. extern (C) struct _cairo_surface;
  100. alias _cairo_surface cairo_surface_t;
  101. /**
  102. * cairo_matrix_t:
  103. * @xx: xx component of the affine transformation
  104. * @yx: yx component of the affine transformation
  105. * @xy: xy component of the affine transformation
  106. * @yy: yy component of the affine transformation
  107. * @x0: X translation component of the affine transformation
  108. * @y0: Y translation component of the affine transformation
  109. *
  110. * A #cairo_matrix_t holds an affine transformation, such as a scale,
  111. * rotation, shear, or a combination of those. The transformation of
  112. * a point (x, y) is given by:
  113. * <programlisting>
  114. * x_new = xx * x + xy * y + x0;
  115. * y_new = yx * x + yy * y + y0;
  116. * </programlisting>
  117. **/
  118. struct cairo_matrix_t
  119. {
  120. double xx;
  121. double yx;
  122. double xy;
  123. double yy;
  124. double x0;
  125. double y0;
  126. }
  127. /**
  128. * cairo_pattern_t:
  129. *
  130. * A #cairo_pattern_t represents a source when drawing onto a
  131. * surface. There are different subtypes of #cairo_pattern_t,
  132. * for different types of sources; for example,
  133. * cairo_pattern_create_rgb() creates a pattern for a solid
  134. * opaque color.
  135. *
  136. * Other than various cairo_pattern_create_<emphasis>type</emphasis>
  137. * functions, some of the pattern types can be implicitly created
  138. * using vairous cairo_set_source_<emphasis>type</emphasis> functions;
  139. * for example cairo_set_source_rgb().
  140. *
  141. * The type of a pattern can be queried with cairo_pattern_get_type().
  142. *
  143. * Memory management of #cairo_pattern_t is done with
  144. * cairo_pattern_reference() and cairo_pattern_destroy().
  145. **/
  146. extern (C) struct _cairo_pattern;
  147. alias _cairo_pattern cairo_pattern_t;
  148. /**
  149. * cairo_destroy_func_t:
  150. * @data: The data element being destroyed.
  151. *
  152. * #cairo_destroy_func_t the type of function which is called when a
  153. * data element is destroyed. It is passed the pointer to the data
  154. * element and should free any memory and resources allocated for it.
  155. **/
  156. alias void function(void *data)cairo_destroy_func_t;
  157. /**
  158. * cairo_user_data_key_t:
  159. * @unused: not used; ignore.
  160. *
  161. * #cairo_user_data_key_t is used for attaching user data to cairo
  162. * data structures. The actual contents of the struct is never used,
  163. * and there is no need to initialize the object; only the unique
  164. * address of a #cairo_data_key_t object is used. Typically, you
  165. * would just use the address of a static #cairo_data_key_t object.
  166. **/
  167. struct cairo_user_data_key_t
  168. {
  169. int unused;
  170. }
  171. /**
  172. * cairo_status_t
  173. * @CAIRO_STATUS_SUCCESS: no error has occurred
  174. * @CAIRO_STATUS_NO_MEMORY: out of memory
  175. * @CAIRO_STATUS_INVALID_RESTORE: cairo_restore without matching cairo_save
  176. * @CAIRO_STATUS_INVALID_POP_GROUP: no saved group to pop
  177. * @CAIRO_STATUS_NO_CURRENT_POINT: no current point defined
  178. * @CAIRO_STATUS_INVALID_MATRIX: invalid matrix (not invertible)
  179. * @CAIRO_STATUS_INVALID_STATUS: invalid value for an input cairo_status_t
  180. * @CAIRO_STATUS_NULL_POINTER: NULL pointer
  181. * @CAIRO_STATUS_INVALID_STRING: input string not valid UTF-8
  182. * @CAIRO_STATUS_INVALID_PATH_DATA: input path data not valid
  183. * @CAIRO_STATUS_READ_ERROR: error while reading from input stream
  184. * @CAIRO_STATUS_WRITE_ERROR: error while writing to output stream
  185. * @CAIRO_STATUS_SURFACE_FINISHED: target surface has been finished
  186. * @CAIRO_STATUS_SURFACE_TYPE_MISMATCH: the surface type is not appropriate for the operation
  187. * @CAIRO_STATUS_PATTERN_TYPE_MISMATCH: the pattern type is not appropriate for the operation
  188. * @CAIRO_STATUS_INVALID_CONTENT: invalid value for an input cairo_content_t
  189. * @CAIRO_STATUS_INVALID_FORMAT: invalid value for an input cairo_format_t
  190. * @CAIRO_STATUS_INVALID_VISUAL: invalid value for an input Visual*
  191. * @CAIRO_STATUS_FILE_NOT_FOUND: file not found
  192. * @CAIRO_STATUS_INVALID_DASH: invalid value for a dash setting
  193. * @CAIRO_STATUS_INVALID_DSC_COMMENT: invalid value for a DSC comment (Since 1.2)
  194. * @CAIRO_STATUS_INVALID_INDEX: invalid index passed to getter (Since 1.4)
  195. * @CAIRO_STATUS_CLIP_NOT_REPRESENTABLE: clip region not representable in desired format (Since 1.4)
  196. *
  197. * #cairo_status_t is used to indicate errors that can occur when
  198. * using Cairo. In some cases it is returned directly by functions.
  199. * but when using #cairo_t, the last error, if any, is stored in
  200. * the context and can be retrieved with cairo_status().
  201. *
  202. * New entries may be added in future versions. Use cairo_status_to_string()
  203. * to get a human-readable representation of an error message.
  204. **/
  205. enum cairo_status_t
  206. {
  207. CAIRO_STATUS_SUCCESS = 0,
  208. CAIRO_STATUS_NO_MEMORY,
  209. CAIRO_STATUS_INVALID_RESTORE,
  210. CAIRO_STATUS_INVALID_POP_GROUP,
  211. CAIRO_STATUS_NO_CURRENT_POINT,
  212. CAIRO_STATUS_INVALID_MATRIX,
  213. CAIRO_STATUS_INVALID_STATUS,
  214. CAIRO_STATUS_NULL_POINTER,
  215. CAIRO_STATUS_INVALID_STRING,
  216. CAIRO_STATUS_INVALID_PATH_DATA,
  217. CAIRO_STATUS_READ_ERROR,
  218. CAIRO_STATUS_WRITE_ERROR,
  219. CAIRO_STATUS_SURFACE_FINISHED,
  220. CAIRO_STATUS_SURFACE_TYPE_MISMATCH,
  221. CAIRO_STATUS_PATTERN_TYPE_MISMATCH,
  222. CAIRO_STATUS_INVALID_CONTENT,
  223. CAIRO_STATUS_INVALID_FORMAT,
  224. CAIRO_STATUS_INVALID_VISUAL,
  225. CAIRO_STATUS_FILE_NOT_FOUND,
  226. CAIRO_STATUS_INVALID_DASH,
  227. CAIRO_STATUS_INVALID_DSC_COMMENT,
  228. CAIRO_STATUS_INVALID_INDEX,
  229. CAIRO_STATUS_CLIP_NOT_REPRESENTABLE,
  230. }
  231. /**
  232. * cairo_content_t
  233. * @CAIRO_CONTENT_COLOR: The surface will hold color content only.
  234. * @CAIRO_CONTENT_ALPHA: The surface will hold alpha content only.
  235. * @CAIRO_CONTENT_COLOR_ALPHA: The surface will hold color and alpha content.
  236. *
  237. * #cairo_content_t is used to describe the content that a surface will
  238. * contain, whether color information, alpha information (translucence
  239. * vs. opacity), or both.
  240. *
  241. * Note: The large values here are designed to keep cairo_content_t
  242. * values distinct from cairo_format_t values so that the
  243. * implementation can detect the error if users confuse the two types.
  244. **/
  245. enum cairo_content_t
  246. {
  247. CAIRO_CONTENT_COLOR = 4096,
  248. CAIRO_CONTENT_ALPHA = 8192,
  249. CAIRO_CONTENT_COLOR_ALPHA = 12288,
  250. }
  251. /**
  252. * cairo_write_func_t:
  253. * @closure: the output closure
  254. * @data: the buffer containing the data to write
  255. * @length: the amount of data to write
  256. *
  257. * #cairo_write_func_t is the type of function which is called when a
  258. * backend needs to write data to an output stream. It is passed the
  259. * closure which was specified by the user at the time the write
  260. * function was registered, the data to write and the length of the
  261. * data in bytes. The write function should return
  262. * CAIRO_STATUS_SUCCESS if all the data was successfully written,
  263. * CAIRO_STATUS_WRITE_ERROR otherwise.
  264. *
  265. * Returns: the status code of the write operation
  266. **/
  267. alias cairo_status_t function(void *closure, ubyte *data, uint length)cairo_write_func_t;
  268. /**
  269. * cairo_read_func_t:
  270. * @closure: the input closure
  271. * @data: the buffer into which to read the data
  272. * @length: the amount of data to read
  273. *
  274. * #cairo_read_func_t is the type of function which is called when a
  275. * backend needs to read data from an intput stream. It is passed the
  276. * closure which was specified by the user at the time the read
  277. * function was registered, the buffer to read the data into and the
  278. * length of the data in bytes. The read function should return
  279. * CAIRO_STATUS_SUCCESS if all the data was successfully read,
  280. * CAIRO_STATUS_READ_ERROR otherwise.
  281. *
  282. * Returns: the status code of the read operation
  283. **/
  284. alias cairo_status_t function(void *closure, ubyte *data, uint length)cairo_read_func_t;
  285. /* Functions for manipulating state objects */
  286. cairo_t * cairo_create(cairo_surface_t *target);
  287. cairo_t * cairo_reference(cairo_t *cr);
  288. void cairo_destroy(cairo_t *cr);
  289. uint cairo_get_reference_count(cairo_t *cr);
  290. void * cairo_get_user_data(cairo_t *cr, cairo_user_data_key_t *key);
  291. cairo_status_t cairo_set_user_data(cairo_t *cr, cairo_user_data_key_t *key, void *user_data, cairo_destroy_func_t destroy);
  292. void cairo_save(cairo_t *cr);
  293. void cairo_restore(cairo_t *cr);
  294. void cairo_push_group(cairo_t *cr);
  295. void cairo_push_group_with_content(cairo_t *cr, cairo_content_t content);
  296. cairo_pattern_t * cairo_pop_group(cairo_t *cr);
  297. void cairo_pop_group_to_source(cairo_t *cr);
  298. /* Modify state */
  299. enum cairo_operator_t
  300. {
  301. CAIRO_OPERATOR_CLEAR,
  302. CAIRO_OPERATOR_SOURCE,
  303. CAIRO_OPERATOR_OVER,
  304. CAIRO_OPERATOR_IN,
  305. CAIRO_OPERATOR_OUT,
  306. CAIRO_OPERATOR_ATOP,
  307. CAIRO_OPERATOR_DEST,
  308. CAIRO_OPERATOR_DEST_OVER,
  309. CAIRO_OPERATOR_DEST_IN,
  310. CAIRO_OPERATOR_DEST_OUT,
  311. CAIRO_OPERATOR_DEST_ATOP,
  312. CAIRO_OPERATOR_XOR,
  313. CAIRO_OPERATOR_ADD,
  314. CAIRO_OPERATOR_SATURATE,
  315. }
  316. void cairo_set_operator(cairo_t *cr, cairo_operator_t op);
  317. void cairo_set_source(cairo_t *cr, cairo_pattern_t *source);
  318. void cairo_set_source_rgb(cairo_t *cr, double red, double green, double blue);
  319. void cairo_set_source_rgba(cairo_t *cr, double red, double green, double blue, double alpha);
  320. void cairo_set_source_surface(cairo_t *cr, cairo_surface_t *surface, double x, double y);
  321. void cairo_set_tolerance(cairo_t *cr, double tolerance);
  322. /**
  323. * cairo_antialias_t:
  324. * @CAIRO_ANTIALIAS_DEFAULT: Use the default antialiasing for
  325. * the subsystem and target device
  326. * @CAIRO_ANTIALIAS_NONE: Use a bilevel alpha mask
  327. * @CAIRO_ANTIALIAS_GRAY: Perform single-color antialiasing (using
  328. * shades of gray for black text on a white background, for example).
  329. * @CAIRO_ANTIALIAS_SUBPIXEL: Perform antialiasing by taking
  330. * advantage of the order of subpixel elements on devices
  331. * such as LCD panels
  332. *
  333. * Specifies the type of antialiasing to do when rendering text or shapes.
  334. **/
  335. enum cairo_antialias_t {
  336. CAIRO_ANTIALIAS_DEFAULT,
  337. CAIRO_ANTIALIAS_NONE,
  338. CAIRO_ANTIALIAS_GRAY,
  339. CAIRO_ANTIALIAS_SUBPIXEL,
  340. }
  341. void cairo_set_antialias(cairo_t *cr, cairo_antialias_t antialias);
  342. /**
  343. * cairo_fill_rule_t
  344. * @CAIRO_FILL_RULE_WINDING: If the path crosses the ray from
  345. * left-to-right, counts +1. If the path crosses the ray
  346. * from right to left, counts -1. (Left and right are determined
  347. * from the perspective of looking along the ray from the starting
  348. * point.) If the total count is non-zero, the point will be filled.
  349. * @CAIRO_FILL_RULE_EVEN_ODD: Counts the total number of
  350. * intersections, without regard to the orientation of the contour. If
  351. * the total number of intersections is odd, the point will be
  352. * filled.
  353. *
  354. * #cairo_fill_rule_t is used to select how paths are filled. For both
  355. * fill rules, whether or not a point is included in the fill is
  356. * determined by taking a ray from that point to infinity and looking
  357. * at intersections with the path. The ray can be in any direction,
  358. * as long as it doesn't pass through the end point of a segment
  359. * or have a tricky intersection such as intersecting tangent to the path.
  360. * (Note that filling is not actually implemented in this way. This
  361. * is just a description of the rule that is applied.)
  362. *
  363. * New entries may be added in future versions.
  364. **/
  365. enum cairo_fill_rule_t
  366. {
  367. CAIRO_FILL_RULE_WINDING,
  368. CAIRO_FILL_RULE_EVEN_ODD,
  369. }
  370. void cairo_set_fill_rule(cairo_t *cr, cairo_fill_rule_t fill_rule);
  371. void cairo_set_line_width(cairo_t *cr, double width);
  372. /**
  373. * cairo_line_cap_t
  374. * @CAIRO_LINE_CAP_BUTT: start(stop) the line exactly at the start(end) point
  375. * @CAIRO_LINE_CAP_ROUND: use a round ending, the center of the circle is the end point
  376. * @CAIRO_LINE_CAP_SQUARE: use squared ending, the center of the square is the end point
  377. *
  378. * Specifies how to render the endpoint of a line when stroking.
  379. **/
  380. enum cairo_line_cap_t
  381. {
  382. CAIRO_LINE_CAP_BUTT,
  383. CAIRO_LINE_CAP_ROUND,
  384. CAIRO_LINE_CAP_SQUARE,
  385. }
  386. void cairo_set_line_cap(cairo_t *cr, cairo_line_cap_t line_cap);
  387. /**
  388. * cairo_line_join_t
  389. * @CAIRO_LINE_JOIN_MITER: use a sharp (angled) corner, see
  390. * cairo_set_miter_limit()
  391. * @CAIRO_LINE_JOIN_ROUND: use a rounded join, the center of the circle is the
  392. * joint point
  393. * @CAIRO_LINE_JOIN_BEVEL: use a cut-off join, the join is cut off at half
  394. * the line width from the joint point
  395. *
  396. * Specifies how to render the junction of two lines when stroking.
  397. **/
  398. enum cairo_line_join_t
  399. {
  400. CAIRO_LINE_JOIN_MITER,
  401. CAIRO_LINE_JOIN_ROUND,
  402. CAIRO_LINE_JOIN_BEVEL,
  403. }
  404. void cairo_set_line_join(cairo_t *cr, cairo_line_join_t line_join);
  405. void cairo_set_dash(cairo_t *cr, double *dashes, int num_dashes, double offset);
  406. void cairo_set_miter_limit(cairo_t *cr, double limit);
  407. void cairo_translate(cairo_t *cr, double tx, double ty);
  408. void cairo_scale(cairo_t *cr, double sx, double sy);
  409. void cairo_rotate(cairo_t *cr, double angle);
  410. void cairo_transform(cairo_t *cr, cairo_matrix_t *matrix);
  411. void cairo_set_matrix(cairo_t *cr, cairo_matrix_t *matrix);
  412. void cairo_identity_matrix(cairo_t *cr);
  413. void cairo_user_to_device(cairo_t *cr, double *x, double *y);
  414. void cairo_user_to_device_distance(cairo_t *cr, double *dx, double *dy);
  415. void cairo_device_to_user(cairo_t *cr, double *x, double *y);
  416. void cairo_device_to_user_distance(cairo_t *cr, double *dx, double *dy);
  417. void cairo_new_path(cairo_t *cr);
  418. void cairo_move_to(cairo_t *cr, double x, double y);
  419. void cairo_new_sub_path(cairo_t *cr);
  420. void cairo_line_to(cairo_t *cr, double x, double y);
  421. void cairo_curve_to(cairo_t *cr, double x1, double y1, double x2, double y2, double x3, double y3);
  422. void cairo_arc(cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2);
  423. void cairo_arc_negative(cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2);
  424. /* XXX: NYI
  425. cairo_public void
  426. cairo_arc_to (cairo_t *cr,
  427. double x1, double y1,
  428. double x2, double y2,
  429. double radius);
  430. */
  431. void cairo_rel_move_to(cairo_t *cr, double dx, double dy);
  432. void cairo_rel_line_to(cairo_t *cr, double dx, double dy);
  433. void cairo_rel_curve_to(cairo_t *cr, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
  434. void cairo_rectangle(cairo_t *cr, double x, double y, double width, double height);
  435. /* XXX: NYI
  436. cairo_public void
  437. cairo_stroke_to_path (cairo_t *cr);
  438. */
  439. void cairo_close_path(cairo_t *cr);
  440. /* Painting functions */
  441. void cairo_paint(cairo_t *cr);
  442. void cairo_paint_with_alpha(cairo_t *cr, double alpha);
  443. void cairo_mask(cairo_t *cr, cairo_pattern_t *pattern);
  444. void cairo_mask_surface(cairo_t *cr, cairo_surface_t *surface, double surface_x, double surface_y);
  445. void cairo_stroke(cairo_t *cr);
  446. void cairo_stroke_preserve(cairo_t *cr);
  447. void cairo_fill(cairo_t *cr);
  448. void cairo_fill_preserve(cairo_t *cr);
  449. void cairo_copy_page(cairo_t *cr);
  450. void cairo_show_page(cairo_t *cr);
  451. /* Insideness testing */
  452. cairo_bool_t cairo_in_stroke(cairo_t *cr, double x, double y);
  453. cairo_bool_t cairo_in_fill(cairo_t *cr, double x, double y);
  454. void cairo_stroke_extents(cairo_t *cr, double *x1, double *y1, double *x2, double *y2);
  455. void cairo_fill_extents(cairo_t *cr, double *x1, double *y1, double *x2, double *y2);
  456. /* Clipping */
  457. void cairo_reset_clip(cairo_t *cr);
  458. void cairo_clip(cairo_t *cr);
  459. void cairo_clip_preserve(cairo_t *cr);
  460. void cairo_clip_extents(cairo_t *cr, double *x1, double *y1, double *x2, double *y2);
  461. /**
  462. * cairo_rectangle_t:
  463. * @x: X coordinate of the left side of the rectangle
  464. * @y: Y coordinate of the the top side of the rectangle
  465. * @width: width of the rectangle
  466. * @height: height of the rectangle
  467. *
  468. * A data structure for holding a rectangle.
  469. *
  470. * Since: 1.4
  471. **/
  472. struct _cairo_rectangle
  473. {
  474. double x;
  475. double y;
  476. double width;
  477. double height;
  478. }
  479. alias _cairo_rectangle cairo_rectangle_t;
  480. /**
  481. * cairo_rectangle_list_t:
  482. * @status: Error status of the rectangle list
  483. * @rectangles: Array containing the rectangles
  484. * @num_rectangles: Number of rectangles in this list
  485. *
  486. * A data structure for holding a dynamically allocated
  487. * array of rectangles.
  488. *
  489. * Since: 1.4
  490. **/
  491. struct _cairo_rectangle_list
  492. {
  493. cairo_status_t status;
  494. cairo_rectangle_t *rectangles;
  495. int num_rectangles;
  496. }
  497. alias _cairo_rectangle_list cairo_rectangle_list_t;
  498. cairo_rectangle_list_t * cairo_copy_clip_rectangle_list(cairo_t *cr);
  499. void cairo_rectangle_list_destroy(cairo_rectangle_list_t *rectangle_list);
  500. /* Font/Text functions */
  501. /**
  502. * cairo_scaled_font_t:
  503. *
  504. * A #cairo_scaled_font_t is a font scaled to a particular size and device
  505. * resolution. A cairo_scaled_font_t is most useful for low-level font
  506. * usage where a library or application wants to cache a reference
  507. * to a scaled font to speed up the computation of metrics.
  508. *
  509. * There are various types of scaled fonts, depending on the
  510. * <firstterm>font backend</firstterm> they use. The type of a
  511. * scaled font can be queried using cairo_scaled_font_get_type().
  512. *
  513. * Memory management of #cairo_scaled_font_t is done with
  514. * cairo_scaled_font_reference() and cairo_scaled_font_destroy().
  515. **/
  516. extern (C) struct _cairo_scaled_font;
  517. alias _cairo_scaled_font cairo_scaled_font_t;
  518. /**
  519. * cairo_font_face_t:
  520. *
  521. * A #cairo_font_face_t specifies all aspects of a font other
  522. * than the size or font matrix (a font matrix is used to distort
  523. * a font by sheering it or scaling it unequally in the two
  524. * directions) . A font face can be set on a #cairo_t by using
  525. * cairo_set_font_face(); the size and font matrix are set with
  526. * cairo_set_font_size() and cairo_set_font_matrix().
  527. *
  528. * There are various types of font faces, depending on the
  529. * <firstterm>font backend</firstterm> they use. The type of a
  530. * font face can be queried using cairo_font_face_get_type().
  531. *
  532. * Memory management of #cairo_font_face_t is done with
  533. * cairo_font_face_reference() and cairo_font_face_destroy().
  534. **/
  535. extern(C) struct _cairo_font_face;
  536. alias _cairo_font_face cairo_font_face_t;
  537. /**
  538. * cairo_glyph_t:
  539. * @index: glyph index in the font. The exact interpretation of the
  540. * glyph index depends on the font technology being used.
  541. * @x: the offset in the X direction between the origin used for
  542. * drawing or measuring the string and the origin of this glyph.
  543. * @y: the offset in the Y direction between the origin used for
  544. * drawing or measuring the string and the origin of this glyph.
  545. *
  546. * The #cairo_glyph_t structure holds information about a single glyph
  547. * when drawing or measuring text. A font is (in simple terms) a
  548. * collection of shapes used to draw text. A glyph is one of these
  549. * shapes. There can be multiple glyphs for a single character
  550. * (alternates to be used in different contexts, for example), or a
  551. * glyph can be a <firstterm>ligature</firstterm> of multiple
  552. * characters. Cairo doesn't expose any way of converting input text
  553. * into glyphs, so in order to use the Cairo interfaces that take
  554. * arrays of glyphs, you must directly access the appropriate
  555. * underlying font system.
  556. *
  557. * Note that the offsets given by @x and @y are not cumulative. When
  558. * drawing or measuring text, each glyph is individually positioned
  559. * with respect to the overall origin
  560. **/
  561. struct cairo_glyph_t
  562. {
  563. Culong index;
  564. double x;
  565. double y;
  566. }
  567. /**
  568. * cairo_text_extents_t:
  569. * @x_bearing: the horizontal distance from the origin to the
  570. * leftmost part of the glyphs as drawn. Positive if the
  571. * glyphs lie entirely to the right of the origin.
  572. * @y_bearing: the vertical distance from the origin to the
  573. * topmost part of the glyphs as drawn. Positive only if the
  574. * glyphs lie completely below the origin; will usually be
  575. * negative.
  576. * @width: width of the glyphs as drawn
  577. * @height: height of the glyphs as drawn
  578. * @x_advance:distance to advance in the X direction
  579. * after drawing these glyphs
  580. * @y_advance: distance to advance in the Y direction
  581. * after drawing these glyphs. Will typically be zero except
  582. * for vertical text layout as found in East-Asian languages.
  583. *
  584. * The #cairo_text_extents_t structure stores the extents of a single
  585. * glyph or a string of glyphs in user-space coordinates. Because text
  586. * extents are in user-space coordinates, they are mostly, but not
  587. * entirely, independent of the current transformation matrix. If you call
  588. * <literal>cairo_scale(cr, 2.0, 2.0)</literal>, text will
  589. * be drawn twice as big, but the reported text extents will not be
  590. * doubled. They will change slightly due to hinting (so you can't
  591. * assume that metrics are independent of the transformation matrix),
  592. * but otherwise will remain unchanged.
  593. **/
  594. //C typedef struct {
  595. //C double x_bearing;
  596. //C double y_bearing;
  597. //C double width;
  598. //C double height;
  599. //C double x_advance;
  600. //C double y_advance;
  601. //C } cairo_text_extents_t;
  602. struct cairo_text_extents_t
  603. {
  604. double x_bearing;
  605. double y_bearing;
  606. double width;
  607. double height;
  608. double x_advance;
  609. double y_advance;
  610. }
  611. /**
  612. * cairo_font_extents_t:
  613. * @ascent: the distance that the font extends above the baseline.
  614. * Note that this is not always exactly equal to the maximum
  615. * of the extents of all the glyphs in the font, but rather
  616. * is picked to express the font designer's intent as to
  617. * how the font should align with elements above it.
  618. * @descent: the distance that the font extends below the baseline.
  619. * This value is positive for typical fonts that include
  620. * portions below the baseline. Note that this is not always
  621. * exactly equal to the maximum of the extents of all the
  622. * glyphs in the font, but rather is picked to express the
  623. * font designer's intent as to how the the font should
  624. * align with elements below it.
  625. * @height: the recommended vertical distance between baselines when
  626. * setting consecutive lines of text with the font. This
  627. * is greater than @ascent+@descent by a
  628. * quantity known as the <firstterm>line spacing</firstterm>
  629. * or <firstterm>external leading</firstterm>. When space
  630. * is at a premium, most fonts can be set with only
  631. * a distance of @ascent+@descent between lines.
  632. * @max_x_advance: the maximum distance in the X direction that
  633. * the the origin is advanced for any glyph in the font.
  634. * @max_y_advance: the maximum distance in the Y direction that
  635. * the the origin is advanced for any glyph in the font.
  636. * this will be zero for normal fonts used for horizontal
  637. * writing. (The scripts of East Asia are sometimes written
  638. * vertically.)
  639. *
  640. * The #cairo_font_extents_t structure stores metric information for
  641. * a font. Values are given in the current user-space coordinate
  642. * system.
  643. *
  644. * Because font metrics are in user-space coordinates, they are
  645. * mostly, but not entirely, independent of the current transformation
  646. * matrix. If you call <literal>cairo_scale(cr, 2.0, 2.0)</literal>,
  647. * text will be drawn twice as big, but the reported text extents will
  648. * not be doubled. They will change slightly due to hinting (so you
  649. * can't assume that metrics are independent of the transformation
  650. * matrix), but otherwise will remain unchanged.
  651. **/
  652. struct cairo_font_extents_t
  653. {
  654. double ascent;
  655. double descent;
  656. double height;
  657. double max_x_advance;
  658. double max_y_advance;
  659. }
  660. /**
  661. * cairo_font_slant_t:
  662. * @CAIRO_FONT_SLANT_NORMAL: Upright font style
  663. * @CAIRO_FONT_SLANT_ITALIC: Italic font style
  664. * @CAIRO_FONT_SLANT_OBLIQUE: Oblique font style
  665. *
  666. * Specifies variants of a font face based on their slant.
  667. **/
  668. enum cairo_font_slant_t
  669. {
  670. CAIRO_FONT_SLANT_NORMAL,
  671. CAIRO_FONT_SLANT_ITALIC,
  672. CAIRO_FONT_SLANT_OBLIQUE,
  673. }
  674. /**
  675. * cairo_font_weight_t:
  676. * @CAIRO_FONT_WEIGHT_NORMAL: Normal font weight
  677. * @CAIRO_FONT_WEIGHT_BOLD: Bold font weight
  678. *
  679. * Specifies variants of a font face based on their weight.
  680. **/
  681. enum cairo_font_weight_t
  682. {
  683. CAIRO_FONT_WEIGHT_NORMAL,
  684. CAIRO_FONT_WEIGHT_BOLD,
  685. }
  686. /**
  687. * cairo_subpixel_order_t:
  688. * @CAIRO_SUBPIXEL_ORDER_DEFAULT: Use the default subpixel order for
  689. * for the target device
  690. * @CAIRO_SUBPIXEL_ORDER_RGB: Subpixel elements are arranged horizontally
  691. * with red at the left
  692. * @CAIRO_SUBPIXEL_ORDER_BGR: Subpixel elements are arranged horizontally
  693. * with blue at the left
  694. * @CAIRO_SUBPIXEL_ORDER_VRGB: Subpixel elements are arranged vertically
  695. * with red at the top
  696. * @CAIRO_SUBPIXEL_ORDER_VBGR: Subpixel elements are arranged vertically
  697. * with blue at the top
  698. *
  699. * The subpixel order specifies the order of color elements within
  700. * each pixel on the display device when rendering with an
  701. * antialiasing mode of %CAIRO_ANTIALIAS_SUBPIXEL.
  702. **/
  703. enum cairo_subpixel_order_t
  704. {
  705. CAIRO_SUBPIXEL_ORDER_DEFAULT,
  706. CAIRO_SUBPIXEL_ORDER_RGB,
  707. CAIRO_SUBPIXEL_ORDER_BGR,
  708. CAIRO_SUBPIXEL_ORDER_VRGB,
  709. CAIRO_SUBPIXEL_ORDER_VBGR,
  710. }
  711. /**
  712. * cairo_hint_style_t:
  713. * @CAIRO_HINT_STYLE_DEFAULT: Use the default hint style for
  714. * for font backend and target device
  715. * @CAIRO_HINT_STYLE_NONE: Do not hint outlines
  716. * @CAIRO_HINT_STYLE_SLIGHT: Hint outlines slightly to improve
  717. * contrast while retaining good fidelity to the original
  718. * shapes.
  719. * @CAIRO_HINT_STYLE_MEDIUM: Hint outlines with medium strength
  720. * giving a compromise between fidelity to the original shapes
  721. * and contrast
  722. * @CAIRO_HINT_STYLE_FULL: Hint outlines to maximize contrast
  723. *
  724. * Specifies the type of hinting to do on font outlines. Hinting
  725. * is the process of fitting outlines to the pixel grid in order
  726. * to improve the appearance of the result. Since hinting outlines
  727. * involves distorting them, it also reduces the faithfulness
  728. * to the original outline shapes. Not all of the outline hinting
  729. * styles are supported by all font backends.
  730. *
  731. * New entries may be added in future versions.
  732. **/
  733. enum cairo_hint_style_t
  734. {
  735. CAIRO_HINT_STYLE_DEFAULT,
  736. CAIRO_HINT_STYLE_NONE,
  737. CAIRO_HINT_STYLE_SLIGHT,
  738. CAIRO_HINT_STYLE_MEDIUM,
  739. CAIRO_HINT_STYLE_FULL,
  740. }
  741. /**
  742. * cairo_hint_metrics_t:
  743. * @CAIRO_HINT_METRICS_DEFAULT: Hint metrics in the default
  744. * manner for the font backend and target device
  745. * @CAIRO_HINT_METRICS_OFF: Do not hint font metrics
  746. * @CAIRO_HINT_METRICS_ON: Hint font metrics
  747. *
  748. * Specifies whether to hint font metrics; hinting font metrics
  749. * means quantizing them so that they are integer values in
  750. * device space. Doing this improves the consistency of
  751. * letter and line spacing, however it also means that text
  752. * will be laid out differently at different zoom factors.
  753. **/
  754. //C typedef enum _cairo_hint_metrics {
  755. //C CAIRO_HINT_METRICS_DEFAULT,
  756. //C CAIRO_HINT_METRICS_OFF,
  757. //C CAIRO_HINT_METRICS_ON
  758. //C } cairo_hint_metrics_t;
  759. enum cairo_hint_metrics_t
  760. {
  761. CAIRO_HINT_METRICS_DEFAULT,
  762. CAIRO_HINT_METRICS_OFF,
  763. CAIRO_HINT_METRICS_ON,
  764. }
  765. /**
  766. * cairo_font_options_t:
  767. *
  768. * An opaque structure holding all options that are used when
  769. * rendering fonts.
  770. *
  771. * Individual features of a #cairo_font_options_t can be set or
  772. * accessed using functions named
  773. * cairo_font_options_set_<emphasis>feature_name</emphasis> and
  774. * cairo_font_options_get_<emphasis>feature_name</emphasis>, like
  775. * cairo_font_options_set_antialias() and
  776. * cairo_font_options_get_antialias().
  777. *
  778. * New features may be added to a #cairo_font_options_t in the
  779. * future. For this reason, cairo_font_options_copy(),
  780. * cairo_font_options_equal(), cairo_font_options_merge(), and
  781. * cairo_font_options_hash() should be used to copy, check
  782. * for equality, merge, or compute a hash value of
  783. * #cairo_font_options_t objects.
  784. **/
  785. extern(C) struct _cairo_font_options;
  786. alias _cairo_font_options cairo_font_options_t;
  787. cairo_font_options_t * cairo_font_options_create();
  788. cairo_font_options_t * cairo_font_options_copy(cairo_font_options_t *original);
  789. void cairo_font_options_destroy(cairo_font_options_t *options);
  790. cairo_status_t cairo_font_options_status(cairo_font_options_t *options);
  791. void cairo_font_options_merge(cairo_font_options_t *options, cairo_font_options_t *other);
  792. cairo_bool_t cairo_font_options_equal(cairo_font_options_t *options, cairo_font_options_t *other);
  793. Culong cairo_font_options_hash(cairo_font_options_t *options);
  794. void cairo_font_options_set_antialias(cairo_font_options_t *options, cairo_antialias_t antialias);
  795. cairo_antialias_t cairo_font_options_get_antialias(cairo_font_options_t *options);
  796. void cairo_font_options_set_subpixel_order(cairo_font_options_t *options, cairo_subpixel_order_t subpixel_order);
  797. cairo_subpixel_order_t cairo_font_options_get_subpixel_order(cairo_font_options_t *options);
  798. void cairo_font_options_set_hint_style(cairo_font_options_t *options, cairo_hint_style_t hint_style);
  799. cairo_hint_style_t cairo_font_options_get_hint_style(cairo_font_options_t *options);
  800. void cairo_font_options_set_hint_metrics(cairo_font_options_t *options, cairo_hint_metrics_t hint_metrics);
  801. cairo_hint_metrics_t cairo_font_options_get_hint_metrics(cairo_font_options_t *options);
  802. /* This interface is for dealing with text as text, not caring about the
  803. font object inside the the cairo_t. */
  804. void cairo_select_font_face(cairo_t *cr, char *family, cairo_font_slant_t slant, cairo_font_weight_t weight);
  805. void cairo_set_font_size(cairo_t *cr, double size);
  806. void cairo_set_font_matrix(cairo_t *cr, cairo_matrix_t *matrix);
  807. void cairo_get_font_matrix(cairo_t *cr, cairo_matrix_t *matrix);
  808. void cairo_set_font_options(cairo_t *cr, cairo_font_options_t *options);
  809. void cairo_get_font_options(cairo_t *cr, cairo_font_options_t *options);
  810. void cairo_set_font_face(cairo_t *cr, cairo_font_face_t *font_face);
  811. cairo_font_face_t * cairo_get_font_face(cairo_t *cr);
  812. void cairo_set_scaled_font(cairo_t *cr, cairo_scaled_font_t *scaled_font);
  813. cairo_scaled_font_t * cairo_get_scaled_font(cairo_t *cr);
  814. void cairo_show_text(cairo_t *cr, char *utf8);
  815. void cairo_show_glyphs(cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs);
  816. void cairo_text_path(cairo_t *cr, char *utf8);
  817. void cairo_glyph_path(cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs);
  818. void cairo_text_extents(cairo_t *cr, char *utf8, cairo_text_extents_t *extents);
  819. void cairo_glyph_extents(cairo_t *cr, cairo_glyph_t *glyphs, int num_glyphs, cairo_text_extents_t *extents);
  820. void cairo_font_extents(cairo_t *cr, cairo_font_extents_t *extents);
  821. /* Generic identifier for a font style */
  822. cairo_font_face_t * cairo_font_face_reference(cairo_font_face_t *font_face);
  823. void cairo_font_face_destroy(cairo_font_face_t *font_face);
  824. uint cairo_font_face_get_reference_count(cairo_font_face_t *font_face);
  825. cairo_status_t cairo_font_face_status(cairo_font_face_t *font_face);
  826. /**
  827. * cairo_font_type_t
  828. * @CAIRO_FONT_TYPE_TOY: The font was created using cairo's toy font api
  829. * @CAIRO_FONT_TYPE_FT: The font is of type FreeType
  830. * @CAIRO_FONT_TYPE_WIN32: The font is of type Win32
  831. * @CAIRO_FONT_TYPE_ATSUI: The font is of type ATSUI
  832. *
  833. * #cairo_font_type_t is used to describe the type of a given font
  834. * face or scaled font. The font types are also known as "font
  835. * backends" within cairo.
  836. *
  837. * The type of a font face is determined by the function used to
  838. * create it, which will generally be of the form
  839. * cairo_<emphasis>type</emphasis>_font_face_create. The font face type can be queried
  840. * with cairo_font_face_get_type()
  841. *
  842. * The various cairo_font_face functions can be used with a font face
  843. * of any type.
  844. *
  845. * The type of a scaled font is determined by the type of the font
  846. * face passed to cairo_scaled_font_create. The scaled font type can
  847. * be queried with cairo_scaled_font_get_type()
  848. *
  849. * The various cairo_scaled_font functions can be used with scaled
  850. * fonts of any type, but some font backends also provide
  851. * type-specific functions that must only be called with a scaled font
  852. * of the appropriate type. These functions have names that begin with
  853. * cairo_<emphasis>type</emphasis>_scaled_font such as cairo_ft_scaled_font_lock_face.
  854. *
  855. * The behavior of calling a type-specific function with a scaled font
  856. * of the wrong type is undefined.
  857. *
  858. * New entries may be added in future versions.
  859. *
  860. * Since: 1.2
  861. **/
  862. enum cairo_font_type_t
  863. {
  864. CAIRO_FONT_TYPE_TOY,
  865. CAIRO_FONT_TYPE_FT,
  866. CAIRO_FONT_TYPE_WIN32,
  867. CAIRO_FONT_TYPE_ATSUI,
  868. }
  869. cairo_font_type_t cairo_font_face_get_type(cairo_font_face_t *font_face);
  870. void * cairo_font_face_get_user_data(cairo_font_face_t *font_face, cairo_user_data_key_t *key);
  871. cairo_status_t cairo_font_face_set_user_data(cairo_font_face_t *font_face, cairo_user_data_key_t *key, void *user_data, cairo_destroy_func_t destroy);
  872. /* Portable interface to general font features. */
  873. cairo_scaled_font_t * cairo_scaled_font_create(cairo_font_face_t *font_face, cairo_matrix_t *font_matrix, cairo_matrix_t *ctm, cairo_font_options_t *options);
  874. cairo_scaled_font_t * cairo_scaled_font_reference(cairo_scaled_font_t *scaled_font);
  875. void cairo_scaled_font_destroy(cairo_scaled_font_t *scaled_font);
  876. uint cairo_scaled_font_get_reference_count(cairo_scaled_font_t *scaled_font);
  877. cairo_status_t cairo_scaled_font_status(cairo_scaled_font_t *scaled_font);
  878. cairo_font_type_t cairo_scaled_font_get_type(cairo_scaled_font_t *scaled_font);
  879. void * cairo_scaled_font_get_user_data(cairo_scaled_font_t *scaled_font, cairo_user_data_key_t *key);
  880. cairo_status_t cairo_scaled_font_set_user_data(cairo_scaled_font_t *scaled_font, cairo_user_data_key_t *key, void *user_data, cairo_destroy_func_t destroy);
  881. void cairo_scaled_font_extents(cairo_scaled_font_t *scaled_font, cairo_font_extents_t *extents);
  882. void cairo_scaled_font_text_extents(cairo_scaled_font_t *scaled_font, char *utf8, cairo_text_extents_t *extents);
  883. void cairo_scaled_font_glyph_extents(cairo_scaled_font_t *scaled_font, cairo_glyph_t *glyphs, int num_glyphs, cairo_text_extents_t *extents);
  884. cairo_font_face_t * cairo_scaled_font_get_font_face(cairo_scaled_font_t *scaled_font);
  885. void cairo_scaled_font_get_font_matrix(cairo_scaled_font_t *scaled_font, cairo_matrix_t *font_matrix);
  886. void cairo_scaled_font_get_ctm(cairo_scaled_font_t *scaled_font, cairo_matrix_t *ctm);
  887. void cairo_scaled_font_get_font_options(cairo_scaled_font_t *scaled_font, cairo_font_options_t *options);
  888. /* Query functions */
  889. cairo_operator_t cairo_get_operator(cairo_t *cr);
  890. cairo_pattern_t * cairo_get_source(cairo_t *cr);
  891. double cairo_get_tolerance(cairo_t *cr);
  892. cairo_antialias_t cairo_get_antialias(cairo_t *cr);
  893. void cairo_get_current_point(cairo_t *cr, double *x, double *y);
  894. cairo_fill_rule_t cairo_get_fill_rule(cairo_t *cr);
  895. double cairo_get_line_width(cairo_t *cr);
  896. cairo_line_cap_t cairo_get_line_cap(cairo_t *cr);
  897. cairo_line_join_t cairo_get_line_join(cairo_t *cr);
  898. double cairo_get_miter_limit(cairo_t *cr);
  899. int cairo_get_dash_count(cairo_t *cr);
  900. void cairo_get_dash(cairo_t *cr, double *dashes, double *offset);
  901. void cairo_get_matrix(cairo_t *cr, cairo_matrix_t *matrix);
  902. cairo_surface_t * cairo_get_target(cairo_t *cr);
  903. cairo_surface_t * cairo_get_group_target(cairo_t *cr);
  904. /**
  905. * cairo_path_data_type_t:
  906. * @CAIRO_PATH_MOVE_TO: A move-to operation
  907. * @CAIRO_PATH_LINE_TO: A line-to operation
  908. * @CAIRO_PATH_CURVE_TO: A curve-to operation
  909. * @CAIRO_PATH_CLOSE_PATH: A close-path operation
  910. *
  911. * #cairo_path_data_t is used to describe the type of one portion
  912. * of a path when represented as a #cairo_path_t.
  913. * See #cairo_path_data_t for details.
  914. **/
  915. enum cairo_path_data_type_t
  916. {
  917. CAIRO_PATH_MOVE_TO,
  918. CAIRO_PATH_LINE_TO,
  919. CAIRO_PATH_CURVE_TO,
  920. CAIRO_PATH_CLOSE_PATH,
  921. }
  922. /**
  923. * cairo_path_data_t:
  924. *
  925. * #cairo_path_data_t is used to represent the path data inside a
  926. * #cairo_path_t.
  927. *
  928. * The data structure is designed to try to balance the demands of
  929. * efficiency and ease-of-use. A path is represented as an array of
  930. * #cairo_path_data_t, which is a union of headers and points.
  931. *
  932. * Each portion of the path is represented by one or more elements in
  933. * the array, (one header followed by 0 or more points). The length
  934. * value of the header is the number of array elements for the current
  935. * portion including the header, (ie. length == 1 + # of points), and
  936. * where the number of points for each element type is as follows:
  937. *
  938. * <programlisting>
  939. * %CAIRO_PATH_MOVE_TO: 1 point
  940. * %CAIRO_PATH_LINE_TO: 1 point
  941. * %CAIRO_PATH_CURVE_TO: 3 points
  942. * %CAIRO_PATH_CLOSE_PATH: 0 points
  943. * </programlisting>
  944. *
  945. * The semantics and ordering of the coordinate values are consistent
  946. * with cairo_move_to(), cairo_line_to(), cairo_curve_to(), and
  947. * cairo_close_path().
  948. *
  949. * Here is sample code for iterating through a #cairo_path_t:
  950. *
  951. * <informalexample><programlisting>
  952. * int i;
  953. * cairo_path_t *path;
  954. * cairo_path_data_t *data;
  955. * &nbsp;
  956. * path = cairo_copy_path (cr);
  957. * &nbsp;
  958. * for (i=0; i < path->num_data; i += path->data[i].header.length) {
  959. * data = &amp;path->data[i];
  960. * switch (data->header.type) {
  961. * case CAIRO_PATH_MOVE_TO:
  962. * do_move_to_things (data[1].point.x, data[1].point.y);
  963. * break;
  964. * case CAIRO_PATH_LINE_TO:
  965. * do_line_to_things (data[1].point.x, data[1].point.y);
  966. * break;
  967. * case CAIRO_PATH_CURVE_TO:
  968. * do_curve_to_things (data[1].point.x, data[1].point.y,
  969. * data[2].point.x, data[2].point.y,
  970. * data[3].point.x, data[3].point.y);
  971. * break;
  972. * case CAIRO_PATH_CLOSE_PATH:
  973. * do_close_path_things ();
  974. * break;
  975. * }
  976. * }
  977. * cairo_path_destroy (path);
  978. * </programlisting></informalexample>
  979. *
  980. * As of cairo 1.4, cairo does not mind if there are more elements in
  981. * a portion of the path than needed. Such elements can be used by
  982. * users of the cairo API to hold extra values in the path data
  983. * structure. For this reason, it is recommended that applications
  984. * always use <literal>data->header.length</literal> to
  985. * iterate over the path data, instead of hardcoding the number of
  986. * elements for each element type.
  987. **/
  988. struct _N4
  989. {
  990. cairo_path_data_type_t type;
  991. int length;
  992. }
  993. struct _N5
  994. {
  995. double x;
  996. double y;
  997. }
  998. union cairo_path_data_t
  999. {
  1000. _N4 header;
  1001. _N5 point;
  1002. }
  1003. /**
  1004. * cairo_path_t:
  1005. * @status: the current error status
  1006. * @data: the elements in the path
  1007. * @num_data: the number of elements in the data array
  1008. *
  1009. * A data structure for holding a path. This data structure serves as
  1010. * the return value for cairo_copy_path() and
  1011. * cairo_copy_path_flat() as well the input value for
  1012. * cairo_append_path().
  1013. *
  1014. * See #cairo_path_data_t for hints on how to iterate over the
  1015. * actual data within the path.
  1016. *
  1017. * The num_data member gives the number of elements in the data
  1018. * array. This number is larger than the number of independent path
  1019. * portions (defined in #cairo_path_data_type_t), since the data
  1020. * includes both headers and coordinates for each portion.
  1021. **/
  1022. struct cairo_path_t
  1023. {
  1024. cairo_status_t status;
  1025. cairo_path_data_t *data;
  1026. int num_data;
  1027. }
  1028. cairo_path_t * cairo_copy_path(cairo_t *cr);
  1029. cairo_path_t * cairo_copy_path_flat(cairo_t *cr);
  1030. void cairo_append_path(cairo_t *cr, cairo_path_t *path);
  1031. void cairo_path_destroy(cairo_path_t *path);
  1032. /* Error status queries */
  1033. cairo_status_t cairo_status(cairo_t *cr);
  1034. char * cairo_status_to_string(cairo_status_t status);
  1035. /* Surface manipulation */
  1036. cairo_surface_t * cairo_surface_create_similar(cairo_surface_t *other, cairo_content_t content, int width, int height);
  1037. cairo_surface_t * cairo_surface_reference(cairo_surface_t *surface);
  1038. void cairo_surface_finish(cairo_surface_t *surface);
  1039. void cairo_surface_destroy(cairo_surface_t *surface);
  1040. uint cairo_surface_get_reference_count(cairo_surface_t *surface);
  1041. cairo_status_t cairo_surface_status(cairo_surface_t *surface);
  1042. /**
  1043. * cairo_surface_type_t
  1044. * @CAIRO_SURFACE_TYPE_IMAGE: The surface is of type image
  1045. * @CAIRO_SURFACE_TYPE_PDF: The surface is of type pdf
  1046. * @CAIRO_SURFACE_TYPE_PS: The surface is of type ps
  1047. * @CAIRO_SURFACE_TYPE_XLIB: The surface is of type xlib
  1048. * @CAIRO_SURFACE_TYPE_XCB: The surface is of type xcb
  1049. * @CAIRO_SURFACE_TYPE_GLITZ: The surface is of type glitz
  1050. * @CAIRO_SURFACE_TYPE_QUARTZ: The surface is of type quartz
  1051. * @CAIRO_SURFACE_TYPE_WIN32: The surface is of type win32
  1052. * @CAIRO_SURFACE_TYPE_BEOS: The surface is of type beos
  1053. * @CAIRO_SURFACE_TYPE_DIRECTFB: The surface is of type directfb
  1054. * @CAIRO_SURFACE_TYPE_SVG: The surface is of type svg
  1055. * @CAIRO_SURFACE_TYPE_OS2: The surface is of type os2
  1056. *
  1057. * #cairo_surface_type_t is used to describe the type of a given
  1058. * surface. The surface types are also known as "backends" or "surface
  1059. * backends" within cairo.
  1060. *
  1061. * The type of a surface is determined by the function used to create
  1062. * it, which will generally be of the form cairo_<emphasis>type</emphasis>_surface_create,
  1063. * (though see cairo_surface_create_similar as well).
  1064. *
  1065. * The surface type can be queried with cairo_surface_get_type()
  1066. *
  1067. * The various cairo_surface functions can be used with surfaces of
  1068. * any type, but some backends also provide type-specific functions
  1069. * that must only be called with a surface of the appropriate
  1070. * type. These functions have names that begin with
  1071. * cairo_<emphasis>type</emphasis>_surface such as cairo_image_surface_get_width().
  1072. *
  1073. * The behavior of calling a type-specific function with a surface of
  1074. * the wrong type is undefined.
  1075. *
  1076. * New entries may be added in future versions.
  1077. *
  1078. * Since: 1.2
  1079. **/
  1080. enum cairo_surface_type_t
  1081. {
  1082. CAIRO_SURFACE_TYPE_IMAGE,
  1083. CAIRO_SURFACE_TYPE_PDF,
  1084. CAIRO_SURFACE_TYPE_PS,
  1085. CAIRO_SURFACE_TYPE_XLIB,
  1086. CAIRO_SURFACE_TYPE_XCB,
  1087. CAIRO_SURFACE_TYPE_GLITZ,
  1088. CAIRO_SURFACE_TYPE_QUARTZ,
  1089. CAIRO_SURFACE_TYPE_WIN32,
  1090. CAIRO_SURFACE_TYPE_BEOS,
  1091. CAIRO_SURFACE_TYPE_DIRECTFB,
  1092. CAIRO_SURFACE_TYPE_SVG,
  1093. CAIRO_SURFACE_TYPE_OS2,
  1094. }
  1095. cairo_surface_type_t cairo_surface_get_type(cairo_surface_t *surface);
  1096. cairo_content_t cairo_surface_get_content(cairo_surface_t *surface);
  1097. cairo_status_t cairo_surface_write_to_png(cairo_surface_t *surface, char *filename);
  1098. cairo_status_t cairo_surface_write_to_png_stream(cairo_surface_t *surface, cairo_write_func_t write_func, void *closure);
  1099. void * cairo_surface_get_user_data(cairo_surface_t *surface, cairo_user_data_key_t *key);
  1100. cairo_status_t cairo_surface_set_user_data(cairo_surface_t *surface, cairo_user_data_key_t *key, void *user_data, cairo_destroy_func_t destroy);
  1101. void cairo_surface_get_font_options(cairo_surface_t *surface, cairo_font_options_t *options);
  1102. void cairo_surface_flush(cairo_surface_t *surface);
  1103. void cairo_surface_mark_dirty(cairo_surface_t *surface);
  1104. void cairo_surface_mark_dirty_rectangle(cairo_surface_t *surface, int x, int y, int width, int height);
  1105. void cairo_surface_set_device_offset(cairo_surface_t *surface, double x_offset, double y_offset);
  1106. void cairo_surface_get_device_offset(cairo_surface_t *surface, double *x_offset, double *y_offset);
  1107. void cairo_surface_set_fallback_resolution(cairo_surface_t *surface, double x_pixels_per_inch, double y_pixels_per_inch);
  1108. /* Image-surface functions */
  1109. /**
  1110. * cairo_format_t
  1111. * @CAIRO_FORMAT_ARGB32: each pixel is a 32-bit quantity, with
  1112. * alpha in the upper 8 bits, then red, then green, then blue.
  1113. * The 32-bit quantities are stored native-endian. Pre-multiplied
  1114. * alpha is used. (That is, 50% transparent red is 0x80800000,
  1115. * not 0x80ff0000.)
  1116. * @CAIRO_FORMAT_RGB24: each pixel is a 32-bit quantity, with
  1117. * the upper 8 bits unused. Red, Green, and Blue are stored
  1118. * in the remaining 24 bits in that order.
  1119. * @CAIRO_FORMAT_A8: each pixel is a 8-bit quantity holding
  1120. * an alpha value.
  1121. * @CAIRO_FORMAT_A1: each pixel is a 1-bit quantity holding
  1122. * an alpha value. Pixels are packed together into 32-bit
  1123. * quantities. The ordering of the bits matches the
  1124. * endianess of the platform. On a big-endian machine, the
  1125. * first pixel is in the uppermost bit, on a little-endian
  1126. * machine the first pixel is in the least-significant bit.
  1127. * @CAIRO_FORMAT_RGB16_565: This format value is deprecated. It has
  1128. * never been properly implemented in cairo and should not be used
  1129. * by applications. (since 1.2)
  1130. *
  1131. * #cairo_format_t is used to identify the memory format of
  1132. * image data.
  1133. *
  1134. * New entries may be added in future versions.
  1135. **/
  1136. enum cairo_format_t
  1137. {
  1138. CAIRO_FORMAT_ARGB32,
  1139. CAIRO_FORMAT_RGB24,
  1140. CAIRO_FORMAT_A8,
  1141. CAIRO_FORMAT_A1,
  1142. /* The value of 4 is reserved by a deprecated enum value.
  1143. * The next format added must have an explicit value of 5.
  1144. CAIRO_FORMAT_RGB16_565 = 4,
  1145. */
  1146. }
  1147. cairo_surface_t * cairo_image_surface_create(cairo_format_t format, int width, int height);
  1148. cairo_surface_t * cairo_image_surface_create_for_data(ubyte *data, cairo_format_t format, int width, int height, int stride);
  1149. ubyte * cairo_image_surface_get_data(cairo_surface_t *surface);
  1150. cairo_format_t cairo_image_surface_get_format(cairo_surface_t *surface);
  1151. int cairo_image_surface_get_width(cairo_surface_t *surface);
  1152. int cairo_image_surface_get_height(cairo_surface_t *surface);
  1153. int cairo_image_surface_get_stride(cairo_surface_t *surface);
  1154. cairo_surface_t * cairo_image_surface_create_from_png(char *filename);
  1155. cairo_surface_t * cairo_image_surface_create_from_png_stream(cairo_read_func_t read_func, void *closure);
  1156. /* Pattern creation functions */
  1157. cairo_pattern_t * cairo_pattern_create_rgb(double red, double green, double blue);
  1158. cairo_pattern_t * cairo_pattern_create_rgba(double red, double green, double blue, double alpha);
  1159. cairo_pattern_t * cairo_pattern_create_for_surface(cairo_surface_t *surface);
  1160. cairo_pattern_t * cairo_pattern_create_linear(double x0, double y0, double x1, double y1);
  1161. cairo_pattern_t * cairo_pattern_create_radial(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
  1162. cairo_pattern_t * cairo_pattern_reference(cairo_pattern_t *pattern);
  1163. void cairo_pattern_destroy(cairo_pattern_t *pattern);
  1164. uint cairo_pattern_get_reference_count(cairo_pattern_t *pattern);
  1165. cairo_status_t cairo_pattern_status(cairo_pattern_t *pattern);
  1166. void * cairo_pattern_get_user_data(cairo_pattern_t *pattern, cairo_user_data_key_t *key);
  1167. cairo_status_t cairo_pattern_set_user_data(cairo_pattern_t *pattern, cairo_user_data_key_t *key, void *user_data, cairo_destroy_func_t destroy);
  1168. /**
  1169. * cairo_pattern_type_t
  1170. * @CAIRO_PATTERN_TYPE_SOLID: The pattern is a solid (uniform)
  1171. * color. It may be opaque or translucent.
  1172. * @CAIRO_PATTERN_TYPE_SURFACE: The pattern is a based on a surface (an image).
  1173. * @CAIRO_PATTERN_TYPE_LINEAR: The pattern is a linear gradient.
  1174. * @CAIRO_PATTERN_TYPE_RADIAL: The pattern is a radial gradient.
  1175. *
  1176. * #cairo_pattern_type_t is used to describe the type of a given pattern.
  1177. *
  1178. * The type of a pattern is determined by the function used to create
  1179. * it. The cairo_pattern_create_rgb() and cairo_pattern_create_rgba()
  1180. * functions create SOLID patterns. The remaining
  1181. * cairo_pattern_create functions map to pattern types in obvious
  1182. * ways.
  1183. *
  1184. * The pattern type can be queried with cairo_pattern_get_type()
  1185. *
  1186. * Most cairo_pattern functions can be called with a pattern of any
  1187. * type, (though trying to change the extend or filter for a solid
  1188. * pattern will have no effect). A notable exception is
  1189. * cairo_pattern_add_color_stop_rgb() and
  1190. * cairo_pattern_add_color_stop_rgba() which must only be called with
  1191. * gradient patterns (either LINEAR or RADIAL). Otherwise the pattern
  1192. * will be shutdown and put into an error state.
  1193. *
  1194. * New entries may be added in future versions.
  1195. *
  1196. * Since: 1.2
  1197. **/
  1198. enum cairo_pattern_type_t
  1199. {
  1200. CAIRO_PATTERN_TYPE_SOLID,
  1201. CAIRO_PATTERN_TYPE_SURFACE,
  1202. CAIRO_PATTERN_TYPE_LINEAR,
  1203. CAIRO_PATTERN_TYPE_RADIAL,
  1204. }
  1205. cairo_pattern_type_t cairo_pattern_get_type(cairo_pattern_t *pattern);
  1206. void cairo_pattern_add_color_stop_rgb(cairo_pattern_t *pattern, double offset, double red, double green, double blue);
  1207. void cairo_pattern_add_color_stop_rgba(cairo_pattern_t *pattern, double offset, double red, double green, double blue, double alpha);
  1208. void cairo_pattern_set_matrix(cairo_pattern_t *pattern, cairo_matrix_t *matrix);
  1209. void cairo_pattern_get_matrix(cairo_pattern_t *pattern, cairo_matrix_t *matrix);
  1210. /**
  1211. * cairo_extend_t
  1212. * @CAIRO_EXTEND_NONE: pixels outside of the source pattern
  1213. * are fully transparent
  1214. * @CAIRO_EXTEND_REPEAT: the pattern is tiled by repeating
  1215. * @CAIRO_EXTEND_REFLECT: the pattern is tiled by reflecting
  1216. * at the edges (not implemented for surface patterns currently)
  1217. * @CAIRO_EXTEND_PAD: pixels outside of the pattern copy
  1218. * the closest pixel from the source (Since 1.2; not implemented
  1219. * for surface patterns currently)
  1220. *
  1221. * #cairo_extend_t is used to describe how the area outside
  1222. * of a pattern will be drawn.
  1223. *
  1224. * New entries may be added in future versions.
  1225. **/
  1226. enum cairo_extend_t
  1227. {
  1228. CAIRO_EXTEND_NONE,
  1229. CAIRO_EXTEND_REPEAT,
  1230. CAIRO_EXTEND_REFLECT,
  1231. CAIRO_EXTEND_PAD,
  1232. }
  1233. void cairo_pattern_set_extend(cairo_pattern_t *pattern, cairo_extend_t extend);
  1234. cairo_extend_t cairo_pattern_get_extend(cairo_pattern_t *pattern);
  1235. enum cairo_filter_t
  1236. {
  1237. CAIRO_FILTER_FAST,
  1238. CAIRO_FILTER_GOOD,
  1239. CAIRO_FILTER_BEST,
  1240. CAIRO_FILTER_NEAREST,
  1241. CAIRO_FILTER_BILINEAR,
  1242. CAIRO_FILTER_GAUSSIAN,
  1243. }
  1244. void cairo_pattern_set_filter(cairo_pattern_t *pattern, cairo_filter_t filter);
  1245. cairo_filter_t cairo_pattern_get_filter(cairo_pattern_t *pattern);
  1246. cairo_status_t cairo_pattern_get_rgba(cairo_pattern_t *pattern, double *red, double *green, double *blue, double *alpha);
  1247. cairo_status_t cairo_pattern_get_surface(cairo_pattern_t *pattern, cairo_surface_t **surface);
  1248. cairo_status_t cairo_pattern_get_color_stop_rgba(cairo_pattern_t *pattern, int index, double *offset, double *red, double *green, double *blue, double *alpha);
  1249. cairo_status_t cairo_pattern_get_color_stop_count(cairo_pattern_t *pattern, int *count);
  1250. cairo_status_t cairo_pattern_get_linear_points(cairo_pattern_t *pattern, double *x0, double *y0, double *x1, double *y1);
  1251. cairo_status_t cairo_pattern_get_radial_circles(cairo_pattern_t *pattern, double *x0, double *y0, double *r0, double *x1, double *y1, double *r1);
  1252. /* Matrix functions */
  1253. void cairo_matrix_init(cairo_matrix_t *matrix, double xx, double yx, double xy, double yy, double x0, double y0);
  1254. void cairo_matrix_init_identity(cairo_matrix_t *matrix);
  1255. void cairo_matrix_init_translate(cairo_matrix_t *matrix, double tx, double ty);
  1256. void cairo_matrix_init_scale(cairo_matrix_t *matrix, double sx, double sy);
  1257. void cairo_matrix_init_rotate(cairo_matrix_t *matrix, double radians);
  1258. void cairo_matrix_translate(cairo_matrix_t *matrix, double tx, double ty);
  1259. void cairo_matrix_scale(cairo_matrix_t *matrix, double sx, double sy);
  1260. void cairo_matrix_rotate(cairo_matrix_t *matrix, double radians);
  1261. cairo_status_t cairo_matrix_invert(cairo_matrix_t *matrix);
  1262. void cairo_matrix_multiply(cairo_matrix_t *result, cairo_matrix_t *a, cairo_matrix_t *b);
  1263. void cairo_matrix_transform_distance(cairo_matrix_t *matrix, double *dx, double *dy);
  1264. void cairo_matrix_transform_point(cairo_matrix_t *matrix, double *x, double *y);
  1265. /* Functions to be used while debugging (not intended for use in production code) */
  1266. void cairo_debug_reset_static_data();