⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cairo.h

📁 按照官方的说法:Cairo is a vector graphics library with cross-device output support. 翻译过来
💻 H
📖 第 1 页 / 共 4 页
字号:
/* cairo - a vector graphics library with display and print output * * Copyright © 2002 University of Southern California * Copyright © 2005 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it either under the terms of the GNU Lesser General Public * License version 2.1 as published by the Free Software Foundation * (the "LGPL") or, at your option, under the terms of the Mozilla * Public License Version 1.1 (the "MPL"). If you do not alter this * notice, a recipient may use your version of this file under either * the MPL or the LGPL. * * You should have received a copy of the LGPL along with this library * in the file COPYING-LGPL-2.1; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * You should have received a copy of the MPL along with this library * in the file COPYING-MPL-1.1 * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY * OF ANY KIND, either express or implied. See the LGPL or the MPL for * the specific language governing rights and limitations. * * The Original Code is the cairo graphics library. * * The Initial Developer of the Original Code is University of Southern * California. * * Contributor(s): *	Carl D. Worth <cworth@cworth.org> */#ifndef CAIRO_H#define CAIRO_H#include <cairo-features.h>CAIRO_BEGIN_DECLS#define CAIRO_VERSION_ENCODE(major, minor, micro) (     \	  ((major) * 10000)                             \	+ ((minor) *   100)                             \	+ ((micro) *     1))#define CAIRO_VERSION CAIRO_VERSION_ENCODE(     \	CAIRO_VERSION_MAJOR,                    \	CAIRO_VERSION_MINOR,                    \	CAIRO_VERSION_MICRO)cairo_public intcairo_version (void);cairo_public const char*cairo_version_string (void);/** * cairo_bool_t: * * #cairo_bool_t is used for boolean values. Returns of type * #cairo_bool_t will always be either 0 or 1, but testing against * these values explicitly is not encouraged; just use the * value as a boolean condition. * * <informalexample><programlisting> *  if (cairo_in_stroke (cr, x, y)) { *      /<!-- -->* do something *<!-- -->/ *  } * </programlisting></informalexample> */typedef int cairo_bool_t;/** * cairo_t: * * A #cairo_t contains the current state of the rendering device, * including coordinates of yet to be drawn shapes. **/typedef struct _cairo cairo_t;/** * cairo_surface_t: * * A #cairo_surface_t represents an image, either as the destination * of a drawing operation or as source when drawing onto another * surface. There are different subtypes of cairo_surface_t for * different drawing backends; for example, cairo_image_surface_create() * creates a bitmap image in memory. * * Memory management of #cairo_surface_t is done with * cairo_surface_reference() and cairo_surface_destroy(). */typedef struct _cairo_surface cairo_surface_t;/** * cairo_matrix_t: * @xx: xx component of the affine transformation * @yx: yx component of the affine transformation * @xy: xy component of the affine transformation * @yy: yy component of the affine transformation * @x0: X translation component of the affine transformation * @y0: Y translation component of the affine transformation * * A #cairo_matrix_t holds an affine transformation, such as a scale, * rotation, shear, or a combination of those. The transformation of * a point (x, y) is given by: * <programlisting> *     x_new = xx * x + xy * y + x0; *     y_new = yx * x + yy * y + y0; * </programlisting> **/typedef struct _cairo_matrix {    double xx; double yx;    double xy; double yy;    double x0; double y0;} cairo_matrix_t;typedef struct _cairo_pattern cairo_pattern_t;/** * cairo_destroy_func_t: * @data: The data element being destroyed. * * #cairo_destroy_func_t the type of function which is called when a * data element is destroyed. It is passed the pointer to the data * element and should free any memory and resources allocated for it. */typedef void (*cairo_destroy_func_t) (void *data);/** * cairo_user_data_key_t: * @unused: not used; ignore. * * #cairo_user_data_key_t is used for attaching user data to cairo * data structures.  The actual contents of the struct is never used, * and there is no need to initialize the object; only the unique * address of a #cairo_data_key_t object is used.  Typically, you * would just use the address of a static #cairo_data_key_t object. */typedef struct _cairo_user_data_key {    int unused;} cairo_user_data_key_t;/** * cairo_status_t * @CAIRO_STATUS_SUCCESS: no error has occurred * @CAIRO_STATUS_NO_MEMORY: out of memory * @CAIRO_STATUS_INVALID_RESTORE: cairo_restore without matching cairo_save * @CAIRO_STATUS_INVALID_POP_GROUP: no saved group to pop * @CAIRO_STATUS_NO_CURRENT_POINT: no current point defined * @CAIRO_STATUS_INVALID_MATRIX: invalid matrix (not invertible) * @CAIRO_STATUS_INVALID_STATUS: invalid value for an input cairo_status_t * @CAIRO_STATUS_NULL_POINTER: NULL pointer * @CAIRO_STATUS_INVALID_STRING: input string not valid UTF-8 * @CAIRO_STATUS_INVALID_PATH_DATA: input path data not valid * @CAIRO_STATUS_READ_ERROR: error while reading from input stream * @CAIRO_STATUS_WRITE_ERROR: error while writing to output stream * @CAIRO_STATUS_SURFACE_FINISHED: target surface has been finished * @CAIRO_STATUS_SURFACE_TYPE_MISMATCH: the surface type is not appropriate for the operation * @CAIRO_STATUS_PATTERN_TYPE_MISMATCH: the pattern type is not appropriate for the operation * @CAIRO_STATUS_INVALID_CONTENT: invalid value for an input cairo_content_t * @CAIRO_STATUS_INVALID_FORMAT: invalid value for an input cairo_format_t * @CAIRO_STATUS_INVALID_VISUAL: invalid value for an input Visual* * @CAIRO_STATUS_FILE_NOT_FOUND: file not found * @CAIRO_STATUS_INVALID_DASH: invalid value for a dash setting * @CAIRO_STATUS_INVALID_DSC_COMMENT: invalid value for a DSC comment (Since 1.2) * * #cairo_status_t is used to indicate errors that can occur when * using Cairo. In some cases it is returned directly by functions. * but when using #cairo_t, the last error, if any, is stored in * the context and can be retrieved with cairo_status(). **/typedef enum _cairo_status {    CAIRO_STATUS_SUCCESS = 0,    CAIRO_STATUS_NO_MEMORY,    CAIRO_STATUS_INVALID_RESTORE,    CAIRO_STATUS_INVALID_POP_GROUP,    CAIRO_STATUS_NO_CURRENT_POINT,    CAIRO_STATUS_INVALID_MATRIX,    CAIRO_STATUS_INVALID_STATUS,    CAIRO_STATUS_NULL_POINTER,    CAIRO_STATUS_INVALID_STRING,    CAIRO_STATUS_INVALID_PATH_DATA,    CAIRO_STATUS_READ_ERROR,    CAIRO_STATUS_WRITE_ERROR,    CAIRO_STATUS_SURFACE_FINISHED,    CAIRO_STATUS_SURFACE_TYPE_MISMATCH,    CAIRO_STATUS_PATTERN_TYPE_MISMATCH,    CAIRO_STATUS_INVALID_CONTENT,    CAIRO_STATUS_INVALID_FORMAT,    CAIRO_STATUS_INVALID_VISUAL,    CAIRO_STATUS_FILE_NOT_FOUND,    CAIRO_STATUS_INVALID_DASH,    CAIRO_STATUS_INVALID_DSC_COMMENT} cairo_status_t;/** * cairo_content_t * @CAIRO_CONTENT_COLOR: The surface will hold color content only. * @CAIRO_CONTENT_ALPHA: The surface will hold alpha content only. * @CAIRO_CONTENT_COLOR_ALPHA: The surface will hold color and alpha content. * * #cairo_content_t is used to describe the content that a surface will * contain, whether color information, alpha information (translucence * vs. opacity), or both. * * Note: The large values here are designed to keep cairo_content_t * values distinct from cairo_format_t values so that the * implementation can detect the error if users confuse the two types. */typedef enum _cairo_content {    CAIRO_CONTENT_COLOR		= 0x1000,    CAIRO_CONTENT_ALPHA		= 0x2000,    CAIRO_CONTENT_COLOR_ALPHA	= 0x3000} cairo_content_t;/** * cairo_write_func_t: * @closure: the output closure * @data: the buffer containing the data to write * @length: the amount of data to write * * #cairo_write_func_t is the type of function which is called when a * backend needs to write data to an output stream.  It is passed the * closure which was specified by the user at the time the write * function was registered, the data to write and the length of the * data in bytes.  The write function should return * CAIRO_STATUS_SUCCESS if all the data was successfully written, * CAIRO_STATUS_WRITE_ERROR otherwise. * * Returns: the status code of the write operation */typedef cairo_status_t (*cairo_write_func_t) (void		  *closure,					      const unsigned char *data,					      unsigned int	   length);/** * cairo_read_func_t: * @closure: the input closure * @data: the buffer into which to read the data * @length: the amount of data to read * * #cairo_read_func_t is the type of function which is called when a * backend needs to read data from an intput stream.  It is passed the * closure which was specified by the user at the time the read * function was registered, the buffer to read the data into and the * length of the data in bytes.  The read function should return * CAIRO_STATUS_SUCCESS if all the data was successfully read, * CAIRO_STATUS_READ_ERROR otherwise. * * Returns: the status code of the read operation */typedef cairo_status_t (*cairo_read_func_t) (void		*closure,					     unsigned char	*data,					     unsigned int	length);/* Functions for manipulating state objects */cairo_public cairo_t *cairo_create (cairo_surface_t *target);cairo_public cairo_t *cairo_reference (cairo_t *cr);cairo_public voidcairo_destroy (cairo_t *cr);cairo_public voidcairo_save (cairo_t *cr);cairo_public voidcairo_restore (cairo_t *cr);cairo_public voidcairo_push_group (cairo_t *cr);cairo_public voidcairo_push_group_with_content (cairo_t *cr, cairo_content_t content);cairo_public cairo_pattern_t *cairo_pop_group (cairo_t *cr);cairo_public voidcairo_pop_group_to_source (cairo_t *cr);/* Modify state */typedef enum _cairo_operator {    CAIRO_OPERATOR_CLEAR,    CAIRO_OPERATOR_SOURCE,    CAIRO_OPERATOR_OVER,    CAIRO_OPERATOR_IN,    CAIRO_OPERATOR_OUT,    CAIRO_OPERATOR_ATOP,    CAIRO_OPERATOR_DEST,    CAIRO_OPERATOR_DEST_OVER,    CAIRO_OPERATOR_DEST_IN,    CAIRO_OPERATOR_DEST_OUT,    CAIRO_OPERATOR_DEST_ATOP,    CAIRO_OPERATOR_XOR,    CAIRO_OPERATOR_ADD,    CAIRO_OPERATOR_SATURATE} cairo_operator_t;cairo_public voidcairo_set_operator (cairo_t *cr, cairo_operator_t op);cairo_public voidcairo_set_source (cairo_t *cr, cairo_pattern_t *source);cairo_public voidcairo_set_source_rgb (cairo_t *cr, double red, double green, double blue);cairo_public voidcairo_set_source_rgba (cairo_t *cr,		       double red, double green, double blue,		       double alpha);cairo_public voidcairo_set_source_surface (cairo_t	  *cr,			  cairo_surface_t *surface,			  double	   x,			  double	   y);cairo_public voidcairo_set_tolerance (cairo_t *cr, double tolerance);/** * cairo_antialias_t: * @CAIRO_ANTIALIAS_DEFAULT: Use the default antialiasing for *   the subsystem and target device * @CAIRO_ANTIALIAS_NONE: Use a bilevel alpha mask * @CAIRO_ANTIALIAS_GRAY: Perform single-color antialiasing (using *  shades of gray for black text on a white background, for example). * @CAIRO_ANTIALIAS_SUBPIXEL: Perform antialiasing by taking *  advantage of the order of subpixel elements on devices *  such as LCD panels * * Specifies the type of antialiasing to do when rendering text or shapes. **/typedef enum _cairo_antialias {    CAIRO_ANTIALIAS_DEFAULT,    CAIRO_ANTIALIAS_NONE,    CAIRO_ANTIALIAS_GRAY,    CAIRO_ANTIALIAS_SUBPIXEL} cairo_antialias_t;cairo_public voidcairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias);/** * cairo_fill_rule_t * @CAIRO_FILL_RULE_WINDING: If the path crosses the ray from * left-to-right, counts +1. If the path crosses the ray * from right to left, counts -1. (Left and right are determined * from the perspective of looking along the ray from the starting * point.) If the total count is non-zero, the point will be filled. * @CAIRO_FILL_RULE_EVEN_ODD: Counts the total number of * intersections, without regard to the orientation of the contour. If * the total number of intersections is odd, the point will be * filled. * * #cairo_fill_rule_t is used to select how paths are filled. For both * fill rules, whether or not a point is included in the fill is * determined by taking a ray from that point to infinity and looking * at intersections with the path. The ray can be in any direction, * as long as it doesn't pass through the end point of a segment * or have a tricky intersection such as intersecting tangent to the path. * (Note that filling is not actually implemented in this way. This * is just a description of the rule that is applied.) **/typedef enum _cairo_fill_rule {    CAIRO_FILL_RULE_WINDING,    CAIRO_FILL_RULE_EVEN_ODD} cairo_fill_rule_t;cairo_public voidcairo_set_fill_rule (cairo_t *cr, cairo_fill_rule_t fill_rule);cairo_public voidcairo_set_line_width (cairo_t *cr, double width);/** * cairo_line_cap_t * @CAIRO_LINE_CAP_BUTT: start(stop) the line exactly at the start(end) point * @CAIRO_LINE_CAP_ROUND: use a round ending, the center of the circle is the end point * @CAIRO_LINE_CAP_SQUARE: use squared ending, the center of the square is the end point * * enumeration for style of line-endings **/typedef enum _cairo_line_cap {    CAIRO_LINE_CAP_BUTT,    CAIRO_LINE_CAP_ROUND,    CAIRO_LINE_CAP_SQUARE} cairo_line_cap_t;cairo_public voidcairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap);typedef enum _cairo_line_join {    CAIRO_LINE_JOIN_MITER,    CAIRO_LINE_JOIN_ROUND,    CAIRO_LINE_JOIN_BEVEL} cairo_line_join_t;cairo_public voidcairo_set_line_join (cairo_t *cr, cairo_line_join_t line_join);cairo_public voidcairo_set_dash (cairo_t	*cr,		double	*dashes,		int	 num_dashes,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -