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

📄 cairo.c

📁 按照官方的说法:Cairo is a vector graphics library with cross-device output support. 翻译过来
💻 C
📖 第 1 页 / 共 5 页
字号:
 * * Return value: a newly created (surface) pattern containing the * results of all drawing operations performed to the group. The * caller owns the returned object and should call * cairo_pattern_destroy() when finished with it. * * Since: 1.2 **/cairo_pattern_t *cairo_pop_group (cairo_t *cr){    cairo_surface_t *group_surface, *parent_target;    cairo_pattern_t *group_pattern = NULL;    cairo_matrix_t group_matrix;    /* Grab the active surfaces */    group_surface = _cairo_gstate_get_target (cr->gstate);    parent_target = _cairo_gstate_get_parent_target (cr->gstate);    /* Verify that we are at the right nesting level */    if (parent_target == NULL) {	_cairo_set_error (cr, CAIRO_STATUS_INVALID_POP_GROUP);	return NULL;    }    /* We need to save group_surface before we restore; we don't need     * to reference parent_target and original_target, since the     * gstate will still hold refs to them once we restore. */    cairo_surface_reference (group_surface);    cairo_restore (cr);    if (cr->status)	goto done;    group_pattern = cairo_pattern_create_for_surface (group_surface);    if (!group_pattern) {        cr->status = CAIRO_STATUS_NO_MEMORY;        goto done;    }    _cairo_gstate_get_matrix (cr->gstate, &group_matrix);    cairo_pattern_set_matrix (group_pattern, &group_matrix);done:    cairo_surface_destroy (group_surface);    return group_pattern;}slim_hidden_def(cairo_pop_group);/** * cairo_pop_group_to_source: * @cr: a cairo context * * Terminates the redirection begun by a call to cairo_push_group() or * cairo_push_group_with_content() and installs the resulting pattern * as the source pattern in the given cairo context. * * The behavior of this function is equivalent to the sequence of * operations: * * <informalexample><programlisting> * cairo_pattern_t *group = cairo_pop_group (cr); * cairo_set_source (cr, group); * cairo_pattern_destroy (group); * </programlisting></informalexample> * * but is more convenient as their is no need for a variable to store * the short-lived pointer to the pattern. * * The cairo_pop_group() function calls cairo_restore(), (balancing a * call to cairo_save() by the push_group function), so that any * changes to the graphics state will not be visible outside the * group. * * Since: 1.2 **/voidcairo_pop_group_to_source (cairo_t *cr){    cairo_pattern_t *group_pattern;    group_pattern = cairo_pop_group (cr);    if (!group_pattern)        return;    cairo_set_source (cr, group_pattern);    cairo_pattern_destroy (group_pattern);}slim_hidden_def(cairo_pop_group_to_source);/** * cairo_set_operator: * @cr: a #cairo_t * @op: a compositing operator, specified as a #cairo_operator_t * * Sets the compositing operator to be used for all drawing * operations. See #cairo_operator_t for details on the semantics of * each available compositing operator. * * XXX: I'd also like to direct the reader's attention to some * (not-yet-written) section on cairo's imaging model. How would I do * that if such a section existed? (cworth). **/voidcairo_set_operator (cairo_t *cr, cairo_operator_t op){    if (cr->status)	return;    cr->status = _cairo_gstate_set_operator (cr->gstate, op);    if (cr->status)	_cairo_set_error (cr, cr->status);}/** * cairo_set_source_rgb * @cr: a cairo context * @red: red component of color * @green: green component of color * @blue: blue component of color * * Sets the source pattern within @cr to an opaque color. This opaque * color will then be used for any subsequent drawing operation until * a new source pattern is set. * * The color components are floating point numbers in the range 0 to * 1. If the values passed in are outside that range, they will be * clamped. **/voidcairo_set_source_rgb (cairo_t *cr, double red, double green, double blue){    cairo_pattern_t *pattern;    if (cr->status)	return;    pattern = cairo_pattern_create_rgb (red, green, blue);    cairo_set_source (cr, pattern);    cairo_pattern_destroy (pattern);}/** * cairo_set_source_rgba: * @cr: a cairo context * @red: red component of color * @green: green component of color * @blue: blue component of color * @alpha: alpha component of color * * Sets the source pattern within @cr to a translucent color. This * color will then be used for any subsequent drawing operation until * a new source pattern is set. * * The color and alpha components are floating point numbers in the * range 0 to 1. If the values passed in are outside that range, they * will be clamped. **/voidcairo_set_source_rgba (cairo_t *cr,		       double red, double green, double blue,		       double alpha){    cairo_pattern_t *pattern;    if (cr->status)	return;    pattern = cairo_pattern_create_rgba (red, green, blue, alpha);    cairo_set_source (cr, pattern);    cairo_pattern_destroy (pattern);}/** * cairo_set_source_surface: * @cr: a cairo context * @surface: a surface to be used to set the source pattern * @x: User-space X coordinate for surface origin * @y: User-space Y coordinate for surface origin * * This is a convenience function for creating a pattern from @surface * and setting it as the source in @cr with cairo_set_source(). * * The @x and @y parameters give the user-space coordinate at which * the surface origin should appear. (The surface origin is its * upper-left corner before any transformation has been applied.) The * @x and @y patterns are negated and then set as translation values * in the pattern matrix. * * Other than the initial translation pattern matrix, as described * above, all other pattern attributes, (such as its extend mode), are * set to the default values as in cairo_pattern_create_for_surface(). * The resulting pattern can be queried with cairo_get_source() so * that these attributes can be modified if desired, (eg. to create a * repeating pattern with cairo_pattern_set_extend()). **/voidcairo_set_source_surface (cairo_t	  *cr,			  cairo_surface_t *surface,			  double	   x,			  double	   y){    cairo_pattern_t *pattern;    cairo_matrix_t matrix;    if (cr->status)	return;    pattern = cairo_pattern_create_for_surface (surface);    cairo_matrix_init_translate (&matrix, -x, -y);    cairo_pattern_set_matrix (pattern, &matrix);    cairo_set_source (cr, pattern);    cairo_pattern_destroy (pattern);}/** * cairo_set_source * @cr: a cairo context * @source: a #cairo_pattern_t to be used as the source for * subsequent drawing operations. * * Sets the source pattern within @cr to @source. This pattern * will then be used for any subsequent drawing operation until a new * source pattern is set. * * Note: The pattern's transformation matrix will be locked to the * user space in effect at the time of cairo_set_source(). This means * that further modifications of the current transformation matrix * will not affect the source pattern. See cairo_pattern_set_matrix(). * * XXX: I'd also like to direct the reader's attention to some * (not-yet-written) section on cairo's imaging model. How would I do * that if such a section existed? (cworth). **/voidcairo_set_source (cairo_t *cr, cairo_pattern_t *source){    if (cr->status)	return;    if (source == NULL) {	_cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER);	return;    }    if (source->status) {	_cairo_set_error (cr, source->status);	return;    }    cr->status = _cairo_gstate_set_source (cr->gstate, source);    if (cr->status)	_cairo_set_error (cr, cr->status);}/** * cairo_get_source: * @cr: a cairo context * * Gets the current source pattern for @cr. * * Return value: the current source pattern. This object is owned by * cairo. To keep a reference to it, you must call * cairo_pattern_reference(). **/cairo_pattern_t *cairo_get_source (cairo_t *cr){    if (cr->status)	return (cairo_pattern_t*) &cairo_pattern_nil.base;    return _cairo_gstate_get_source (cr->gstate);}/** * cairo_set_tolerance: * @cr: a #cairo_t * @tolerance: the tolerance, in device units (typically pixels) * * Sets the tolerance used when converting paths into trapezoids. * Curved segments of the path will be subdivided until the maximum * deviation between the original path and the polygonal approximation * is less than @tolerance. The default value is 0.1. A larger * value will give better performance, a smaller value, better * appearance. (Reducing the value from the default value of 0.1 * is unlikely to improve appearance significantly.) **/voidcairo_set_tolerance (cairo_t *cr, double tolerance){    if (cr->status)	return;    _cairo_restrict_value (&tolerance, CAIRO_TOLERANCE_MINIMUM, tolerance);    cr->status = _cairo_gstate_set_tolerance (cr->gstate, tolerance);    if (cr->status)	_cairo_set_error (cr, cr->status);}/** * cairo_set_antialias: * @cr: a #cairo_t * @antialias: the new antialiasing mode * * Set the antialiasing mode of the rasterizer used for drawing shapes. * This value is a hint, and a particular backend may or may not support * a particular value.  At the current time, no backend supports * %CAIRO_ANTIALIAS_SUBPIXEL when drawing shapes. * * Note that this option does not affect text rendering, instead see * cairo_font_options_set_antialias(). **/voidcairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias){    if (cr->status)	return;    cr->status = _cairo_gstate_set_antialias (cr->gstate, antialias);    if (cr->status)	_cairo_set_error (cr, cr->status);}/** * cairo_set_fill_rule: * @cr: a #cairo_t * @fill_rule: a fill rule, specified as a #cairo_fill_rule_t * * Set the current fill rule within the cairo context. The fill rule * is used to determine which regions are inside or outside a complex * (potentially self-intersecting) path. The current fill rule affects * both cairo_fill and cairo_clip. See #cairo_fill_rule_t for details * on the semantics of each available fill rule. **/voidcairo_set_fill_rule (cairo_t *cr, cairo_fill_rule_t fill_rule){    if (cr->status)	return;    cr->status = _cairo_gstate_set_fill_rule (cr->gstate, fill_rule);    if (cr->status)	_cairo_set_error (cr, cr->status);}/** * cairo_set_line_width: * @cr: a #cairo_t * @width: a line width * * Sets the current line width within the cairo context. The line * width value specifies the diameter of a pen that is circular in * user space, (though device-space pen may be an ellipse in general * due to scaling/shear/rotation of the CTM). * * Note: When the description above refers to user space and CTM it * refers to the user space and CTM in effect at the time of the * stroking operation, not the user space and CTM in effect at the * time of the call to cairo_set_line_width(). The simplest usage * makes both of these spaces identical. That is, if there is no * change to the CTM between a call to cairo_set_line_with() and the * stroking operation, then one can just pass user-space values to * cairo_set_line_width() and ignore this note. * * As with the other stroke parameters, the current line width is * examined by cairo_stroke(), cairo_stroke_extents(), and * cairo_stroke_to_path(), but does not have any effect during path * construction. * * The default line width value is 2.0. **/voidcairo_set_line_width (cairo_t *cr, double width){    if (cr->status)	return;    _cairo_restrict_value (&width, 0.0, width);    cr->status = _cairo_gstate_set_line_width (cr->gstate, width);    if (cr->status)	_cairo_set_error (cr, cr->status);}/** * cairo_set_line_cap: * @cr: a cairo context, as a #cairo_t * @line_cap: a line cap style, as a #cairo_line_cap_t * * Sets the current line cap style within the cairo context. See * #cairo_line_cap_t for details about how the available line cap * styles are drawn. * * As with the other stroke parameters, the current line cap style is * examined by cairo_stroke(), cairo_stroke_extents(), and * cairo_stroke_to_path(), but does not have any effect during path * construction. **/voidcairo_set_line_cap (cairo_t *cr, cairo_line_cap_t line_cap){    if (cr->status)	return;    cr->status = _cairo_gstate_set_line_cap (cr->gstate, line_cap);    if (cr->status)	_cairo_set_error (cr, cr->status);}/** * cairo_set_line_join: * @cr: a cairo context, as a #cairo_t * @line_join: a line joint style, as a #cairo_line_join_t * * Sets the current line join style within the cairo context. See * #cairo_line_join_t for details about how the available line join * styles are drawn. * * As with the other stroke parameters, the current line join style is * examined by cairo_stroke(), cairo_stroke_extents(), and * cairo_stroke_to_path(), but does not have any effect during path * construction. **/voidcairo_set_line_join (cairo_t *cr, cairo_line_join_t line_join){    if (cr->status)	return;    cr->status = _cairo_gstate_set_line_join (cr->gstate, line_join);    if (cr->status)	_cairo_set_error (cr, cr->status);}/** * cairo_set_dash: * @cr: a cairo context * @dashes: an array specifying alternate lengths of on and off stroke portions * @num_dashes: the length of the dashes array * @offset: an offset into the dash pattern at which the stroke should start * * Sets the dash pattern to be used by cairo_stroke(). A dash pattern * is specified by @dashes, an array of positive values. Each value * provides the length of alternate "on" and "off" portions of the * stroke. The @offset specifies an offset into the pattern at which * the stroke begins. * * Each "on" segment will have caps applied as if the segment were a * separate sub-path. In particular, it is valid to use an "on" length * of 0.0 with CAIRO_LINE_CAP_ROUND or CAIRO_LINE_CAP_SQUARE in order * to distributed dots or squares along a path. * * Note: The length values are in user-space units as evaluated at the * time of stroking. This is not necessarily the same as the user * space at the time of cairo_set_dash().

⌨️ 快捷键说明

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