diff options
author | Nivesh Rajbhandari | 2012-07-09 11:43:36 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-07-09 11:43:36 -0700 |
commit | ac27d538af33ca8d67d3d88729f49c05793afda7 (patch) | |
tree | 4be9251ff087e93a37b1f463ae9eaaaf779caeeb /js/lib/rdge/materials/radial-gradient-material.js | |
parent | eff1851b2189bea8b89065980d02541cecea5ddf (diff) | |
download | ninja-ac27d538af33ca8d67d3d88729f49c05793afda7.tar.gz |
PI, drawing and editing fixes for shapes and materials.
IKNinja-1841 - Cannot change webgl shape with LinearGradient and RadialGradient to solid color.
IKNINJA-1851 - Cannot draw webgl shapes with Linear/RadialGradient material.
IKNINJA-1864 - PI doesn't update the color of shape if WebGL material switches to Flat.
IKNINJA-1886 - Gradient edits not applied to WebGL Stage object.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/lib/rdge/materials/radial-gradient-material.js')
-rwxr-xr-x | js/lib/rdge/materials/radial-gradient-material.js | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/js/lib/rdge/materials/radial-gradient-material.js b/js/lib/rdge/materials/radial-gradient-material.js index c9c2536f..c68cad43 100755 --- a/js/lib/rdge/materials/radial-gradient-material.js +++ b/js/lib/rdge/materials/radial-gradient-material.js | |||
@@ -113,7 +113,48 @@ var RadialGradientMaterial = function RadialGradientMaterial() { | |||
113 | { | 113 | { |
114 | jObj.u_texTransform = this._textureTransform.slice(); | 114 | jObj.u_texTransform = this._textureTransform.slice(); |
115 | return jObj; | 115 | return jObj; |
116 | } | 116 | }; |
117 | |||
118 | // Only Linear Gradient and Radial Gradient have gradient data. | ||
119 | this.gradientType = "radial"; | ||
120 | |||
121 | this.getGradientData = function() { | ||
122 | var angle = Math.round(this._angle*180/Math.PI), | ||
123 | color, | ||
124 | colorStr, | ||
125 | css = "-webkit-gradient(linear, " + angle + "deg"; | ||
126 | |||
127 | // TODO - Angle is not supported in -webkit-gradient syntax, so just default to across: | ||
128 | css = '-webkit-radial-gradient(50% 50%, ellipse cover'; | ||
129 | |||
130 | // TODO - Also, Color Model requires from and to in the gradient string | ||
131 | for (var i=1; i < 5; i++) { | ||
132 | color = this.getProperty('u_color'+i); | ||
133 | colorStr = Math.round(color[0] * 255) + ', ' + Math.round(color[1] * 255) + ', ' + Math.round(color[2] * 255) + ', ' + Math.round(color[3] * 100); | ||
134 | css += ', rgba(' + colorStr + ') ' + Math.round(this.getProperty('u_colorStop'+i)*100) + '%'; | ||
135 | } | ||
136 | |||
137 | css += ')'; | ||
138 | |||
139 | return css; | ||
140 | }; | ||
141 | |||
142 | this.setGradientData = function(colors) { | ||
143 | var len = colors.length; | ||
144 | // TODO - Current shaders only support 4 color stops | ||
145 | if (len > 4) { | ||
146 | len = 4; | ||
147 | } | ||
148 | |||
149 | for (var n = 0; n < len; n++) { | ||
150 | var position = colors[n].position/100; | ||
151 | var cs = colors[n].value; | ||
152 | var stop = [cs.r/255, cs.g/255, cs.b/255, cs.a]; | ||
153 | |||
154 | this.setProperty("u_color" + (n + 1), stop.slice(0)); | ||
155 | this.setProperty("u_colorStop" + (n + 1), position); | ||
156 | } | ||
157 | }; | ||
117 | }; | 158 | }; |
118 | 159 | ||
119 | /////////////////////////////////////////////////////////////////////////////////////// | 160 | /////////////////////////////////////////////////////////////////////////////////////// |