aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/circle.js
diff options
context:
space:
mode:
authorhwc4872012-03-16 12:40:50 -0700
committerhwc4872012-03-16 12:40:50 -0700
commit2ac5db3bb1bcee887d6dd742e6c0273abb5366bd (patch)
tree13622390967922f9c1719bf835f2f818867b5b9b /js/lib/geom/circle.js
parenta0d23354802ebc6b437698acb4b18d3395d47cd1 (diff)
parent3e98d9eaf6f691aa0f7a4334983537a4ee3ffd39 (diff)
downloadninja-2ac5db3bb1bcee887d6dd742e6c0273abb5366bd.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into integration
Diffstat (limited to 'js/lib/geom/circle.js')
-rwxr-xr-xjs/lib/geom/circle.js95
1 files changed, 84 insertions, 11 deletions
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index 7d1a3452..fec62308 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -444,16 +444,43 @@ var Circle = function GLCircle() {
444 var bezPts = MathUtils.circularArcToBezier( [0,0,0], [1,0,0], 2.0*Math.PI ); 444 var bezPts = MathUtils.circularArcToBezier( [0,0,0], [1,0,0], 2.0*Math.PI );
445 if (bezPts) { 445 if (bezPts) {
446 var n = bezPts.length; 446 var n = bezPts.length;
447 var gradient,
448 colors,
449 len,
450 j,
451 position,
452 cs,
453 c;
447 454
448 // set up the fill style 455 // set up the fill style
449 ctx.beginPath(); 456 ctx.beginPath();
450 ctx.lineWidth = 0; 457 ctx.lineWidth = 0;
451 if (this._fillColor) { 458 if (this._fillColor) {
452 var c = "rgba(" + 255*this._fillColor[0] + "," + 255*this._fillColor[1] + "," + 255*this._fillColor[2] + "," + this._fillColor[3] + ")"; 459 if(this._fillColor.gradientMode) {
453 ctx.fillStyle = c; 460 if(this._fillColor.gradientMode === "radial") {
454 461 gradient = ctx.createRadialGradient(xCtr, yCtr, 0,
462 xCtr, yCtr, Math.max(yScale, xScale));
463 } else {
464 gradient = ctx.createLinearGradient(0, this._height/2, this._width, this._height/2);
465 }
466 colors = this._fillColor.color;
467
468 len = colors.length;
469
470 for(j=0; j<len; j++) {
471 position = colors[j].position/100;
472 cs = colors[j].value;
473 gradient.addColorStop(position, "rgba(" + cs.r + "," + cs.g + "," + cs.b + "," + cs.a + ")");
474 }
475
476 ctx.fillStyle = gradient;
477
478 } else {
479 c = "rgba(" + 255*this._fillColor[0] + "," + 255*this._fillColor[1] + "," + 255*this._fillColor[2] + "," + this._fillColor[3] + ")";
480 ctx.fillStyle = c;
481 }
455 // draw the fill 482 // draw the fill
456 ctx.beginPath(); 483// ctx.beginPath();
457 var p = MathUtils.transformPoint( bezPts[0], mat ); 484 var p = MathUtils.transformPoint( bezPts[0], mat );
458 ctx.moveTo( p[0], p[1] ); 485 ctx.moveTo( p[0], p[1] );
459 var index = 1; 486 var index = 1;
@@ -506,9 +533,29 @@ var Circle = function GLCircle() {
506 ctx.beginPath(); 533 ctx.beginPath();
507 ctx.lineWidth = lineWidth; 534 ctx.lineWidth = lineWidth;
508 if (this._strokeColor) { 535 if (this._strokeColor) {
509 var c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")"; 536 if(this._strokeColor.gradientMode) {
510 ctx.strokeStyle = c; 537 if(this._strokeColor.gradientMode === "radial") {
511 538 gradient = ctx.createRadialGradient(xCtr, yCtr, Math.min(xScale, yScale),
539 xCtr, yCtr, 0.5*Math.max(this._height, this._width));
540 } else {
541 gradient = ctx.createLinearGradient(0, this._height/2, this._width, this._height/2);
542 }
543 colors = this._strokeColor.color;
544
545 len = colors.length;
546
547 for(j=0; j<len; j++) {
548 position = colors[j].position/100;
549 cs = colors[j].value;
550 gradient.addColorStop(position, "rgba(" + cs.r + "," + cs.g + "," + cs.b + "," + cs.a + ")");
551 }
552
553 ctx.strokeStyle = gradient;
554
555 } else {
556 c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")";
557 ctx.strokeStyle = c;
558 }
512 // draw the stroke 559 // draw the stroke
513 p = MathUtils.transformPoint( bezPts[0], mat ); 560 p = MathUtils.transformPoint( bezPts[0], mat );
514 ctx.moveTo( p[0], p[1] ); 561 ctx.moveTo( p[0], p[1] );
@@ -619,8 +666,20 @@ var Circle = function GLCircle() {
619 rtnStr += "strokeWidth: " + this._strokeWidth + "\n"; 666 rtnStr += "strokeWidth: " + this._strokeWidth + "\n";
620 rtnStr += "innerRadius: " + this._innerRadius + "\n"; 667 rtnStr += "innerRadius: " + this._innerRadius + "\n";
621 rtnStr += "strokeStyle: " + this._strokeStyle + "\n"; 668 rtnStr += "strokeStyle: " + this._strokeStyle + "\n";
622 rtnStr += "strokeColor: " + String(this._strokeColor) + "\n"; 669
623 rtnStr += "fillColor: " + String(this._fillColor) + "\n"; 670 if(this._strokeColor.gradientMode) {
671 rtnStr += "strokeGradientMode: " + this._strokeColor.gradientMode + "\n";
672 rtnStr += "strokeColor: " + this.gradientToString(this._strokeColor.color) + "\n";
673 } else {
674 rtnStr += "strokeColor: " + String(this._strokeColor) + "\n";
675 }
676
677 if(this._fillColor.gradientMode) {
678 rtnStr += "fillGradientMode: " + this._fillColor.gradientMode + "\n";
679 rtnStr += "fillColor: " + this.gradientToString(this._fillColor.color) + "\n";
680 } else {
681 rtnStr += "fillColor: " + String(this._fillColor) + "\n";
682 }
624 683
625 rtnStr += "strokeMat: "; 684 rtnStr += "strokeMat: ";
626 if (this._strokeMaterial) { 685 if (this._strokeMaterial) {
@@ -654,8 +713,22 @@ var Circle = function GLCircle() {
654 this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr ); 713 this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr );
655 var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr ); 714 var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr );
656 var fillMaterialName = this.getPropertyFromString( "fillMat: ", importStr ); 715 var fillMaterialName = this.getPropertyFromString( "fillMat: ", importStr );
657 this._fillColor = eval( "[" + this.getPropertyFromString( "fillColor: ", importStr ) + "]" ); 716 if(importStr.indexOf("fillGradientMode: ") < 0) {
658 this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" ); 717 this._fillColor = eval( "[" + this.getPropertyFromString( "fillColor: ", importStr ) + "]" );
718 } else {
719 this._fillColor = {};
720 this._fillColor.gradientMode = this.getPropertyFromString( "fillGradientMode: ", importStr );
721 this._fillColor.color = this.stringToGradient(this.getPropertyFromString( "fillColor: ", importStr ));
722 }
723
724 if(importStr.indexOf("strokeGradientMode: ") < 0)
725 {
726 this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" );
727 } else {
728 this._strokeColor = {};
729 this._strokeColor.gradientMode = this.getPropertyFromString( "strokeGradientMode: ", importStr );
730 this._strokeColor.color = this.stringToGradient(this.getPropertyFromString( "strokeColor: ", importStr ));
731 }
659 732
660 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); 733 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
661 if (!strokeMat) { 734 if (!strokeMat) {