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

📄 cairo.c

📁 按照官方的说法:Cairo is a vector graphics library with cross-device output support. 翻译过来
💻 C
📖 第 1 页 / 共 5 页
字号:
	return;    /* Do nothing, successfully, if radius is <= 0 */    if (radius <= 0.0)	return;    while (angle2 < angle1)	angle2 += 2 * M_PI;    cairo_line_to (cr,		   xc + radius * cos (angle1),		   yc + radius * sin (angle1));    _cairo_arc_path (cr, xc, yc, radius,		     angle1, angle2);}/** * cairo_arc_negative: * @cr: a cairo context * @xc: X position of the center of the arc * @yc: Y position of the center of the arc * @radius: the radius of the arc * @angle1: the start angle, in radians * @angle2: the end angle, in radians * * Adds a circular arc of the given @radius to the current path.  The * arc is centered at (@xc, @yc), begins at @angle1 and proceeds in * the direction of decreasing angles to end at @angle2. If @angle2 is * greater than @angle1 it will be progressively decreased by 2*M_PI * until it is greater than @angle1. * * See cairo_arc() for more details. This function differs only in the * direction of the arc between the two angles. **/voidcairo_arc_negative (cairo_t *cr,		    double xc, double yc,		    double radius,		    double angle1, double angle2){    if (cr->status)	return;    /* Do nothing, successfully, if radius is <= 0 */    if (radius <= 0.0)	return;    while (angle2 > angle1)	angle2 -= 2 * M_PI;    cairo_line_to (cr,		   xc + radius * cos (angle1),		   yc + radius * sin (angle1));     _cairo_arc_path_negative (cr, xc, yc, radius,			       angle1, angle2);}/* XXX: NYIvoidcairo_arc_to (cairo_t *cr,	      double x1, double y1,	      double x2, double y2,	      double radius){    if (cr->status)	return;    cr->status = _cairo_gstate_arc_to (cr->gstate,				       x1, y1,				       x2, y2,				       radius);}*//** * cairo_rel_move_to: * @cr: a cairo context * @dx: the X offset * @dy: the Y offset * * Begin a new sub-path. After this call the current point will offset * by (@x, @y). * * Given a current point of (x, y), cairo_rel_move_to(@cr, @dx, @dy) * is logically equivalent to cairo_move_to (@cr, x + @dx, y + @dy). * * It is an error to call this function with no current point. Doing * so will cause @cr to shutdown with a status of * CAIRO_STATUS_NO_CURRENT_POINT. **/voidcairo_rel_move_to (cairo_t *cr, double dx, double dy){    cairo_fixed_t dx_fixed, dy_fixed;    if (cr->status)	return;    _cairo_gstate_user_to_device_distance (cr->gstate, &dx, &dy);    dx_fixed = _cairo_fixed_from_double (dx);    dy_fixed = _cairo_fixed_from_double (dy);    cr->status = _cairo_path_fixed_rel_move_to (&cr->path, dx_fixed, dy_fixed);    if (cr->status)	_cairo_set_error (cr, cr->status);}/** * cairo_rel_line_to: * @cr: a cairo context * @dx: the X offset to the end of the new line * @dy: the Y offset to the end of the new line * * Relative-coordinate version of cairo_line_to(). Adds a line to the * path from the current point to a point that is offset from the * current point by (@dx, @dy) in user space. After this call the * current point will be offset by (@dx, @dy). * * Given a current point of (x, y), cairo_rel_line_to(@cr, @dx, @dy) * is logically equivalent to cairo_line_to (@cr, x + @dx, y + @dy). * * It is an error to call this function with no current point. Doing * so will cause @cr to shutdown with a status of * CAIRO_STATUS_NO_CURRENT_POINT. **/voidcairo_rel_line_to (cairo_t *cr, double dx, double dy){    cairo_fixed_t dx_fixed, dy_fixed;    if (cr->status)	return;    _cairo_gstate_user_to_device_distance (cr->gstate, &dx, &dy);    dx_fixed = _cairo_fixed_from_double (dx);    dy_fixed = _cairo_fixed_from_double (dy);    cr->status = _cairo_path_fixed_rel_line_to (&cr->path, dx_fixed, dy_fixed);    if (cr->status)	_cairo_set_error (cr, cr->status);}slim_hidden_def(cairo_rel_line_to);/** * cairo_rel_curve_to: * @cr: a cairo context * @dx1: the X offset to the first control point * @dy1: the Y offset to the first control point * @dx2: the X offset to the second control point * @dy2: the Y offset to the second control point * @dx3: the X offset to the end of the curve * @dy3: the Y offset to the end of the curve * * Relative-coordinate version of cairo_curve_to(). All offsets are * relative to the current point. Adds a cubic Bézier spline to the * path from the current point to a point offset from the current * point by (@dx3, @dy3), using points offset by (@dx1, @dy1) and * (@dx2, @dy2) as the control points. After this call the current * point will be offset by (@dx3, @dy3). * * Given a current point of (x, y), cairo_rel_curve_to (@cr, @dx1, * @dy1, @dx2, @dy2, @dx3, @dy3) is logically equivalent to * cairo_curve_to (@cr, x + @dx1, y + @dy1, x + @dx2, y + @dy2, x + * @dx3, y + @dy3). * * It is an error to call this function with no current point. Doing * so will cause @cr to shutdown with a status of * CAIRO_STATUS_NO_CURRENT_POINT. **/voidcairo_rel_curve_to (cairo_t *cr,		    double dx1, double dy1,		    double dx2, double dy2,		    double dx3, double dy3){    cairo_fixed_t dx1_fixed, dy1_fixed;    cairo_fixed_t dx2_fixed, dy2_fixed;    cairo_fixed_t dx3_fixed, dy3_fixed;    if (cr->status)	return;    _cairo_gstate_user_to_device_distance (cr->gstate, &dx1, &dy1);    _cairo_gstate_user_to_device_distance (cr->gstate, &dx2, &dy2);    _cairo_gstate_user_to_device_distance (cr->gstate, &dx3, &dy3);    dx1_fixed = _cairo_fixed_from_double (dx1);    dy1_fixed = _cairo_fixed_from_double (dy1);    dx2_fixed = _cairo_fixed_from_double (dx2);    dy2_fixed = _cairo_fixed_from_double (dy2);    dx3_fixed = _cairo_fixed_from_double (dx3);    dy3_fixed = _cairo_fixed_from_double (dy3);    cr->status = _cairo_path_fixed_rel_curve_to (&cr->path,						 dx1_fixed, dy1_fixed,						 dx2_fixed, dy2_fixed,						 dx3_fixed, dy3_fixed);    if (cr->status)	_cairo_set_error (cr, cr->status);}/** * cairo_rectangle: * @cr: a cairo context * @x: the X coordinate of the top left corner of the rectangle * @y: the Y coordinate to the top left corner of the rectangle * @width: the width of the rectangle * @height: the height of the rectangle * * Adds a closed sub-path rectangle of the given size to the current * path at position (@x, @y) in user-space coordinates. * * This function is logically equivalent to: * <informalexample><programlisting> * cairo_move_to (cr, x, y); * cairo_rel_line_to (cr, width, 0); * cairo_rel_line_to (cr, 0, height); * cairo_rel_line_to (cr, -width, 0); * cairo_close_path (cr); * </programlisting></informalexample> **/voidcairo_rectangle (cairo_t *cr,		 double x, double y,		 double width, double height){    if (cr->status)	return;    cairo_move_to (cr, x, y);    cairo_rel_line_to (cr, width, 0);    cairo_rel_line_to (cr, 0, height);    cairo_rel_line_to (cr, -width, 0);    cairo_close_path (cr);}/* XXX: NYIvoidcairo_stroke_to_path (cairo_t *cr){    if (cr->status)	return;    cr->status = _cairo_gstate_stroke_path (cr->gstate);    if (cr->status)	_cairo_set_error (cr, cr->status);}*//** * cairo_close_path: * @cr: a cairo context * * Adds a line segment to the path from the current point to the * beginning of the current sub-path, (the most recent point passed to * cairo_move_to()), and closes this sub-path. After this call the * current point will be at the joined endpoint of the sub-path. * * The behavior of cairo_close_path() is distinct from simply calling * cairo_line_to() with the equivalent coordinate in the case of * stroking. When a closed sub-path is stroked, there are no caps on * the ends of the sub-path. Instead, there is a line join connecting * the final and initial segments of the sub-path. * * If there is no current point before the call to cairo_close_path, * this function will have no effect. **/voidcairo_close_path (cairo_t *cr){    if (cr->status)	return;    cr->status = _cairo_path_fixed_close_path (&cr->path);    if (cr->status)	_cairo_set_error (cr, cr->status);}slim_hidden_def(cairo_close_path);/** * cairo_paint: * @cr: a cairo context * * A drawing operator that paints the current source everywhere within * the current clip region. **/voidcairo_paint (cairo_t *cr){    if (cr->status)	return;    cr->status = _cairo_gstate_paint (cr->gstate);    if (cr->status)	_cairo_set_error (cr, cr->status);}/** * cairo_paint_with_alpha: * @cr: a cairo context * @alpha: alpha value, between 0 (transparent) and 1 (opaque) * * A drawing operator that paints the current source everywhere within * the current clip region using a mask of constant alpha value * @alpha. The effect is similar to cairo_paint(), but the drawing * is faded out using the alpha value. **/voidcairo_paint_with_alpha (cairo_t *cr,			double   alpha){    cairo_color_t color;    cairo_pattern_union_t pattern;    if (cr->status)	return;    if (CAIRO_ALPHA_IS_OPAQUE (alpha)) {	cairo_paint (cr);	return;    }    if (CAIRO_ALPHA_IS_ZERO (alpha)) {	return;    }    _cairo_color_init_rgba (&color, 1., 1., 1., alpha);    _cairo_pattern_init_solid (&pattern.solid, &color);    cr->status = _cairo_gstate_mask (cr->gstate, &pattern.base);    if (cr->status)	_cairo_set_error (cr, cr->status);    _cairo_pattern_fini (&pattern.base);}/** * cairo_mask: * @cr: a cairo context * @pattern: a #cairo_pattern_t * * A drawing operator that paints the current source * using the alpha channel of @pattern as a mask. (Opaque * areas of @mask are painted with the source, transparent * areas are not painted.) */voidcairo_mask (cairo_t         *cr,	    cairo_pattern_t *pattern){    if (cr->status)	return;    if (pattern == NULL) {	_cairo_set_error (cr, CAIRO_STATUS_NULL_POINTER);	return;    }    if (pattern->status) {	_cairo_set_error (cr, pattern->status);	return;    }    cr->status = _cairo_gstate_mask (cr->gstate, pattern);    if (cr->status)	_cairo_set_error (cr, cr->status);}/** * cairo_mask_surface: * @cr: a cairo context * @surface: a #cairo_surface_t * @surface_x: X coordinate at which to place the origin of @surface * @surface_y: Y coordinate at which to place the origin of @surface * * A drawing operator that paints the current source * using the alpha channel of @surface as a mask. (Opaque * areas of @surface are painted with the source, transparent * areas are not painted.) */voidcairo_mask_surface (cairo_t         *cr,		    cairo_surface_t *surface,		    double           surface_x,		    double           surface_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, - surface_x, - surface_y);    cairo_pattern_set_matrix (pattern, &matrix);    cairo_mask (cr, pattern);    cairo_pattern_destroy (pattern);}/** * cairo_stroke: * @cr: a cairo context * * A drawing operator that strokes the current path according to the * current line width, line join, line cap, and dash settings. After * cairo_stroke, the current path will be cleared from the cairo * context. See cairo_set_line_width(), cairo_set_line_join(), * cairo_set_line_cap(), cairo_set_dash(), and * cairo_stroke_preserve(). * * Note: Degenerate segments and sub-paths are treated specially and * provide a useful result. These can result in two different * situations: * * 1. Zero-length "on" segments set in cairo_set_dash(). If the cap * style is CAIRO_LINE_CAP_ROUND or CAIRO_LINE_CAP_SQUARE then these * segments will be drawn as circular dots or squares respectively. In * the case of CAIRO_LINE_CAP_SQUARE, the orientation of the squares * is determined by the direction of the underlying path. * * 2. A sub-path created by cairo_move_to() followed by either a * cairo_close_path() or one or more calls to cairo_line_to() to the * same coordinate as the cairo_move_to(). If the cap style is * CAIRO_LINE_CAP_ROUND then these sub-paths will be drawn as circular * dots. Note that in the case of CAIRO_LINE_CAP_SQUARE a degenerate * sub-path will not be drawn at all, (since the correct orientation * is indeterminate). * * In no case will a cap style of CAIRO_LINE_CAP_BUTT cause anything * to be drawn in the case of either degenerate segments or sub-paths. **/voidcairo_stroke (cairo_t *cr){    cairo_stroke_preserve (cr);    cairo_new_path (cr);}/** * cairo_stroke_preserve: * @cr: a cairo context * * A drawing operator that strokes the current path according to the * current line width, line join, line cap, and dash settings. Unlike * cairo_stroke(), cairo_stroke_preserve preserves the path within the * cairo context. * * See cairo_set_line_width(), cairo_set_line_join(), * cairo_set_line_cap(), cairo_set_dash(), and * cairo_stroke_preserve(). **/

⌨️ 快捷键说明

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