'Draw an arc between two points with radius in javascript canvas

I need to draw an arc with R radius between two points x1,y1 and x2,y2. I'm trying to draw this arc on html canvas. I'll add two examples along with this question.

Examples, what i'm looking for



Solution 1:[1]

You can render arc like:

ctx.beginPath();
ctx.arc(100, 100, 50, 0, Math.PI, true);
ctx.stroke();

Params 100/100 - arc center, 50 - radius.
If you want to render between 2 dots - you need to find center dot(like centerX = x1 + (x2 - x1) / 2).

More you can read here and find some examples:

https://developer.mozilla.org/ru/docs/Web/API/CanvasRenderingContext2D/arc

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mero