How to find(get) the current(last) coordinates of the "Path" in Canvas?
context.beginPath();
context.strokeStyle="green";
context.fillStyle="green";
context.moveTo(250,500);
context.lineTo(开发者_如何学运维200,500);
context.arc(500,500,300,(Math.PI/180)*180,(Math.PI/180)*300,false);
// Here I don't know what the x and y are, in case I want to draw a line with a
//given length and NOT a line to a particular point (x,y)
context.stroke();
context.closePath();
There is no attribute or function in canvas for the last path position. I think you'll have to compute it yourself. Luckily that is simple, even for the arc
command. For instance:
var x = centerX + Math.cos(endAngle) * radius;
var y = centerY + Math.sin(endAngle) * radius;
精彩评论