diff options
author | Eric Guzman | 2012-05-22 15:57:23 -0700 |
---|---|---|
committer | Eric Guzman | 2012-05-22 15:57:23 -0700 |
commit | ad3b4595d7377e5bf75bcb8ad81007859b0a8a02 (patch) | |
tree | ecb7fe289824a625b1dc422a97c2236826081ec3 | |
parent | 0eb95ff2dbba1fe7213eed2e0140b4d07bda3dd5 (diff) | |
parent | 2b207ef8b2594927f8cd6cd63a8483d205cb86c4 (diff) | |
download | ninja-ad3b4595d7377e5bf75bcb8ad81007859b0a8a02.tar.gz |
Merge branch 'dom-architecture' of github.com:Motorola-Mobility/ninja-internal into CSSPanelUpdates
Conflicts:
js/controllers/styles-controller.js
27 files changed, 963 insertions, 600 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index eeafaab6..af860b95 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js | |||
@@ -8,9 +8,37 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
8 | var NinjaCvsRt = NinjaCvsRt || {}; | 8 | var NinjaCvsRt = NinjaCvsRt || {}; |
9 | 9 | ||
10 | /////////////////////////////////////////////////////////////////////// | 10 | /////////////////////////////////////////////////////////////////////// |
11 | //Loading webGL/canvas data on window load | ||
12 | window.addEventListener('load', loadCanvasData, false); | ||
13 | //Load data function (on document loaded) | ||
14 | function loadCanvasData (e) { | ||
15 | //Cleaning up events | ||
16 | window.removeEventListener('load', loadCanvasData, false); | ||
17 | //Getting tag with data, MUST contain attribute | ||
18 | var xhr, tag = document.querySelectorAll(['script[data-ninja-canvas-lib]'])[0]; | ||
19 | //Checking for data to be external file | ||
20 | if (tag.getAttribute('data-ninja-canvas-json') !== null) { | ||
21 | //Loading JSON data | ||
22 | xhr = new XMLHttpRequest(); | ||
23 | xhr.open("GET", tag.getAttribute('data-ninja-canvas-json'), false); | ||
24 | xhr.send(); | ||
25 | //Checking for data | ||
26 | if (xhr.readyState === 4) { | ||
27 | //Calling method to initialize all webGL/canvas(es) | ||
28 | NinjaCvsRt.initWebGl(document.body, tag.getAttribute('data-ninja-canvas-libpath'), xhr.response); | ||
29 | } else { | ||
30 | //TODO: Add error for users | ||
31 | } | ||
32 | } else {//Data in document itself | ||
33 | //Calling method to initialize all webGL/canvas(es) | ||
34 | NinjaCvsRt.initWebGl(document.body, tag.getAttribute('data-ninja-canvas-libpath'), document.querySelectorAll(['script[data-ninja-canvas]'])[0].innerHTML); | ||
35 | } | ||
36 | } | ||
37 | |||
38 | /////////////////////////////////////////////////////////////////////// | ||
11 | //Loading webGL/canvas data | 39 | //Loading webGL/canvas data |
12 | NinjaCvsRt.initWebGl = function (rootElement, directory) { | 40 | NinjaCvsRt.initWebGl = function (rootElement, directory, data) { |
13 | var cvsDataMngr, ninjaWebGlData = JSON.parse((document.querySelectorAll(['script[data-ninja-webgl]'])[0].innerHTML.replace('(', '')).replace(')', '')); | 41 | var cvsDataMngr, ninjaWebGlData = JSON.parse((data.replace('(', '')).replace(')', '')); |
14 | if (ninjaWebGlData && ninjaWebGlData.data) { | 42 | if (ninjaWebGlData && ninjaWebGlData.data) { |
15 | for (var n=0; ninjaWebGlData.data[n]; n++) { | 43 | for (var n=0; ninjaWebGlData.data[n]; n++) { |
16 | ninjaWebGlData.data[n] = unescape(ninjaWebGlData.data[n]); | 44 | ninjaWebGlData.data[n] = unescape(ninjaWebGlData.data[n]); |
@@ -878,11 +906,12 @@ NinjaCvsRt.RuntimeRectangle = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
878 | inset = Math.ceil( lw ) - 0.5; | 906 | inset = Math.ceil( lw ) - 0.5; |
879 | 907 | ||
880 | if(this._fillColor.gradientMode) { | 908 | if(this._fillColor.gradientMode) { |
881 | if(this._fillColor.gradientMode === "radial") { | 909 | if(this._fillColor.gradientMode === "radial") { |
882 | 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; |
883 | } else { | 911 | 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); | 912 | } else { |
885 | } | 913 | gradient = ctx.createLinearGradient(inset, h/2, w-inset, h/2); |
914 | } | ||
886 | colors = this._fillColor.color; | 915 | colors = this._fillColor.color; |
887 | 916 | ||
888 | len = colors.length; | 917 | len = colors.length; |
@@ -912,11 +941,10 @@ NinjaCvsRt.RuntimeRectangle = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
912 | inset = Math.ceil( 0.5*lw ) - 0.5; | 941 | inset = Math.ceil( 0.5*lw ) - 0.5; |
913 | 942 | ||
914 | if(this._strokeColor.gradientMode) { | 943 | if(this._strokeColor.gradientMode) { |
915 | if(this._strokeColor.gradientMode === "radial") { | 944 | 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); | 945 | gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(h, w)/2); |
917 | } else { | 946 | else |
918 | gradient = ctx.createLinearGradient(0, h/2, w, h/2); | 947 | gradient = ctx.createLinearGradient(0, h/2, w, h/2); |
919 | } | ||
920 | colors = this._strokeColor.color; | 948 | colors = this._strokeColor.color; |
921 | 949 | ||
922 | len = colors.length; | 950 | len = colors.length; |
@@ -1116,9 +1144,9 @@ NinjaCvsRt.RuntimeOval = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
1116 | if(this._fillColor.gradientMode) { | 1144 | if(this._fillColor.gradientMode) { |
1117 | if(this._fillColor.gradientMode === "radial") { | 1145 | if(this._fillColor.gradientMode === "radial") { |
1118 | gradient = ctx.createRadialGradient(xCtr, yCtr, 0, | 1146 | gradient = ctx.createRadialGradient(xCtr, yCtr, 0, |
1119 | xCtr, yCtr, Math.max(this._width, this._height)/2); | 1147 | xCtr, yCtr, Math.max(this._width, this._height)/2 - lineWidth); |
1120 | } else { | 1148 | } else { |
1121 | 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); |
1122 | } | 1150 | } |
1123 | colors = this._fillColor.color; | 1151 | colors = this._fillColor.color; |
1124 | 1152 | ||
@@ -1194,7 +1222,7 @@ NinjaCvsRt.RuntimeOval = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
1194 | if (this._strokeColor) { | 1222 | if (this._strokeColor) { |
1195 | if(this._strokeColor.gradientMode) { | 1223 | if(this._strokeColor.gradientMode) { |
1196 | if(this._strokeColor.gradientMode === "radial") { | 1224 | if(this._strokeColor.gradientMode === "radial") { |
1197 | gradient = ctx.createRadialGradient(xCtr, yCtr, Math.min(xScale, yScale), | 1225 | gradient = ctx.createRadialGradient(xCtr, yCtr, 0, |
1198 | xCtr, yCtr, 0.5*Math.max(this._height, this._width)); | 1226 | xCtr, yCtr, 0.5*Math.max(this._height, this._width)); |
1199 | } else { | 1227 | } else { |
1200 | 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); |
@@ -1456,6 +1484,8 @@ NinjaCvsRt.RuntimeRadialGradientMaterial = Object.create(NinjaCvsRt.RuntimeMater | |||
1456 | _colorStop3: { value: 0.6, writable: true }, | 1484 | _colorStop3: { value: 0.6, writable: true }, |
1457 | _colorStop4: { value: 1.0, writable: true }, | 1485 | _colorStop4: { value: 1.0, writable: true }, |
1458 | 1486 | ||
1487 | _textureTransform: { value: [1,0,0, 0,1,0, 0,0,1], writable: true }, | ||
1488 | |||
1459 | init: { | 1489 | init: { |
1460 | value: function(world) { | 1490 | value: function(world) { |
1461 | var material = this._materialNode; | 1491 | var material = this._materialNode; |
@@ -1477,6 +1507,8 @@ NinjaCvsRt.RuntimeRadialGradientMaterial = Object.create(NinjaCvsRt.RuntimeMater | |||
1477 | this._shader["default"].u_colorStop3.set( [this._colorStop3] ); | 1507 | this._shader["default"].u_colorStop3.set( [this._colorStop3] ); |
1478 | this._shader["default"].u_colorStop4.set( [this._colorStop4] ); | 1508 | this._shader["default"].u_colorStop4.set( [this._colorStop4] ); |
1479 | 1509 | ||
1510 | this._shader["default"].u_texTransform.set( this._textureTransform ); | ||
1511 | |||
1480 | if (this._angle !== undefined) | 1512 | if (this._angle !== undefined) |
1481 | 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)]); |
1482 | } | 1514 | } |
@@ -1496,6 +1528,8 @@ NinjaCvsRt.RuntimeRadialGradientMaterial = Object.create(NinjaCvsRt.RuntimeMater | |||
1496 | this._colorStop3 = jObj.colorStop3; | 1528 | this._colorStop3 = jObj.colorStop3; |
1497 | this._colorStop4 = jObj.colorStop4; | 1529 | this._colorStop4 = jObj.colorStop4; |
1498 | 1530 | ||
1531 | this._textureTransform = jObj.textureTransform; | ||
1532 | |||
1499 | if (this._angle !== undefined) | 1533 | if (this._angle !== undefined) |
1500 | this._angle = jObj.angle; | 1534 | this._angle = jObj.angle; |
1501 | } | 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_mvMat |