canvas-arc-to-svg-arc
v1.0.1
Published
a simple module that lets you define circular arc segments in an svg path using the semantics of the RenderingContext2D.arc method
Readme
canvas-arc-to-svg-arc
canvas-arc-to-svg-arc is a simple module that lets you define circular arc segments in an svg path using the semantics of the RenderingContext2D.arc method.
Installation
npm install --save canvas-arc-to-svg-arcExample
import canvasArcToSVGArc from "canvas-arc-to-svg-arc";
const pathData =
"M0,0" + canvasArcToSVGArc(0, 50, 50, -Math.PI / 2, Math.PI / 2, false);
document.getElementById("my-path").setAttribute("d", pathData);Usage
canvasArcToSVGArc(
x,
y,
radius,
startAngle,
endAngle,
counterClockwise,
drawLineToStart
);Returns a string containing the path data for the specified arc. All arguments other than the last one are directly analagous to their ctx.arc(...) equivalents.
The last argument, drawLineToStart, specifies whether or not you want a line to be drawn between wherever the path last let off and the beginning of the arc. The default value is true, as that is the standard behavior of the ctx.arc method.
