diff options
author | Eric Guzman | 2012-06-19 01:20:36 -0700 |
---|---|---|
committer | Eric Guzman | 2012-06-19 01:20:36 -0700 |
commit | 2ef72cdf0e59fb3623a2c13251ac707522f3dc5a (patch) | |
tree | f69f4e3de7e4441311ef2b38770e0ce26067aac4 /assets | |
parent | 5260d3dfd99d79924c4aaa3ab798e90c7d328d7d (diff) | |
parent | 1007cbf983ad0f2460a4122a492a96023fdb4439 (diff) | |
download | ninja-2ef72cdf0e59fb3623a2c13251ac707522f3dc5a.tar.gz |
Merge branch 'binding' of github.com:dhg637/ninja-internal into binding
Conflicts:
js/stage/binding-view.reel/binding-view.js
Diffstat (limited to 'assets')
-rw-r--r-- | assets/canvas-runtime.js | 44 |
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 |