diff options
author | Pushkar Joshi | 2012-05-01 09:06:34 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-05-01 09:06:34 -0700 |
commit | f32420d51258f1caf048ac387985ee84f019604c (patch) | |
tree | a8d59d99b89843b3b201e92c7b44453cc4a34a84 /js | |
parent | 57c373259fb22a6c20248ef338dc2766a364ac59 (diff) | |
download | ninja-f32420d51258f1caf048ac387985ee84f019604c.tar.gz |
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.
Diffstat (limited to 'js')
-rwxr-xr-x | js/lib/geom/brush-stroke.js | 12 |
1 files changed, 11 insertions, 1 deletions
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() { | |||
704 | ctx.lineCap = "round"; | 704 | ctx.lineCap = "round"; |
705 | ctx.lineJoin="round"; | 705 | ctx.lineJoin="round"; |
706 | var minStrokeWidth = (this._strokeHardness*this._strokeWidth)/100; //the hardness is the percentage of the stroke width that's fully opaque | 706 | var minStrokeWidth = (this._strokeHardness*this._strokeWidth)/100; //the hardness is the percentage of the stroke width that's fully opaque |
707 | var numlayers = 1 + (this._strokeWidth-minStrokeWidth)/2; | 707 | var numlayers = 1 + Math.ceil((this._strokeWidth-minStrokeWidth)*0.5); |
708 | var alphaVal = 1.0/(numlayers); //this way the alpha at the first path will be 1 | 708 | var alphaVal = 1.0/(numlayers); //this way the alpha at the first path will be 1 |
709 | ctx.strokeStyle="rgba("+parseInt(255*this._strokeColor[0])+","+parseInt(255*this._strokeColor[1])+","+parseInt(255*this._strokeColor[2])+","+alphaVal+")"; | 709 | ctx.strokeStyle="rgba("+parseInt(255*this._strokeColor[0])+","+parseInt(255*this._strokeColor[1])+","+parseInt(255*this._strokeColor[2])+","+alphaVal+")"; |
710 | for (var l=0;l<numlayers;l++){ | 710 | for (var l=0;l<numlayers;l++){ |
@@ -732,6 +732,16 @@ var BrushStroke = function GLBrushStroke() { | |||
732 | ctx.lineTo(p[0],p[1]); | 732 | ctx.lineTo(p[0],p[1]); |
733 | } | 733 | } |
734 | ctx.lineWidth=2*l+minStrokeWidth; | 734 | ctx.lineWidth=2*l+minStrokeWidth; |
735 | |||
736 | |||
737 | //experiments with shadows | ||
738 | /* | ||
739 | ctx.shadowOffsetX = 10; | ||
740 | ctx.shadowOffsetY = 10; | ||
741 | ctx.shadowBlur = 10; | ||
742 | ctx.shadowColor = //"rgb("+parseInt(255*this._strokeColor[0])+","+parseInt(255*this._strokeColor[1])+","+parseInt(255*this._strokeColor[2])+")"; | ||
743 | "#FF6666"; //or use rgb(red, green, blue) | ||
744 | */ | ||
735 | ctx.stroke(); | 745 | ctx.stroke(); |
736 | }//for every layer l | 746 | }//for every layer l |
737 | } //if there is no calligraphic stroke | 747 | } //if there is no calligraphic stroke |