HTML5キャンバスオブジェクトでは、最終的な宛先を同じ行に与えるために、宛先点から距離を引く必要があります。HTML5キャンバスで、オフセットを使って最終点の座標を計算する方法は?
まず、ピタゴラスの定理を使って、原点と目標点の距離を計算しましたが、タレスの定理の記憶は、同じ点の上にある最終点(右のxとy)属性。
function getDistance (from, to){
return Math.hypot(to.x - from.x, to.y - from.y);
}
function getFinalTo (from, to, distanceToSubstract){
//with Pythagore we obtain the distance between the 2 points
var originalDistance = getDistance(from, to);
var finalDistance = originalDistance - distanceToSubstract;
//Now, I was thinking about Thales but all my tries are wrong
//Here some of ones, I need to get finalTo properties to draw an arrow to a node without
var finalTo = new Object;
finalTo.x = ((1 - finalDistance) * from.x) + (finalDistance * to.x);
finalTo.y = ((1 - finalDistance) * from.y) + (finalDistance * to.y);
return finalTo;
}
実際、矢頭は半径約100ピクセルになる丸いノードによって隠されるので、最後のポイントを取得しようとします。
ありがとうございます。 よろしく、