2011-09-16 2 views
1
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(); Canvasの「パス」の現在の(最後の)座標を見つける(取得する)方法は?

答えて

3

最後のパス位置のキャンバスに属性または機能がありません。私はあなた自身でそれを計算しなければならないと思う。幸運にも、それは簡単です。arcコマンドの場合でも。例えば:

var x = centerX + Math.cos(endAngle) * radius; 
var y = centerY + Math.sin(endAngle) * radius; 
関連する問題