aboutsummaryrefslogtreecommitdiff
path: root/assets/canvas-runtime.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/canvas-runtime.js')
-rw-r--r--assets/canvas-runtime.js32
1 files changed, 19 insertions, 13 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js
index 9bf22313..af860b95 100644
--- a/assets/canvas-runtime.js
+++ b/assets/canvas-runtime.js
@@ -906,11 +906,12 @@ NinjaCvsRt.RuntimeRectangle = Object.create(NinjaCvsRt.RuntimeGeomObj, {
906 inset = Math.ceil( lw ) - 0.5; 906 inset = Math.ceil( lw ) - 0.5;
907 907
908 if(this._fillColor.gradientMode) { 908 if(this._fillColor.gradientMode) {
909 if(this._fillColor.gradientMode === "radial") { 909 if(this._fillColor.gradientMode === "radial") {
910 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(w, h)/2); 910 var ww = w - 2*lw, hh = h - 2*lw;
911 } else { 911 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(ww, hh)/2);
912 gradient = ctx.createLinearGradient(inset/2, h/2, w-inset, h/2); 912 } else {
913 } 913 gradient = ctx.createLinearGradient(inset, h/2, w-inset, h/2);
914 }
914 colors = this._fillColor.color; 915 colors = this._fillColor.color;
915 916
916 len = colors.length; 917 len = colors.length;
@@ -940,11 +941,10 @@ NinjaCvsRt.RuntimeRectangle = Object.create(NinjaCvsRt.RuntimeGeomObj, {
940 inset = Math.ceil( 0.5*lw ) - 0.5; 941 inset = Math.ceil( 0.5*lw ) - 0.5;
941 942
942 if(this._strokeColor.gradientMode) { 943 if(this._strokeColor.gradientMode) {
943 if(this._strokeColor.gradientMode === "radial") { 944 if(this._strokeColor.gradientMode === "radial")
944 gradient = ctx.createRadialGradient(w/2, h/2, Math.min(h, w)/2-inset, w/2, h/2, Math.max(h, w)/2); 945 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(h, w)/2);
945 } else { 946 else
946 gradient = ctx.createLinearGradient(0, h/2, w, h/2); 947 gradient = ctx.createLinearGradient(0, h/2, w, h/2);
947 }
948 colors = this._strokeColor.color; 948 colors = this._strokeColor.color;
949 949
950 len = colors.length; 950 len = colors.length;
@@ -1144,9 +1144,9 @@ NinjaCvsRt.RuntimeOval = Object.create(NinjaCvsRt.RuntimeGeomObj, {
1144 if(this._fillColor.gradientMode) { 1144 if(this._fillColor.gradientMode) {
1145 if(this._fillColor.gradientMode === "radial") { 1145 if(this._fillColor.gradientMode === "radial") {
1146 gradient = ctx.createRadialGradient(xCtr, yCtr, 0, 1146 gradient = ctx.createRadialGradient(xCtr, yCtr, 0,
1147 xCtr, yCtr, Math.max(this._width, this._height)/2); 1147 xCtr, yCtr, Math.max(this._width, this._height)/2 - lineWidth);
1148 } else { 1148 } else {
1149 gradient = ctx.createLinearGradient(lineWidth/2, this._height/2, this._width-lineWidth, this._height/2); 1149 gradient = ctx.createLinearGradient(lineWidth, this._height/2, this._width-lineWidth, this._height/2);
1150 } 1150 }
1151 colors = this._fillColor.color; 1151 colors = this._fillColor.color;
1152 1152
@@ -1222,7 +1222,7 @@ NinjaCvsRt.RuntimeOval = Object.create(NinjaCvsRt.RuntimeGeomObj, {
1222 if (this._strokeColor) { 1222 if (this._strokeColor) {
1223 if(this._strokeColor.gradientMode) { 1223 if(this._strokeColor.gradientMode) {
1224 if(this._strokeColor.gradientMode === "radial") { 1224 if(this._strokeColor.gradientMode === "radial") {
1225 gradient = ctx.createRadialGradient(xCtr, yCtr, Math.min(xScale, yScale), 1225 gradient = ctx.createRadialGradient(xCtr, yCtr, 0,
1226 xCtr, yCtr, 0.5*Math.max(this._height, this._width)); 1226 xCtr, yCtr, 0.5*Math.max(this._height, this._width));
1227 } else { 1227 } else {
1228 gradient = ctx.createLinearGradient(0, this._height/2, this._width, this._height/2); 1228 gradient = ctx.createLinearGradient(0, this._height/2, this._width, this._height/2);
@@ -1484,6 +1484,8 @@ NinjaCvsRt.RuntimeRadialGradientMaterial = Object.create(NinjaCvsRt.RuntimeMater
1484 _colorStop3: { value: 0.6, writable: true }, 1484 _colorStop3: { value: 0.6, writable: true },
1485 _colorStop4: { value: 1.0, writable: true }, 1485 _colorStop4: { value: 1.0, writable: true },
1486 1486
1487 _textureTransform: { value: [1,0,0, 0,1,0, 0,0,1], writable: true },
1488
1487 init: { 1489 init: {
1488 value: function(world) { 1490 value: function(world) {
1489 var material = this._materialNode; 1491 var material = this._materialNode;
@@ -1505,6 +1507,8 @@ NinjaCvsRt.RuntimeRadialGradientMaterial = Object.create(NinjaCvsRt.RuntimeMater
1505 this._shader["default"].u_colorStop3.set( [this._colorStop3] ); 1507 this._shader["default"].u_colorStop3.set( [this._colorStop3] );
1506 this._shader["default"].u_colorStop4.set( [this._colorStop4] ); 1508 this._shader["default"].u_colorStop4.set( [this._colorStop4] );
1507 1509
1510 this._shader["default"].u_texTransform.set( this._textureTransform );
1511
1508 if (this._angle !== undefined) 1512 if (this._angle !== undefined)
1509 this._shader["default"].u_cos_sin_angle.set([Math.cos(this._angle), Math.sin(this._angle)]); 1513 this._shader["default"].u_cos_sin_angle.set([Math.cos(this._angle), Math.sin(this._angle)]);
1510 } 1514 }
@@ -1524,6 +1528,8 @@ NinjaCvsRt.RuntimeRadialGradientMaterial = Object.create(NinjaCvsRt.RuntimeMater
1524 this._colorStop3 = jObj.colorStop3; 1528 this._colorStop3 = jObj.colorStop3;
1525 this._colorStop4 = jObj.colorStop4; 1529 this._colorStop4 = jObj.colorStop4;
1526 1530
1531 this._textureTransform = jObj.textureTransform;
1532
1527 if (this._angle !== undefined) 1533 if (this._angle !== undefined)
1528 this._angle = jObj.angle; 1534 this._angle = jObj.angle;
1529 } 1535 }