PageRenderTime 159ms CodeModel.GetById 13ms app.highlight 133ms RepoModel.GetById 1ms app.codeStats 1ms

/binding/cairo/cairo.d

http://github.com/wilkie/djehuty
D | 1775 lines | 467 code | 509 blank | 799 comment | 0 complexity | 0a57629c2ff5fe800e1c40d24287ba0e MD5 | raw file

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

Large files files are truncated, but you can click here to view the full file