Draws an arc of a given radius between two points
Typically, the HTML canvas arcTo
method is used to draw rounded corners and determining the values of the parameters is generally trivial because the first endpoint is simply the corner. However, computing the first endpoint in the case of drawing a generic arc is complicated. The drawArc
method does that computation for you.
Given a starting point, P1, an endpoint, P2, and a radius, r, compute a point, Q, such that P1Q and P2Q are tangent at P1 and P2 to a circle with the given radius with P2 counter-clockwise from P1.
drawArc(context, x1, y1, x2, y2, radius)
- context - HTML drawing context
- x1, y1 - start of the arc
- x2, y2 - end of the arc
- radius - radius of curvature