ItsME
ItsME

Reputation: 65

How to get coordinates of point where drawing arc ended in canvas?

Please consider this example.

How can I get coordinates of point where arc ended? Is there any function for this?

var canvas = document.getElementById('myCanvas');

var context = this.canvas.getContext('2d');

context.beginPath();
context.arc(115, 115, 100, (Math.PI/2)+Math.PI, 0, false);
context.lineWidth = 15;
context.stroke();

Upvotes: 2

Views: 1047

Answers (1)

MBo
MBo

Reputation: 80187

Basic trigonometry gives us formula

 X_End = X_Center + R * Cos(End_Angle)
 Y_End = Y_Center + R * Sin(End_Angle)

for you case

 X_End = 115 + 100 * Cos(0) = 215

and find Y_End yourself

Upvotes: 2

Related Questions