From 753244b4713243ab19ca246be674f0b45fb85b72 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Mon, 26 Mar 2012 16:22:21 -0700 Subject: correctly update the brush stroke canvas size and position when the stroke path is smoothed (and also when the stroke width is changed) AND some code cleanup to remove unnecessary brush stroke properties --- js/lib/geom/brush-stroke.js | 156 +++++++++++--------------------------------- 1 file changed, 38 insertions(+), 118 deletions(-) diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js index f0925ba5..70429ca9 100755 --- a/js/lib/geom/brush-stroke.js +++ b/js/lib/geom/brush-stroke.js @@ -28,20 +28,12 @@ var BrushStroke = function GLBrushStroke() { this._BBoxMax = [0, 0, 0]; this._isDirty = true; this._isInit = false; - - - //whether or not to use the canvas drawing to stroke/fill - this._useCanvasDrawing = true; - + //the HTML5 canvas that holds this brush stroke this._canvas = null; - //the X and Y location of this brush stroke canvas in stage world space of Ninja - this._canvasX = 0; - this._canvasY = 0; - //stroke information - this._strokeWidth = 0.0; + this._strokeWidth = 1.0; this._strokeColor = [0.4, 0.4, 0.4, 1.0]; this._secondStrokeColor = [1, 0.4, 0.4, 1.0]; this._strokeHardness = 100; @@ -114,22 +106,6 @@ var BrushStroke = function GLBrushStroke() { this._dragPlane = p; }; - this.getCanvasX = function(){ - return this._canvasX; - }; - - this.getCanvasY = function(){ - return this._canvasY; - }; - - this.setCanvasX = function(cx){ - this._canvasX=cx; - }; - - this.setCanvasY = function(cy){ - this._canvasY=cy; - }; - this.getNumPoints = function () { return this._Points.length; }; @@ -190,6 +166,9 @@ var BrushStroke = function GLBrushStroke() { this.setStrokeWidth = function (w) { this._strokeWidth = w; + if (this._strokeWidth<1) { + this._strokeWidth = 1; + } this._isDirty=true; }; @@ -402,83 +381,37 @@ var BrushStroke = function GLBrushStroke() { this._stageWorldCenter = VecUtils.vecInterpolate(3, bboxMin, bboxMax, 0.5); // ***** center the input stageworld data about the center of the bbox ***** - this._LocalPoints = this._Points.slice(0); + this._LocalPoints = []; for (i=0;i1) { - this._LocalPoints = this._OrigPoints.slice(0); + this._copyCoordinates3D(this._OrigPoints, this._LocalPoints); //iterations of Laplacian smoothing (setting the points to the average of their neighbors) var numLaplacianIterations = this._strokeAmountSmoothing; for (var n=0;n