aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom
diff options
context:
space:
mode:
authorPushkar Joshi2012-05-01 15:10:14 -0700
committerPushkar Joshi2012-05-01 15:10:14 -0700
commit42b0fe45cded043f2c210f263a3eb2ba2dbd09c2 (patch)
treed2f43650653b033185d6ed2b7997e4a28ff8467e /js/lib/geom
parentd91e67e06095afbdbe47353eb71d2829a9a9c401 (diff)
downloadninja-42b0fe45cded043f2c210f263a3eb2ba2dbd09c2.tar.gz
small code changes (mostly re-org)
Diffstat (limited to 'js/lib/geom')
-rwxr-xr-xjs/lib/geom/brush-stroke.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js
index 574cead1..a1746d95 100755
--- a/js/lib/geom/brush-stroke.js
+++ b/js/lib/geom/brush-stroke.js
@@ -637,7 +637,7 @@ var BrushStroke = function GLBrushStroke() {
637 //build the stamp for the brush stroke 637 //build the stamp for the brush stroke
638 var t=0; 638 var t=0;
639 var numTraces = this._strokeWidth; 639 var numTraces = this._strokeWidth;
640 var halfNumTraces = numTraces/2; 640 var halfNumTraces = numTraces*0.5;
641 var opaqueRegionHalfWidth = 0.5*this._strokeHardness*numTraces*0.01; //the 0.01 is to convert the strokeHardness from [0,100] to [0,1] 641 var opaqueRegionHalfWidth = 0.5*this._strokeHardness*numTraces*0.01; //the 0.01 is to convert the strokeHardness from [0,100] to [0,1]
642 var maxTransparentRegionHalfWidth = halfNumTraces-opaqueRegionHalfWidth; 642 var maxTransparentRegionHalfWidth = halfNumTraces-opaqueRegionHalfWidth;
643 643
@@ -658,21 +658,21 @@ var BrushStroke = function GLBrushStroke() {
658 ctx.globalCompositeOperation = 'source-over'; 658 ctx.globalCompositeOperation = 'source-over';
659 ctx.globalAlpha = this._strokeColor[3]; 659 ctx.globalAlpha = this._strokeColor[3];
660 660
661
662 for (t=0;t<numTraces;t++){ 661 for (t=0;t<numTraces;t++){
663 var disp = [brushStamp[t][0], brushStamp[t][1]]; 662 var disp = [brushStamp[t][0], brushStamp[t][1]];
664 var alphaVal = 1.0; 663 var alphaVal = 1.0;
665 var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth; 664 var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth;
666 if (distFromOpaqueRegion>0) { 665 if (distFromOpaqueRegion>0) {
667 alphaVal = 1.0 - distFromOpaqueRegion/maxTransparentRegionHalfWidth; 666 var transparencyFactor = distFromOpaqueRegion/maxTransparentRegionHalfWidth;
668 alphaVal *= 1.0/ctx.lineWidth; //factor that accounts for lineWidth !== 1 667 alphaVal = 1.0 - transparencyFactor;//(transparencyFactor*transparencyFactor);//the square term produces nonlinearly varying alpha values
669 } 668 }
670 ctx.save(); 669 ctx.save();
671 if (t === (numTraces-1)){ 670 if (t === (numTraces-1) || t === 0){
672 ctx.lineWidth = 1; 671 ctx.lineWidth = 1;
673 } else { 672 } else {
674 //todo figure out the correct formula for the line width 673 //todo figure out the correct formula for the line width
675 ctx.lineWidth=2; 674 ctx.lineWidth=2;
675 alphaVal *= 0.5; //factor that accounts for lineWidth == 2
676 } 676 }
677 ctx.strokeStyle="rgba("+parseInt(255*this._strokeColor[0])+","+parseInt(255*this._strokeColor[1])+","+parseInt(255*this._strokeColor[2])+","+alphaVal+")"; 677 ctx.strokeStyle="rgba("+parseInt(255*this._strokeColor[0])+","+parseInt(255*this._strokeColor[1])+","+parseInt(255*this._strokeColor[2])+","+alphaVal+")";
678 //linearly interpolate between the two stroke colors 678 //linearly interpolate between the two stroke colors