diff options
author | Jose Antonio Marquez | 2012-05-22 18:02:36 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-05-22 18:02:36 -0700 |
commit | 27e6e1238ec1adb34aa396074e2559801c7e4314 (patch) | |
tree | d27f27fd071d9df575c6014eed0efee252ff0390 /assets | |
parent | 75fe4f36a6768d688792bc1925cfa4bfa508ac3e (diff) | |
parent | a341522e3603c18ab3b93defa894e3be702dd0f4 (diff) | |
download | ninja-27e6e1238ec1adb34aa396074e2559801c7e4314.tar.gz |
Merge branch 'refs/heads/Ninja-DOM-Architecture' into Document
Diffstat (limited to 'assets')
-rw-r--r-- | assets/canvas-runtime.js | 32 | ||||
-rwxr-xr-x | assets/shaders/linearGradient.vert.glsl | 5 | ||||
-rw-r--r-- | assets/shaders/radialGradient.vert.glsl | 4 |
3 files changed, 26 insertions, 15 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 | } |
diff --git a/assets/shaders/linearGradient.vert.glsl b/assets/shaders/linearGradient.vert.glsl index aac9cbee..f0800812 100755 --- a/assets/shaders/linearGradient.vert.glsl +++ b/assets/shaders/linearGradient.vert.glsl | |||
@@ -37,6 +37,7 @@ uniform float u_colorStop3; | |||
37 | uniform float u_colorStop4; | 37 | uniform float u_colorStop4; |
38 | uniform vec2 u_cos_sin_angle; | 38 | uniform vec2 u_cos_sin_angle; |
39 | //uniform int u_colorCount; // currently using 4 | 39 | //uniform int u_colorCount; // currently using 4 |
40 | uniform mat3 u_texTransform; | ||
40 | 41 | ||
41 | varying vec2 v_uv; | 42 | varying vec2 v_uv; |
42 | 43 | ||
@@ -44,5 +45,7 @@ varying vec2 v_uv; | |||
44 | void main(void) | 45 | void main(void) |
45 | { | 46 | { |
46 | gl_Position = u_projMatrix * u_mvMatrix * vec4(vert,1.0) ; | 47 | gl_Position = u_projMatrix * u_mvMatrix * vec4(vert,1.0) ; |
47 | v_uv = texcoord; | 48 | //v_uv = texcoord; |
49 | vec3 tmp = u_texTransform * vec3( texcoord, 1.0); | ||
50 | v_uv = tmp.xy; | ||
48 | } | 51 | } |
diff --git a/assets/shaders/radialGradient.vert.glsl b/assets/shaders/radialGradient.vert.glsl index c3e1b50a..7994ac12 100644 --- a/assets/shaders/radialGradient.vert.glsl +++ b/assets/shaders/radialGradient.vert.glsl | |||
@@ -18,11 +18,13 @@ attribute vec2 texcoord; | |||
18 | // matrix uniforms | 18 | // matrix uniforms |
19 | uniform mat4 u_mvMatrix; | 19 | uniform mat4 u_mvMatrix; |
20 | uniform mat4 u_projMatrix; | 20 | uniform mat4 u_projMatrix; |
21 | uniform mat3 u_texTransform; | ||
21 | 22 | ||
22 | varying vec2 v_uv; | 23 | varying vec2 v_uv; |
23 | 24 | ||
24 | void main(void) | 25 | void main(void) |
25 | { | 26 | { |
26 | gl_Position = u_projMatrix * u_mvMatrix * vec4(vert,1.0) ; | 27 | gl_Position = u_projMatrix * u_mvMatrix * vec4(vert,1.0) ; |
27 | v_uv = texcoord; | 28 | vec3 tmp = u_texTransform * vec3( texcoord, 1.0); |
29 | v_uv = tmp.xy; | ||
28 | } \ No newline at end of file | 30 | } \ No newline at end of file |