Browse Source

Merge pull request #2161 from aanm/fixing-get-point

Fixed getPoint for same node edges
codeClimate
yotamberk 8 years ago
committed by GitHub
parent
commit
ca94ee0df5
1 changed files with 11 additions and 3 deletions
  1. +11
    -3
      lib/network/modules/components/edges/BezierEdgeDynamic.js

+ 11
- 3
lib/network/modules/components/edges/BezierEdgeDynamic.js View File

@ -133,8 +133,16 @@ class BezierEdgeDynamic extends BezierEdgeBase {
*/
getPoint(percentage, viaNode = this.via) {
let t = percentage;
let x = Math.pow(1 - t, 2) * this.fromPoint.x + (2 * t * (1 - t)) * viaNode.x + Math.pow(t, 2) * this.toPoint.x;
let y = Math.pow(1 - t, 2) * this.fromPoint.y + (2 * t * (1 - t)) * viaNode.y + Math.pow(t, 2) * this.toPoint.y;
let x, y;
if (this.from === this.to){
let [cx,cy,cr] = this._getCircleData(this.from)
let a = 2 * Math.PI * (1 - t);
x = cx + cr * Math.sin(a);
y = cy + cr - cr * (1 - Math.cos(a));
} else {
x = Math.pow(1 - t, 2) * this.fromPoint.x + 2 * t * (1 - t) * viaNode.x + Math.pow(t, 2) * this.toPoint.x;
y = Math.pow(1 - t, 2) * this.fromPoint.y + 2 * t * (1 - t) * viaNode.y + Math.pow(t, 2) * this.toPoint.y;
}
return {x: x, y: y};
}
@ -151,4 +159,4 @@ class BezierEdgeDynamic extends BezierEdgeBase {
}
export default BezierEdgeDynamic;
export default BezierEdgeDynamic;

Loading…
Cancel
Save