How to get x / y coordinates of the first and last points of a drawn arc relative to the upper left corner of the canvas?

I have a square canvas with a width of 100 and a height of 100. Inside this square, I draw an arc like this:

var canvas = document.getElementById('myCanvas');
var ctx    = canvas.getContext('2d');
ctx.clearRect(0,0,100,100) // clears "myCanvas" which is 100pixels by 100 pixels
ctx.beginPath();
ctx.arc( 50, 50, 30, 0, Math.PI*2/6 , false )
ctx.stroke();

The question arises: how to get the x / y coordinates of the first and last points of the drawn line relative to the upper left corner of the canvas?

+3
source share
1 answer

(x + radius, y). - , (x + radius*cos(angle), y + radius*sin(angle)). , , angle . .

( , , anticlockwise , . anticlockwise , y. , , . , .)

+4

Source: https://habr.com/ru/post/1763876/


All Articles