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 --- .../brush-properties.reel/brush-properties.html | 4 +- .../brush-properties.reel/brush-properties.js | 3 + js/lib/geom/brush-stroke.js | 66 +++++++--------------- js/tools/BrushTool.js | 6 ++ 4 files changed, 31 insertions(+), 48 deletions(-) diff --git a/js/components/tools-properties/brush-properties.reel/brush-properties.html b/js/components/tools-properties/brush-properties.reel/brush-properties.html index af07b3f2..6d4852e6 100755 --- a/js/components/tools-properties/brush-properties.reel/brush-properties.html +++ b/js/components/tools-properties/brush-properties.reel/brush-properties.html @@ -43,7 +43,8 @@ "properties": { "element": {"#": "brushProperties"}, "_strokeSize": {"@": "strokeSizeHT"}, - "_strokeHardness": {"@": "strokeHardnessHT"} + "_strokeHardness": {"@": "strokeHardnessHT"}, + "_doSmoothing": {"@": "doSmoothing"} } } } @@ -58,6 +59,7 @@
+ diff --git a/js/components/tools-properties/brush-properties.reel/brush-properties.js b/js/components/tools-properties/brush-properties.reel/brush-properties.js index d2fcf888..0ce685b5 100755 --- a/js/components/tools-properties/brush-properties.reel/brush-properties.js +++ b/js/components/tools-properties/brush-properties.reel/brush-properties.js @@ -14,5 +14,8 @@ exports.BrushProperties = Montage.create(ToolProperties, { }, strokeHardness: { get: function() { return this._strokeHardness; } + }, + doSmoothing:{ + get: function() {return this._doSmoothing; } } }); 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