From 703fb3d06e88257ac73c1d1a0ec6ca33a64f4371 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Wed, 7 Mar 2012 14:33:21 -0800 Subject: implement stroke hardness such that it is percentage of the stroke width that's fully the color of the brush AND add a smoothing flag for the brush options --- js/lib/geom/brush-stroke.js | 66 +++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 47 deletions(-) (limited to 'js/lib/geom/brush-stroke.js') diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js index 39af5c5c..3e64e730 100755 --- a/js/lib/geom/brush-stroke.js +++ b/js/lib/geom/brush-stroke.js @@ -36,6 +36,7 @@ var BrushStroke = function GLBrushStroke() { this._strokeHardness = 100; this._strokeMaterial = null; this._strokeStyle = "Solid"; + this._strokeDoSmoothing = false; //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 //smaller value means more samples for the path @@ -183,6 +184,10 @@ var BrushStroke = function GLBrushStroke() { this._strokeHardness=h; } + this.setDoSmoothing = function(s){ + this._strokeDoSmoothing = s; + } + this.getStrokeStyle = function () { return this._strokeStyle; }; @@ -262,7 +267,7 @@ var BrushStroke = function GLBrushStroke() { } } //**** add samples to the long sections of the path --- Catmull-Rom spline interpolation - if (numPoints>1) { + if (this._strokeDoSmoothing && numPoints>1) { var numInsertedPoints = 0; var threshold = 5;//0.25*this._strokeWidth; //this determines whether a segment between two sample is too long var prevPt = this._Points[0]; @@ -507,35 +512,6 @@ var BrushStroke = function GLBrushStroke() { brushStamp.push(brushPt); } - - //make a circular brush stamp - brushStamp=[]; - numTraces = this._strokeWidth*Math.PI; //figure out how to - var radius = this._strokeWidth/2; - for (t=0;t