Browse Source

Fixed getPoint for same node edges

Signed-off-by: André Martins <aanm90@gmail.com>
codeClimate
André Martins 8 years ago
parent
commit
944511f4c7
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) { getPoint(percentage, viaNode = this.via) {
let t = percentage; 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}; return {x: x, y: y};
} }
@ -151,4 +159,4 @@ class BezierEdgeDynamic extends BezierEdgeBase {
} }
export default BezierEdgeDynamic;
export default BezierEdgeDynamic;

Loading…
Cancel
Save