From f32420d51258f1caf048ac387985ee84f019604c Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 1 May 2012 09:06:34 -0700 Subject: prevent alpha values from accumulating over 1 due to rounding...fixes 1443 Brush: Odd painting behavior when Hardness is 99%. A solid outline is shown on the brushstroke. --- js/lib/geom/brush-stroke.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'js/lib') diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js index d5d9a893..27d12f03 100755 --- a/js/lib/geom/brush-stroke.js +++ b/js/lib/geom/brush-stroke.js @@ -704,7 +704,7 @@ var BrushStroke = function GLBrushStroke() { ctx.lineCap = "round"; ctx.lineJoin="round"; var minStrokeWidth = (this._strokeHardness*this._strokeWidth)/100; //the hardness is the percentage of the stroke width that's fully opaque - var numlayers = 1 + (this._strokeWidth-minStrokeWidth)/2; + var numlayers = 1 + Math.ceil((this._strokeWidth-minStrokeWidth)*0.5); var alphaVal = 1.0/(numlayers); //this way the alpha at the first path will be 1 ctx.strokeStyle="rgba("+parseInt(255*this._strokeColor[0])+","+parseInt(255*this._strokeColor[1])+","+parseInt(255*this._strokeColor[2])+","+alphaVal+")"; for (var l=0;l