开发者

How to find(get) the current(last) coordinates of the "Path" in Canvas?

开发者 https://www.devze.com 2023-04-05 01:43 出处:网络
context.beginPath(); context.strokeStyle="green"; context.fillStyle="green"; context.moveTo(250,500);
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;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号