aboutsummaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
authorJon Reid2012-06-15 10:10:41 -0700
committerJon Reid2012-06-15 10:10:41 -0700
commit526ac54f73d53e1e2a3d6a4dbf4f9992c143baf7 (patch)
tree65939e59615aaa10a7db77211e71616ad531bd0e /assets
parentb5b760ee82e5cc4da176914983a6002cbf86c11a (diff)
parent5ee0c89fa0c7acc280ff3b884767e8513fd0b315 (diff)
downloadninja-526ac54f73d53e1e2a3d6a4dbf4f9992c143baf7.tar.gz
Merge remote-tracking branch 'ninja-internal/master' into test-merge
Conflicts: js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js js/panels/Timeline/TimelineTrack.reel/TimelineTrack.html js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
Diffstat (limited to 'assets')
-rw-r--r--assets/canvas-runtime.js44
1 files changed, 41 insertions, 3 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js
index fe5f839c..6268f0bb 100644
--- a/assets/canvas-runtime.js
+++ b/assets/canvas-runtime.js
@@ -1969,7 +1969,8 @@ NinjaCvsRt.RuntimeSubPath = Object.create(NinjaCvsRt.RuntimeGeomObj, {
1969 if (ipColor.gradientMode){ 1969 if (ipColor.gradientMode){
1970 var position, gradient, cs, inset; //vars used in gradient calculations 1970 var position, gradient, cs, inset; //vars used in gradient calculations
1971 inset = Math.ceil( lw ) - 0.5; 1971 inset = Math.ceil( lw ) - 0.5;
1972 1972 inset=0;
1973
1973 if(ipColor.gradientMode === "radial") { 1974 if(ipColor.gradientMode === "radial") {
1974 var ww = w - 2*lw, hh = h - 2*lw; 1975 var ww = w - 2*lw, hh = h - 2*lw;
1975 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(ww, hh)/2); 1976 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(ww, hh)/2);
@@ -2107,7 +2108,40 @@ NinjaCvsRt.RuntimeBrushStroke = Object.create(NinjaCvsRt.RuntimeGeomObj, {
2107 } 2108 }
2108 this._LocalPoints = newPoints.slice(0); 2109 this._LocalPoints = newPoints.slice(0);
2109 } 2110 }
2110 } 2111
2112 // *** compute the bounding box *********
2113 var BBoxMin = [Infinity, Infinity, Infinity];
2114 var BBoxMax = [-Infinity, -Infinity, -Infinity];
2115 if (numPoints === 0) {
2116 BBoxMin = [0, 0, 0];
2117 BBoxMax = [0, 0, 0];
2118 } else {
2119 for (var i=0;i<numPoints;i++){
2120 var pt = this._LocalPoints[i];
2121 for (var d = 0; d < 3; d++) {
2122 if (BBoxMin[d] > pt[d]) {
2123 BBoxMin[d] = pt[d];
2124 }
2125 if (BBoxMax[d] < pt[d]) {
2126 BBoxMax[d] = pt[d];
2127 }
2128 }//for every dimension d from 0 to 2
2129 }
2130 }
2131
2132 //increase the bbox given the stroke width and the angle (in case of calligraphic brush)
2133 var bboxPadding = this._strokeWidth*0.5;
2134 for (var d = 0; d < 3; d++) {
2135 BBoxMin[d]-= bboxPadding;
2136 BBoxMax[d]+= bboxPadding;
2137 }//for every dimension d from 0 to 2
2138
2139 //******* update the local coords so that the bbox min is at the origin ******
2140 for (var i=0;i<numPoints;i++) {
2141 this._LocalPoints[i][0]-= BBoxMin[0];
2142 this._LocalPoints[i][1]-= BBoxMin[1];
2143 }
2144 }//if we need to do smoothing
2111 } 2145 }
2112 }, 2146 },
2113 2147
@@ -2148,6 +2182,7 @@ NinjaCvsRt.RuntimeBrushStroke = Object.create(NinjaCvsRt.RuntimeGeomObj, {
2148 if (ipColor.gradientMode){ 2182 if (ipColor.gradientMode){
2149 var position, gradient, cs, inset; //vars used in gradient calculations 2183 var position, gradient, cs, inset; //vars used in gradient calculations
2150 inset = Math.ceil( lw ) - 0.5; 2184 inset = Math.ceil( lw ) - 0.5;
2185 inset=0;
2151 2186
2152 if(ipColor.gradientMode === "radial") { 2187 if(ipColor.gradientMode === "radial") {
2153 var ww = w - 2*lw, hh = h - 2*lw; 2188 var ww = w - 2*lw, hh = h - 2*lw;
@@ -2231,7 +2266,10 @@ NinjaCvsRt.RuntimeBrushStroke = Object.create(NinjaCvsRt.RuntimeGeomObj, {
2231 var disp = [brushStamp[t][0], brushStamp[t][1]]; 2266 var disp = [brushStamp[t][0], brushStamp[t][1]];
2232 var alphaVal = 1.0; 2267 var alphaVal = 1.0;
2233 var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth; 2268 var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth;
2234 if (distFromOpaqueRegion>0) { 2269 if (numTraces === 1){
2270 distFromOpaqueRegion = 0;
2271 }
2272 else if (distFromOpaqueRegion>0) {
2235 var transparencyFactor = distFromOpaqueRegion/maxTransparentRegionHalfWidth; 2273 var transparencyFactor = distFromOpaqueRegion/maxTransparentRegionHalfWidth;
2236 alphaVal = 1.0 - transparencyFactor;//(transparencyFactor*transparencyFactor);//the square term produces nonlinearly varying alpha values 2274 alphaVal = 1.0 - transparencyFactor;//(transparencyFactor*transparencyFactor);//the square term produces nonlinearly varying alpha values
2237 alphaVal *= 0.5; //factor that accounts for lineWidth == 2 2275 alphaVal *= 0.5; //factor that accounts for lineWidth == 2