aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/circle.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom/circle.js')
-rwxr-xr-xjs/lib/geom/circle.js94
1 files changed, 48 insertions, 46 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 }