📄 cairo.c
字号:
* * If @num_dashes is 0 dashing is disabled. * * If @num_dashes is 1 a symmetric pattern is assumed with alternating * on and off portions of the size specified by the single value in * @dashes. * * If any value in @dashes is negative, or if all values are 0, then * @cairo_t will be put into an error state with a status of * #CAIRO_STATUS_INVALID_DASH. **/voidcairo_set_dash (cairo_t *cr, double *dashes, int num_dashes, double offset){ if (cr->status) return; cr->status = _cairo_gstate_set_dash (cr->gstate, dashes, num_dashes, offset); if (cr->status) _cairo_set_error (cr, cr->status);}voidcairo_set_miter_limit (cairo_t *cr, double limit){ if (cr->status) return; cr->status = _cairo_gstate_set_miter_limit (cr->gstate, limit); if (cr->status) _cairo_set_error (cr, cr->status);}/** * cairo_translate: * @cr: a cairo context * @tx: amount to translate in the X direction * @ty: amount to translate in the Y direction * * Modifies the current transformation matrix (CTM) by translating the * user-space origin by (@tx, @ty). This offset is interpreted as a * user-space coordinate according to the CTM in place before the new * call to cairo_translate. In other words, the translation of the * user-space origin takes place after any existing transformation. **/voidcairo_translate (cairo_t *cr, double tx, double ty){ if (cr->status) return; cr->status = _cairo_gstate_translate (cr->gstate, tx, ty); if (cr->status) _cairo_set_error (cr, cr->status);}/** * cairo_scale: * @cr: a cairo context * @sx: scale factor for the X dimension * @sy: scale factor for the Y dimension * * Modifies the current transformation matrix (CTM) by scaling the X * and Y user-space axes by @sx and @sy respectively. The scaling of * the axes takes place after any existing transformation of user * space. **/voidcairo_scale (cairo_t *cr, double sx, double sy){ if (cr->status) return; cr->status = _cairo_gstate_scale (cr->gstate, sx, sy); if (cr->status) _cairo_set_error (cr, cr->status);}/** * cairo_rotate: * @cr: a cairo context * @angle: angle (in radians) by which the user-space axes will be * rotated * * Modifies the current transformation matrix (CTM) by rotating the * user-space axes by @angle radians. The rotation of the axes takes * places after any existing transformation of user space. The * rotation direction for positive angles is from the positive X axis * toward the positive Y axis. **/voidcairo_rotate (cairo_t *cr, double angle){ if (cr->status) return; cr->status = _cairo_gstate_rotate (cr->gstate, angle); if (cr->status) _cairo_set_error (cr, cr->status);}/** * cairo_transform: * @cr: a cairo context * @matrix: a transformation to be applied to the user-space axes * * Modifies the current transformation matrix (CTM) by applying * @matrix as an additional transformation. The new transformation of * user space takes place after any existing transformation. **/voidcairo_transform (cairo_t *cr, const cairo_matrix_t *matrix){ if (cr->status) return; cr->status = _cairo_gstate_transform (cr->gstate, matrix); if (cr->status) _cairo_set_error (cr, cr->status);}/** * cairo_set_matrix: * @cr: a cairo context * @matrix: a transformation matrix from user space to device space * * Modifies the current transformation matrix (CTM) by setting it * equal to @matrix. **/voidcairo_set_matrix (cairo_t *cr, const cairo_matrix_t *matrix){ if (cr->status) return; cr->status = _cairo_gstate_set_matrix (cr->gstate, matrix); if (cr->status) _cairo_set_error (cr, cr->status);}/** * cairo_identity_matrix: * @cr: a cairo context * * Resets the current transformation matrix (CTM) by setting it equal * to the identity matrix. That is, the user-space and device-space * axes will be aligned and one user-space unit will transform to one * device-space unit. **/voidcairo_identity_matrix (cairo_t *cr){ if (cr->status) return; cr->status = _cairo_gstate_identity_matrix (cr->gstate); if (cr->status) _cairo_set_error (cr, cr->status);}/** * cairo_user_to_device: * @cr: a cairo context * @x: X value of coordinate (in/out parameter) * @y: Y value of coordinate (in/out parameter) * * Transform a coordinate from user space to device space by * multiplying the given point by the current transformation matrix * (CTM). **/voidcairo_user_to_device (cairo_t *cr, double *x, double *y){ if (cr->status) return; cr->status = _cairo_gstate_user_to_device (cr->gstate, x, y); if (cr->status) _cairo_set_error (cr, cr->status);}/** * cairo_user_to_device_distance: * @cr: a cairo context * @dx: X component of a distance vector (in/out parameter) * @dy: Y component of a distance vector (in/out parameter) * * Transform a distance vector from user space to device space. This * function is similar to cairo_user_to_device() except that the * translation components of the CTM will be ignored when transforming * (@dx,@dy). **/voidcairo_user_to_device_distance (cairo_t *cr, double *dx, double *dy){ if (cr->status) return; cr->status = _cairo_gstate_user_to_device_distance (cr->gstate, dx, dy); if (cr->status) _cairo_set_error (cr, cr->status);}/** * cairo_device_to_user: * @cr: a cairo * @x: X value of coordinate (in/out parameter) * @y: Y value of coordinate (in/out parameter) * * Transform a coordinate from device space to user space by * multiplying the given point by the inverse of the current * transformation matrix (CTM). **/voidcairo_device_to_user (cairo_t *cr, double *x, double *y){ if (cr->status) return; cr->status = _cairo_gstate_device_to_user (cr->gstate, x, y); if (cr->status) _cairo_set_error (cr, cr->status);}/** * cairo_device_to_user_distance: * @cr: a cairo context * @dx: X component of a distance vector (in/out parameter) * @dy: Y component of a distance vector (in/out parameter) * * Transform a distance vector from device space to user space. This * function is similar to cairo_device_to_user() except that the * translation components of the inverse CTM will be ignored when * transforming (@dx,@dy). **/voidcairo_device_to_user_distance (cairo_t *cr, double *dx, double *dy){ if (cr->status) return; cr->status = _cairo_gstate_device_to_user_distance (cr->gstate, dx, dy); if (cr->status) _cairo_set_error (cr, cr->status);}/** * cairo_new_path: * @cr: a cairo context * * Clears the current path. After this call there will be no path and * no current point. **/voidcairo_new_path (cairo_t *cr){ if (cr->status) return; _cairo_path_fixed_fini (&cr->path);}slim_hidden_def(cairo_new_path);/** * cairo_move_to: * @cr: a cairo context * @x: the X coordinate of the new position * @y: the Y coordinate of the new position * * Begin a new sub-path. After this call the current point will be (@x, * @y). **/voidcairo_move_to (cairo_t *cr, double x, double y){ cairo_fixed_t x_fixed, y_fixed; if (cr->status) return; _cairo_gstate_user_to_backend (cr->gstate, &x, &y); x_fixed = _cairo_fixed_from_double (x); y_fixed = _cairo_fixed_from_double (y); cr->status = _cairo_path_fixed_move_to (&cr->path, x_fixed, y_fixed); if (cr->status) _cairo_set_error (cr, cr->status);}slim_hidden_def(cairo_move_to);/** * cairo_new_sub_path: * @cr: a cairo context * * Begin a new sub-path. Note that the existing path is not * affected. After this call there will be no current point. * * In many cases, this call is not needed since new sub-paths are * frequently started with cairo_move_to(). * * A call to cairo_new_sub_path() is particularly useful when * beginning a new sub-path with one of the cairo_arc() calls. This * makes things easier as it is no longer necessary to manually * compute the arc's initial coordinates for a call to * cairo_move_to(). * * Since: 1.2 **/voidcairo_new_sub_path (cairo_t *cr){ if (cr->status) return; _cairo_path_fixed_new_sub_path (&cr->path);}/** * cairo_line_to: * @cr: a cairo context * @x: the X coordinate of the end of the new line * @y: the Y coordinate of the end of the new line * * Adds a line to the path from the current point to position (@x, @y) * in user-space coordinates. After this call the current point * will be (@x, @y). * * If there is no current point before the call to cairo_line_to() * this function will behave as cairo_move_to (@cr, @x, @y). **/voidcairo_line_to (cairo_t *cr, double x, double y){ cairo_fixed_t x_fixed, y_fixed; if (cr->status) return; _cairo_gstate_user_to_backend (cr->gstate, &x, &y); x_fixed = _cairo_fixed_from_double (x); y_fixed = _cairo_fixed_from_double (y); cr->status = _cairo_path_fixed_line_to (&cr->path, x_fixed, y_fixed); if (cr->status) _cairo_set_error (cr, cr->status);}/** * cairo_curve_to: * @cr: a cairo context * @x1: the X coordinate of the first control point * @y1: the Y coordinate of the first control point * @x2: the X coordinate of the second control point * @y2: the Y coordinate of the second control point * @x3: the X coordinate of the end of the curve * @y3: the Y coordinate of the end of the curve * * Adds a cubic Bézier spline to the path from the current point to * position (@x3, @y3) in user-space coordinates, using (@x1, @y1) and * (@x2, @y2) as the control points. After this call the current point * will be (@x3, @y3). * * If there is no current point before the call to cairo_curve_to() * this function will behave as if preceded by a call to * cairo_move_to (@cr, @x1, @y1). **/voidcairo_curve_to (cairo_t *cr, double x1, double y1, double x2, double y2, double x3, double y3){ cairo_fixed_t x1_fixed, y1_fixed; cairo_fixed_t x2_fixed, y2_fixed; cairo_fixed_t x3_fixed, y3_fixed; if (cr->status) return; _cairo_gstate_user_to_backend (cr->gstate, &x1, &y1); _cairo_gstate_user_to_backend (cr->gstate, &x2, &y2); _cairo_gstate_user_to_backend (cr->gstate, &x3, &y3); x1_fixed = _cairo_fixed_from_double (x1); y1_fixed = _cairo_fixed_from_double (y1); x2_fixed = _cairo_fixed_from_double (x2); y2_fixed = _cairo_fixed_from_double (y2); x3_fixed = _cairo_fixed_from_double (x3); y3_fixed = _cairo_fixed_from_double (y3); cr->status = _cairo_path_fixed_curve_to (&cr->path, x1_fixed, y1_fixed, x2_fixed, y2_fixed, x3_fixed, y3_fixed); if (cr->status) _cairo_set_error (cr, cr->status);}/** * cairo_arc: * @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 increasing angles to end at @angle2. If @angle2 is * less than @angle1 it will be progressively increased by 2*M_PI * until it is greater than @angle1. * * If there is a current point, an initial line segment will be added * to the path to connect the current point to the beginning of the * arc. * * Angles are measured in radians. An angle of 0.0 is in the direction * of the positive X axis (in user space). An angle of %M_PI/2.0 radians * (90 degrees) is in the direction of the positive Y axis (in * user space). Angles increase in the direction from the positive X * axis toward the positive Y axis. So with the default transformation * matrix, angles increase in a clockwise direction. * * (To convert from degrees to radians, use <literal>degrees * (M_PI / * 180.)</literal>.) * * This function gives the arc in the direction of increasing angles; * see cairo_arc_negative() to get the arc in the direction of * decreasing angles. * * The arc is circular in user space. To achieve an elliptical arc, * you can scale the current transformation matrix by different * amounts in the X and Y directions. For example, to draw an ellipse * in the box given by @x, @y, @width, @height: * * <informalexample><programlisting> * cairo_save (cr); * cairo_translate (x + width / 2., y + height / 2.); * cairo_scale (1. / (height / 2.), 1. / (width / 2.)); * cairo_arc (cr, 0., 0., 1., 0., 2 * M_PI); * cairo_restore (cr); * </programlisting></informalexample> **/voidcairo_arc (cairo_t *cr, double xc, double yc, double radius, double angle1, double angle2){ if (cr->status)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -