aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-04-02 14:52:14 -0700
committerNivesh Rajbhandari2012-04-02 14:52:14 -0700
commit5377e963c4413640cd3c04e0406384df04144568 (patch)
tree75a6c9e74ad45648f880107609b644bbb65fcc2a /js/tools
parentc4e83a61311db75c7a1c307553262e77ecaae662 (diff)
downloadninja-5377e963c4413640cd3c04e0406384df04144568.tar.gz
Switching to Linear/RadialGradient materials will set the corresponding color. Also, dispatching an addElement event when toggling shape from WebGL/canvas2d so timeline can draw correctly.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/LineTool.js2
-rwxr-xr-xjs/tools/OvalTool.js4
-rwxr-xr-xjs/tools/RectTool.js4
-rwxr-xr-xjs/tools/ShapeTool.js27
4 files changed, 5 insertions, 32 deletions
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js
index 499a6b9d..9b22c629 100755
--- a/js/tools/LineTool.js
+++ b/js/tools/LineTool.js
@@ -216,7 +216,7 @@ exports.LineTool = Montage.create(ShapeTool, {
216 { 216 {
217 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); 217 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM));
218 } 218 }
219 strokeColor = this._getMaterialColor(strokeM) || strokeColor; 219 strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor;
220 } 220 }
221 221
222 var world = this.getGLWorld(canvas, this.options.use3D); 222 var world = this.getGLWorld(canvas, this.options.use3D);
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js
index c09c9bc7..e8e88d1d 100755
--- a/js/tools/OvalTool.js
+++ b/js/tools/OvalTool.js
@@ -53,14 +53,14 @@ exports.OvalTool = Montage.create(ShapeTool, {
53 { 53 {
54 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); 54 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM));
55 } 55 }
56 strokeColor = this._getMaterialColor(strokeM) || strokeColor; 56 strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor;
57 57
58 var fillM = this.options.fillMaterial; 58 var fillM = this.options.fillMaterial;
59 if(fillM) 59 if(fillM)
60 { 60 {
61 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); 61 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM));
62 } 62 }
63 fillColor = this._getMaterialColor(fillM) || fillColor; 63 fillColor = ShapesController.getMaterialColor(fillM) || fillColor;
64 } 64 }
65 65
66 var world = this.getGLWorld(canvas, this.options.use3D); 66 var world = this.getGLWorld(canvas, this.options.use3D);
diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js
index d69aa933..0c14a559 100755
--- a/js/tools/RectTool.js
+++ b/js/tools/RectTool.js
@@ -72,14 +72,14 @@ exports.RectTool = Montage.create(ShapeTool, {
72 { 72 {
73 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); 73 strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM));
74 } 74 }
75 strokeColor = this._getMaterialColor(strokeM) || strokeColor; 75 strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor;
76 76
77 var fillM = this.options.fillMaterial; 77 var fillM = this.options.fillMaterial;
78 if(fillM) 78 if(fillM)
79 { 79 {
80 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); 80 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM));
81 } 81 }
82 fillColor = this._getMaterialColor(fillM) || fillColor; 82 fillColor = ShapesController.getMaterialColor(fillM) || fillColor;
83 } 83 }
84 84
85 var world = this.getGLWorld(canvas, this.options.use3D); 85 var world = this.getGLWorld(canvas, this.options.use3D);
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index 1a12401f..85009bc2 100755
--- a/js/tools/ShapeTool.js
+++ b/js/tools/ShapeTool.js
@@ -206,33 +206,6 @@ exports.ShapeTool = Montage.create(DrawingTool, {
206 } 206 }
207 }, 207 },
208 208
209 _getMaterialColor: {
210 value: function(m)
211 {
212 var css,
213 colorObj;
214 if(m === "LinearGradientMaterial")
215 {
216 css = "-webkit-gradient(linear, left top, right top, from(rgb(255, 0, 0)), color-stop(0.3, rgb(0, 255, 0)), color-stop(0.6, rgb(0, 0, 255)), to(rgb(0, 255, 255)))";
217 }
218 else if(m === "RadialGradientMaterial")
219 {
220 css = "-webkit-radial-gradient(50% 50%, ellipse cover, rgb(255, 0, 0) 0%, rgb(0, 255, 0) 30%, rgb(0, 0, 255) 60%, rgb(0, 255, 255) 100%)";
221 }
222
223 if(css)
224 {
225 colorObj = this.application.ninja.colorController.getColorObjFromCss(css);
226 if(colorObj)
227 {
228 return {gradientMode:colorObj.color.gradientMode, color:colorObj.color.stops};
229 }
230 }
231
232 return null;
233 }
234 },
235
236 // We can draw on an existing canvas unless it has only a single shape object 209 // We can draw on an existing canvas unless it has only a single shape object
237 _useExistingCanvas: { 210 _useExistingCanvas: {
238 value: function() 211 value: function()