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();
答案 0 :(得分:4)
画布中没有属性或函数用于最后一个路径位置。我想你必须自己计算一下。幸运的是,这很简单,即使对于arc
命令也是如此。例如:
var x = centerX + Math.cos(endAngle) * radius;
var y = centerY + Math.sin(endAngle) * radius;