From 9f643b964cc9dff9bb22348ec24fd529a7e2af1b Mon Sep 17 00:00:00 2001 From: Alex de Mulder Date: Tue, 18 Feb 2014 18:22:43 +0100 Subject: [PATCH] tweaks and minor bugfix --- src/graph/Edge.js | 12 ++++++++++-- src/graph/Graph.js | 4 ++-- src/graph/Node.js | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/graph/Edge.js b/src/graph/Edge.js index eafcdfdb..0f9a3268 100644 --- a/src/graph/Edge.js +++ b/src/graph/Edge.js @@ -557,6 +557,7 @@ Edge.prototype._drawArrow = function(ctx) { var xFrom = (fromBorderPoint) * this.from.x + (1 - fromBorderPoint) * this.to.x; var yFrom = (fromBorderPoint) * this.from.y + (1 - fromBorderPoint) * this.to.y; + if (this.smooth == true) { angle = Math.atan2((this.to.y - this.via.y), (this.to.x - this.via.x)); dx = (this.to.x - this.via.x); @@ -565,9 +566,16 @@ Edge.prototype._drawArrow = function(ctx) { } var toBorderDist = this.to.distanceToBorder(ctx, angle); var toBorderPoint = (edgeSegmentLength - toBorderDist) / edgeSegmentLength; - var xTo = (1 - toBorderPoint) * this.via.x + toBorderPoint * this.to.x; - var yTo = (1 - toBorderPoint) * this.via.y + toBorderPoint * this.to.y; + var xTo,yTo; + if (this.smooth == true) { + xTo = (1 - toBorderPoint) * this.via.x + toBorderPoint * this.to.x; + yTo = (1 - toBorderPoint) * this.via.y + toBorderPoint * this.to.y; + } + else { + xTo = (1 - toBorderPoint) * this.from.x + toBorderPoint * this.to.x; + yTo = (1 - toBorderPoint) * this.from.y + toBorderPoint * this.to.y; + } ctx.beginPath(); ctx.moveTo(xFrom,yFrom); diff --git a/src/graph/Graph.js b/src/graph/Graph.js index fd402de6..d0613ece 100644 --- a/src/graph/Graph.js +++ b/src/graph/Graph.js @@ -22,7 +22,7 @@ function Graph (container, data, options) { this.renderRefreshRate = 60; // hz (fps) this.renderTimestep = 1000 / this.renderRefreshRate; // ms -- saves calculation later on this.renderTime = 0.5 * this.renderTimestep; // measured time it takes to render a frame - this.maxRenderSteps = 4; // max amount of physics ticks per render step. + this.maxRenderSteps = 3; // max amount of physics ticks per render step. this.stabilize = true; // stabilize before displaying the graph this.selectable = true; @@ -1725,7 +1725,7 @@ Graph.prototype._isMoving = function(vmin) { * @private */ Graph.prototype._discreteStepNodes = function() { - var interval = 0.75; + var interval = 0.5; var nodes = this.nodes; var nodeId; diff --git a/src/graph/Node.js b/src/graph/Node.js index 83c372fb..c6700d1a 100644 --- a/src/graph/Node.js +++ b/src/graph/Node.js @@ -235,7 +235,7 @@ Node.parseColor = function(color) { var lighterColorHex = util.HSVToHex(lighterColorHSV.h,lighterColorHSV.s,lighterColorHSV.v); c = { - border: color, + background: color, border:darkerColorHex, highlight: { background:lighterColorHex, @@ -245,7 +245,7 @@ Node.parseColor = function(color) { } else { c = { - border:color, + background:color, border:color, highlight: { background:color,