aboutsummaryrefslogtreecommitdiff
path: root/assets/canvas-runtime.js
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-06-13 10:03:53 -0700
committerNivesh Rajbhandari2012-06-13 10:03:53 -0700
commit1cfbfc91815b04dc2a5b090c5e05e300b9371eb7 (patch)
tree4cf6749de9fea6b90370e6f593146ae4a8690384 /assets/canvas-runtime.js
parent509092ff335f74517a413cfb2deeb9d2de20f8e3 (diff)
parent5a7774f6769a7a682e21bafe0e57007668f16153 (diff)
downloadninja-1cfbfc91815b04dc2a5b090c5e05e300b9371eb7.tar.gz
Merge branch 'refs/heads/ninja-internal' into PI_HotTextFixes
Diffstat (limited to 'assets/canvas-runtime.js')
-rw-r--r--assets/canvas-runtime.js40
1 files changed, 38 insertions, 2 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js
index fe5f839c..feb35187 100644
--- a/assets/canvas-runtime.js
+++ b/assets/canvas-runtime.js
@@ -2107,7 +2107,40 @@ NinjaCvsRt.RuntimeBrushStroke = Object.create(NinjaCvsRt.RuntimeGeomObj, {
2107 } 2107 }
2108 this._LocalPoints = newPoints.slice(0); 2108 this._LocalPoints = newPoints.slice(0);
2109 } 2109 }
2110 } 2110
2111 // *** compute the bounding box *********
2112 var BBoxMin = [Infinity, Infinity, Infinity];
2113 var BBoxMax = [-Infinity, -Infinity, -Infinity];
2114 if (numPoints === 0) {
2115 BBoxMin = [0, 0, 0];
2116 BBoxMax = [0, 0, 0];
2117 } else {
2118 for (var i=0;i<numPoints;i++){
2119 var pt = this._LocalPoints[i];
2120 for (var d = 0; d < 3; d++) {
2121 if (BBoxMin[d] > pt[d]) {
2122 BBoxMin[d] = pt[d];
2123 }
2124 if (BBoxMax[d] < pt[d]) {
2125 BBoxMax[d] = pt[d];
2126 }
2127 }//for every dimension d from 0 to 2
2128 }
2129 }
2130
2131 //increase the bbox given the stroke width and the angle (in case of calligraphic brush)
2132 var bboxPadding = this._strokeWidth*0.5;
2133 for (var d = 0; d < 3; d++) {
2134 BBoxMin[d]-= bboxPadding;
2135 BBoxMax[d]+= bboxPadding;
2136 }//for every dimension d from 0 to 2
2137
2138 //******* update the local coords so that the bbox min is at the origin ******
2139 for (var i=0;i<numPoints;i++) {
2140 this._LocalPoints[i][0]-= BBoxMin[0];
2141 this._LocalPoints[i][1]-= BBoxMin[1];
2142 }
2143 }//if we need to do smoothing
2111 } 2144 }
2112 }, 2145 },
2113 2146
@@ -2231,7 +2264,10 @@ NinjaCvsRt.RuntimeBrushStroke = Object.create(NinjaCvsRt.RuntimeGeomObj, {
2231 var disp = [brushStamp[t][0], brushStamp[t][1]]; 2264 var disp = [brushStamp[t][0], brushStamp[t][1]];
2232 var alphaVal = 1.0; 2265 var alphaVal = 1.0;
2233 var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth; 2266 var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth;
2234 if (distFromOpaqueRegion>0) { 2267 if (numTraces === 1){
2268 distFromOpaqueRegion = 0;
2269 }
2270 else if (distFromOpaqueRegion>0) {
2235 var transparencyFactor = distFromOpaqueRegion/maxTransparentRegionHalfWidth; 2271 var transparencyFactor = distFromOpaqueRegion/maxTransparentRegionHalfWidth;
2236 alphaVal = 1.0 - transparencyFactor;//(transparencyFactor*transparencyFactor);//the square term produces nonlinearly varying alpha values 2272 alphaVal = 1.0 - transparencyFactor;//(transparencyFactor*transparencyFactor);//the square term produces nonlinearly varying alpha values
2237 alphaVal *= 0.5; //factor that accounts for lineWidth == 2 2273 alphaVal *= 0.5; //factor that accounts for lineWidth == 2