Arc 弧形 - convertSvg/svg-path-parse GitHub Wiki
Arc 弧形
弧形命令A是另一个创建SVG曲线的命令。基本上,弧形可以视为圆形或椭圆形的一部分。假设,已知椭圆形的长轴半径和短轴半径,并且已知两个点(在椭圆上),根据半径和两点,可以画出两个椭圆,在每个椭圆上根据两点都可以画出两种弧形。所以,仅仅根据半径和两点,可以画出四种弧形。为了保证创建的弧形唯一,A命令需要用到比较多的参数:
// rx ry radius x y end coordinate
A rx ry x-axis-rotation large-arc-flag sweep-flag x y
a rx ry x-axis-rotation large-arc-flag sweep-flag dx dy
Cario cairo_arc () cairo_arc_negative ()
// cricle transform
void
cairo_arc (cairo_t *cr,
double xc,
double yc,
double radius,
double angle1,
double angle2);
Parameters
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
Ellipses
cairo_set_source_rgb(cr, 1, 1, 1);
cairo_paint(cr);
cairo_set_source_rgb(cr, 0, 0, 0);
{
cairo_matrix_t save_matrix;
cairo_get_matrix(cr, &save_matrix);
cairo_translate(cr, img_width / 2.0, img_height / 2.0);
cairo_scale(cr, 0.5, 1);
cairo_translate(cr, - img_width / 2.0, - img_height / 2.0);
cairo_new_path(cr);
cairo_arc
(
/*cr =*/ cr,
/*xc =*/ img_width / 2.0,
/*yc =*/ img_height / 2.0,
/*radius =*/ img_width / 3.0,
/*angle1 =*/ 0,
/*angle2 =*/ 2 * M_PI
);
cairo_set_matrix(cr, &save_matrix);
}
cairo_set_line_width(cr, 20.0);
cairo_stroke(cr);
深入阅读: