From 46fb52be241dced940d46629c809a09c86ed4438 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Wed, 29 Feb 2012 11:38:33 -0800 Subject: changed the registration point of the brush tool icon and added a temporary check to prevent extremely long brush strokes --- js/helper-classes/RDGE/GLBrushStroke.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'js/helper-classes/RDGE') diff --git a/js/helper-classes/RDGE/GLBrushStroke.js b/js/helper-classes/RDGE/GLBrushStroke.js index f63bcc8a..07a4a039 100755 --- a/js/helper-classes/RDGE/GLBrushStroke.js +++ b/js/helper-classes/RDGE/GLBrushStroke.js @@ -35,7 +35,8 @@ function GLBrushStroke() { this._strokeStyle = "Solid"; //the wetness of the brush (currently this is multiplied to the square of the stroke width, but todo should be changed to not depend on stroke width entirely - this._WETNESS_FACTOR = 0.010625;//0.0625; + //smaller value means more samples for the path + this._WETNESS_FACTOR = 0.25; //drawing context this._world = null; @@ -75,10 +76,10 @@ function GLBrushStroke() { //add the point only if it is some epsilon away from the previous point var numPoints = this._Points.length; if (numPoints>0) { - var threshold = this._WETNESS_FACTOR*this._strokeWidth*this._strokeWidth; + var threshold = this._WETNESS_FACTOR*this._strokeWidth; var prevPt = this._Points[numPoints-1]; var diffPt = [prevPt[0]-pt[0], prevPt[1]-pt[1]]; - var diffPtMag = diffPt[0]*diffPt[0] + diffPt[1]*diffPt[1]; + var diffPtMag = Math.sqrt(diffPt[0]*diffPt[0] + diffPt[1]*diffPt[1]); if (diffPtMag>threshold){ this._Points.push(pt); this._dirty=true; @@ -136,7 +137,7 @@ function GLBrushStroke() { //**** add samples to the path if needed...linear interpolation for now if (numPoints>1) { - var threshold = this._WETNESS_FACTOR*this._strokeWidth*this._strokeWidth; + var threshold = this._WETNESS_FACTOR*this._strokeWidth; var prevPt = this._Points[0]; var prevIndex = 0; for (var i=1;i