aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhwc4872012-05-18 12:35:58 -0700
committerhwc4872012-05-18 12:35:58 -0700
commit6b03f357f45d76733ae7bf5ff52ffe2fb2a84fda (patch)
tree2411bd4bf3478621a16c83ead914670e0d143372
parent651341341f894c4d0def267ab3250e77f7d0c276 (diff)
downloadninja-6b03f357f45d76733ae7bf5ff52ffe2fb2a84fda.tar.gz
Updates for WebGL/Canvas 2D authortime and runtime gradients.
-rw-r--r--assets/canvas-runtime.js26
-rw-r--r--js/io/system/ninjalibrary.json2
-rwxr-xr-xjs/lib/geom/circle.js2
-rwxr-xr-xjs/lib/geom/rectangle.js10
4 files changed, 19 insertions, 21 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js
index b6682493..67d53963 100644
--- a/assets/canvas-runtime.js
+++ b/assets/canvas-runtime.js
@@ -878,11 +878,12 @@ NinjaCvsRt.RuntimeRectangle = Object.create(NinjaCvsRt.RuntimeGeomObj, {
878 inset = Math.ceil( lw ) - 0.5; 878 inset = Math.ceil( lw ) - 0.5;
879 879
880 if(this._fillColor.gradientMode) { 880 if(this._fillColor.gradientMode) {
881 if(this._fillColor.gradientMode === "radial") { 881 if(this._fillColor.gradientMode === "radial") {
882 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(w, h)/2); 882 var ww = w - 2*lw, hh = h - 2*lw;
883 } else { 883 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(ww, hh)/2);
884 gradient = ctx.createLinearGradient(inset/2, h/2, w-inset, h/2); 884 } else {
885 } 885 gradient = ctx.createLinearGradient(inset, h/2, w-inset, h/2);
886 }
886 colors = this._fillColor.color; 887 colors = this._fillColor.color;
887 888
888 len = colors.length; 889 len = colors.length;
@@ -912,11 +913,10 @@ NinjaCvsRt.RuntimeRectangle = Object.create(NinjaCvsRt.RuntimeGeomObj, {
912 inset = Math.ceil( 0.5*lw ) - 0.5; 913 inset = Math.ceil( 0.5*lw ) - 0.5;
913 914
914 if(this._strokeColor.gradientMode) { 915 if(this._strokeColor.gradientMode) {
915 if(this._strokeColor.gradientMode === "radial") { 916 if(this._strokeColor.gradientMode === "radial")
916 gradient = ctx.createRadialGradient(w/2, h/2, Math.min(h, w)/2-inset, w/2, h/2, Math.max(h, w)/2); 917 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(h, w)/2);
917 } else { 918 else
918 gradient = ctx.createLinearGradient(0, h/2, w, h/2); 919 gradient = ctx.createLinearGradient(0, h/2, w, h/2);
919 }
920 colors = this._strokeColor.color; 920 colors = this._strokeColor.color;
921 921
922 len = colors.length; 922 len = colors.length;
@@ -1116,9 +1116,9 @@ NinjaCvsRt.RuntimeOval = Object.create(NinjaCvsRt.RuntimeGeomObj, {
1116 if(this._fillColor.gradientMode) { 1116 if(this._fillColor.gradientMode) {
1117 if(this._fillColor.gradientMode === "radial") { 1117 if(this._fillColor.gradientMode === "radial") {
1118 gradient = ctx.createRadialGradient(xCtr, yCtr, 0, 1118 gradient = ctx.createRadialGradient(xCtr, yCtr, 0,
1119 xCtr, yCtr, Math.max(this._width, this._height)/2); 1119 xCtr, yCtr, Math.max(this._width, this._height)/2 - lineWidth);
1120 } else { 1120 } else {
1121 gradient = ctx.createLinearGradient(lineWidth/2, this._height/2, this._width-lineWidth, this._height/2); 1121 gradient = ctx.createLinearGradient(lineWidth, this._height/2, this._width-lineWidth, this._height/2);
1122 } 1122 }
1123 colors = this._fillColor.color; 1123 colors = this._fillColor.color;
1124 1124
@@ -1194,7 +1194,7 @@ NinjaCvsRt.RuntimeOval = Object.create(NinjaCvsRt.RuntimeGeomObj, {
1194 if (this._strokeColor) { 1194 if (this._strokeColor) {
1195 if(this._strokeColor.gradientMode) { 1195 if(this._strokeColor.gradientMode) {
1196 if(this._strokeColor.gradientMode === "radial") { 1196 if(this._strokeColor.gradientMode === "radial") {
1197 gradient = ctx.createRadialGradient(xCtr, yCtr, Math.min(xScale, yScale), 1197 gradient = ctx.createRadialGradient(xCtr, yCtr, 0,
1198 xCtr, yCtr, 0.5*Math.max(this._height, this._width)); 1198 xCtr, yCtr, 0.5*Math.max(this._height, this._width));
1199 } else { 1199 } else {
1200 gradient = ctx.createLinearGradient(0, this._height/2, this._width, this._height/2); 1200 gradient = ctx.createLinearGradient(0, this._height/2, this._width, this._height/2);
diff --git a/js/io/system/ninjalibrary.json b/js/io/system/ninjalibrary.json
index 5bacb28a..0d211fb5 100644
--- a/js/io/system/ninjalibrary.json
+++ b/js/io/system/ninjalibrary.json
@@ -1,6 +1,6 @@
1{ 1{
2 "libraries": [ 2 "libraries": [
3 {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.8.0.0"}, 3 {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.8.0.0"},
4 {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.6.1"} 4 {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.6.2"}
5 ] 5 ]
6} \ No newline at end of file 6} \ No newline at end of file
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index 2ca4c1f5..4a369844 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -581,7 +581,7 @@ exports.Circle = Object.create(GeomObj, {
581 if (this._strokeColor) { 581 if (this._strokeColor) {
582 if(this._strokeColor.gradientMode) { 582 if(this._strokeColor.gradientMode) {
583 if(this._strokeColor.gradientMode === "radial") { 583 if(this._strokeColor.gradientMode === "radial") {
584 gradient = ctx.createRadialGradient(xCtr, yCtr, Math.min(xScale, yScale), 584 gradient = ctx.createRadialGradient(xCtr, yCtr, 0,
585 xCtr, yCtr, 0.5*Math.max(this._height, this._width)); 585 xCtr, yCtr, 0.5*Math.max(this._height, this._width));
586 } else { 586 } else {
587 gradient = ctx.createLinearGradient(0, this._height/2, this._width, this._height/2); 587 gradient = ctx.createLinearGradient(0, this._height/2, this._width, this._height/2);
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js
index 711245ae..b85433a0 100755
--- a/js/lib/geom/rectangle.js
+++ b/js/lib/geom/rectangle.js
@@ -507,7 +507,7 @@ exports.Rectangle = Object.create(GeomObj, {
507 } 507 }
508 }, 508 },
509 509
510 render: { 510 render: {
511 value: function() { 511 value: function() {
512 // get the world 512 // get the world
513 var world = this.getWorld(); 513 var world = this.getWorld();
@@ -538,7 +538,6 @@ exports.Rectangle = Object.create(GeomObj, {
538 if(this._fillColor.gradientMode) { 538 if(this._fillColor.gradientMode) {
539 if(this._fillColor.gradientMode === "radial") { 539 if(this._fillColor.gradientMode === "radial") {
540 var ww = w - 2*lw, hh = h - 2*lw; 540 var ww = w - 2*lw, hh = h - 2*lw;
541 //gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2-this._strokeWidth, h/2, Math.max(ww, hh)/2);
542 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(ww, hh)/2); 541 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(ww, hh)/2);
543 } else { 542 } else {
544 gradient = ctx.createLinearGradient(inset, h/2, w-inset, h/2); 543 gradient = ctx.createLinearGradient(inset, h/2, w-inset, h/2);
@@ -572,11 +571,10 @@ exports.Rectangle = Object.create(GeomObj, {
572 inset = Math.ceil( 0.5*lw ) - 0.5; 571 inset = Math.ceil( 0.5*lw ) - 0.5;
573 572
574 if(this._strokeColor.gradientMode) { 573 if(this._strokeColor.gradientMode) {
575 if(this._strokeColor.gradientMode === "radial") { 574 if(this._strokeColor.gradientMode === "radial")
576 gradient = ctx.createRadialGradient(w/2, h/2, Math.min(h, w)/2-inset, w/2, h/2, Math.max(h, w)/2); 575 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(h, w)/2);
577 } else { 576 else
578 gradient = ctx.createLinearGradient(0, h/2, w, h/2); 577 gradient = ctx.createLinearGradient(0, h/2, w, h/2);
579 }
580 colors = this._strokeColor.color; 578 colors = this._strokeColor.color;
581 579
582 len = colors.length; 580 len = colors.length;