diff options
author | hwc487 | 2012-06-13 10:17:07 -0700 |
---|---|---|
committer | hwc487 | 2012-06-13 10:17:07 -0700 |
commit | eea0703ca3b7f066a9d685ce09905d4860fa082d (patch) | |
tree | f0000ae8469a9e551f629c744251e6a688bbec4c /assets | |
parent | 1fe66f1a89ac949dee44ae881556901a8bf98bba (diff) | |
parent | 5a7774f6769a7a682e21bafe0e57007668f16153 (diff) | |
download | ninja-eea0703ca3b7f066a9d685ce09905d4860fa082d.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Textures
Conflicts:
js/io/system/ninjalibrary.json
Diffstat (limited to 'assets')
-rw-r--r-- | assets/canvas-runtime.js | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index 753161aa..2035d2e0 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js | |||
@@ -2447,7 +2447,40 @@ NinjaCvsRt.RuntimeBrushStroke = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
2447 | } | 2447 | } |
2448 | this._LocalPoints = newPoints.slice(0); | 2448 | this._LocalPoints = newPoints.slice(0); |
2449 | } | 2449 | } |
2450 | } | 2450 | |
2451 | // *** compute the bounding box ********* | ||
2452 | var BBoxMin = [Infinity, Infinity, Infinity]; | ||
2453 | var BBoxMax = [-Infinity, -Infinity, -Infinity]; | ||
2454 | if (numPoints === 0) { | ||
2455 | BBoxMin = [0, 0, 0]; | ||
2456 | BBoxMax = [0, 0, 0]; | ||
2457 | } else { | ||
2458 | for (var i=0;i<numPoints;i++){ | ||
2459 | var pt = this._LocalPoints[i]; | ||
2460 | for (var d = 0; d < 3; d++) { | ||
2461 | if (BBoxMin[d] > pt[d]) { | ||
2462 | BBoxMin[d] = pt[d]; | ||
2463 | } | ||
2464 | if (BBoxMax[d] < pt[d]) { | ||
2465 | BBoxMax[d] = pt[d]; | ||
2466 | } | ||
2467 | }//for every dimension d from 0 to 2 | ||
2468 | } | ||
2469 | } | ||
2470 | |||
2471 | //increase the bbox given the stroke width and the angle (in case of calligraphic brush) | ||
2472 | var bboxPadding = this._strokeWidth*0.5; | ||
2473 | for (var d = 0; d < 3; d++) { | ||
2474 | BBoxMin[d]-= bboxPadding; | ||
2475 | BBoxMax[d]+= bboxPadding; | ||
2476 | }//for every dimension d from 0 to 2 | ||
2477 | |||
2478 | //******* update the local coords so that the bbox min is at the origin ****** | ||
2479 | for (var i=0;i<numPoints;i++) { | ||
2480 | this._LocalPoints[i][0]-= BBoxMin[0]; | ||
2481 | this._LocalPoints[i][1]-= BBoxMin[1]; | ||
2482 | } | ||
2483 | }//if we need to do smoothing | ||
2451 | } | 2484 | } |
2452 | }, | 2485 | }, |
2453 | 2486 | ||
@@ -2571,7 +2604,10 @@ NinjaCvsRt.RuntimeBrushStroke = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
2571 | var disp = [brushStamp[t][0], brushStamp[t][1]]; | 2604 | var disp = [brushStamp[t][0], brushStamp[t][1]]; |
2572 | var alphaVal = 1.0; | 2605 | var alphaVal = 1.0; |
2573 | var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth; | 2606 | var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth; |
2574 | if (distFromOpaqueRegion>0) { | 2607 | if (numTraces === 1){ |
2608 | distFromOpaqueRegion = 0; | ||
2609 | } | ||
2610 | else if (distFromOpaqueRegion>0) { | ||
2575 | var transparencyFactor = distFromOpaqueRegion/maxTransparentRegionHalfWidth; | 2611 | var transparencyFactor = distFromOpaqueRegion/maxTransparentRegionHalfWidth; |
2576 | alphaVal = 1.0 - transparencyFactor;//(transparencyFactor*transparencyFactor);//the square term produces nonlinearly varying alpha values | 2612 | alphaVal = 1.0 - transparencyFactor;//(transparencyFactor*transparencyFactor);//the square term produces nonlinearly varying alpha values |
2577 | alphaVal *= 0.5; //factor that accounts for lineWidth == 2 | 2613 | alphaVal *= 0.5; //factor that accounts for lineWidth == 2 |