aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
authorEric Guzman2012-08-20 14:54:44 -0700
committerEric Guzman2012-08-20 14:54:44 -0700
commit1e9d019867ff90840735ec531af5ebec9c7962e6 (patch)
tree887d28987a3113e84c771e264767c9462e9a8844 /js/lib
parenta34663e154af834176b758b6da368f634cd2a6bd (diff)
parent36d692a9fb216f2785a570d13c1beb27360c7305 (diff)
downloadninja-1e9d019867ff90840735ec531af5ebec9c7962e6.tar.gz
Merge branch 'refs/heads/master' into minorFixes_7.1
Diffstat (limited to 'js/lib')
-rwxr-xr-xjs/lib/geom/circle.js94
-rwxr-xr-xjs/lib/geom/line.js13
-rwxr-xr-xjs/lib/geom/rectangle.js2
3 files changed, 60 insertions, 49 deletions
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index 4995c2cb..28a99956 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -669,53 +669,33 @@ exports.Circle = Object.create(GeomObj, {
669 mat[5] = yScale; 669 mat[5] = yScale;
670 670
671 // set up the stroke style 671 // set up the stroke style
672 ctx.beginPath(); 672 if(lineWidth > 0) {
673 ctx.lineWidth = lineWidth; 673 ctx.beginPath();
674 if (this._strokeColor) { 674 ctx.lineWidth = lineWidth;
675 if(this._strokeColor.gradientMode) { 675 if (this._strokeColor) {
676 if(this._strokeColor.gradientMode === "radial") { 676 if(this._strokeColor.gradientMode) {
677 gradient = ctx.createRadialGradient(xCtr, yCtr, 0, 677 if(this._strokeColor.gradientMode === "radial") {
678 xCtr, yCtr, 0.5*Math.max(this._height, this._width)); 678 gradient = ctx.createRadialGradient(xCtr, yCtr, 0,
679 } else { 679 xCtr, yCtr, 0.5*Math.max(this._height, this._width));
680 gradient = ctx.createLinearGradient(0, this._height/2, this._width, this._height/2); 680 } else {
681 } 681 gradient = ctx.createLinearGradient(0, this._height/2, this._width, this._height/2);
682 colors = this._strokeColor.color; 682 }
683 683 colors = this._strokeColor.color;
684 len = colors.length;
685
686 for(j=0; j<len; j++) {
687 position = colors[j].position/100;
688 cs = colors[j].value;
689 gradient.addColorStop(position, "rgba(" + cs.r + "," + cs.g + "," + cs.b + "," + cs.a + ")");
690 }
691
692 ctx.strokeStyle = gradient;
693 684
694 } else { 685 len = colors.length;
695 c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")";
696 ctx.strokeStyle = c;
697 }
698 // draw the stroke
699 p = MathUtils.transformPoint( bezPts[0], mat );
700 ctx.moveTo( p[0], p[1] );
701 index = 1;
702 while (index < n) {
703 var p0 = MathUtils.transformPoint( bezPts[index], mat );
704 var p1 = MathUtils.transformPoint( bezPts[index+1], mat );
705 686
706 var x0 = p0[0], y0 = p0[1], 687 for(j=0; j<len; j++) {
707 x1 = p1[0], y1 = p1[1]; 688 position = colors[j].position/100;
708 ctx.quadraticCurveTo( x0, y0, x1, y1 ); 689 cs = colors[j].value;
709 index += 2; 690 gradient.addColorStop(position, "rgba(" + cs.r + "," + cs.g + "," + cs.b + "," + cs.a + ")");
710 } 691 }
711 692
712 if (MathUtils.fpSign(innerRad) > 0) { 693 ctx.strokeStyle = gradient;
713 // calculate the stroke matrix
714 xScale = 0.5*innerRad*this._width - 0.5*lineWidth;
715 yScale = 0.5*innerRad*this._height - 0.5*lineWidth;
716 mat[0] = xScale;
717 mat[5] = yScale;
718 694
695 } else {
696 c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")";
697 ctx.strokeStyle = c;
698 }
719 // draw the stroke 699 // draw the stroke
720 p = MathUtils.transformPoint( bezPts[0], mat ); 700 p = MathUtils.transformPoint( bezPts[0], mat );
721 ctx.moveTo( p[0], p[1] ); 701 ctx.moveTo( p[0], p[1] );
@@ -729,10 +709,32 @@ exports.Circle = Object.create(GeomObj, {
729 ctx.quadraticCurveTo( x0, y0, x1, y1 ); 709 ctx.quadraticCurveTo( x0, y0, x1, y1 );
730 index += 2; 710 index += 2;
731 } 711 }
732 }
733 712
734 // render the stroke 713 if (MathUtils.fpSign(innerRad) > 0) {
735 ctx.stroke(); 714 // calculate the stroke matrix
715 xScale = 0.5*innerRad*this._width - 0.5*lineWidth;
716 yScale = 0.5*innerRad*this._height - 0.5*lineWidth;
717 mat[0] = xScale;
718 mat[5] = yScale;
719
720 // draw the stroke
721 p = MathUtils.transformPoint( bezPts[0], mat );
722 ctx.moveTo( p[0], p[1] );
723 index = 1;
724 while (index < n) {
725 var p0 = MathUtils.transformPoint( bezPts[index], mat );
726 var p1 = MathUtils.transformPoint( bezPts[index+1], mat );
727
728 var x0 = p0[0], y0 = p0[1],
729 x1 = p1[0], y1 = p1[1];
730 ctx.quadraticCurveTo( x0, y0, x1, y1 );
731 index += 2;
732 }
733 }
734
735 // render the stroke
736 ctx.stroke();
737 }
736 } 738 }
737 } 739 }
738 } 740 }
diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js
index eec4f6d9..df65ee86 100755
--- a/js/lib/geom/line.js
+++ b/js/lib/geom/line.js
@@ -537,6 +537,15 @@ exports.Line = Object.create(GeomObj, {
537 ctx.strokeStyle = c; 537 ctx.strokeStyle = c;
538 } 538 }
539 539
540 var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils;
541 viewUtils.pushViewportObj( world.getCanvas() );
542 var cop = viewUtils.getCenterOfProjection();
543 viewUtils.popViewportObj();
544 var xCtr = cop[0] + this._xOffset, yCtr = cop[1] - this._yOffset;
545 var xLeft = xCtr - 0.5*this.getWidth(), yTop = yCtr - 0.5*this.getHeight();
546 var xDist = cop[0] - xLeft, yDist = cop[1] - yTop;
547 var xOff = 0.5*world.getViewportWidth() - xDist, yOff = 0.5*world.getViewportHeight() - yDist;
548
540 // get the points 549 // get the points
541 var p0, p1; 550 var p0, p1;
542 if(this._slope === "vertical") { 551 if(this._slope === "vertical") {
@@ -554,8 +563,8 @@ exports.Line = Object.create(GeomObj, {
554 } 563 }
555 564
556 // draw the line 565 // draw the line
557 ctx.moveTo( p0[0], p0[1] ); 566 ctx.moveTo( p0[0]+xOff, p0[1]+yOff );
558 ctx.lineTo( p1[0], p1[1] ); 567 ctx.lineTo( p1[0]+xOff, p1[1]+yOff );
559 ctx.stroke(); 568 ctx.stroke();
560 } 569 }
561 } 570 }
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js
index f3db92af..b34a97ab 100755
--- a/js/lib/geom/rectangle.js
+++ b/js/lib/geom/rectangle.js
@@ -603,7 +603,7 @@ exports.Rectangle = Object.create(GeomObj, {
603 603
604 // render the stroke 604 // render the stroke
605 ctx.beginPath(); 605 ctx.beginPath();
606 if (this._strokeColor) { 606 if (this._strokeColor && (lw > 0)) {
607 inset = Math.ceil( 0.5*lw ) - 0.5; 607 inset = Math.ceil( 0.5*lw ) - 0.5;
608 608
609 if(this._strokeColor.gradientMode) { 609 if(this._strokeColor.gradientMode) {