aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
Diffstat (limited to 'js/tools')
-rwxr-xr-xjs/tools/LineTool.js8
-rwxr-xr-xjs/tools/OvalTool.js15
-rwxr-xr-xjs/tools/RectTool.js15
-rwxr-xr-xjs/tools/ShapeTool.js25
-rwxr-xr-xjs/tools/Translate3DToolBase.js4
5 files changed, 30 insertions, 37 deletions
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js
index a61f8f79..499a6b9d 100755
--- a/js/tools/LineTool.js
+++ b/js/tools/LineTool.js
@@ -216,6 +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 } 220 }
220 221
221 var world = this.getGLWorld(canvas, this.options.use3D); 222 var world = this.getGLWorld(canvas, this.options.use3D);
@@ -234,13 +235,6 @@ exports.LineTool = Montage.create(ShapeTool, {
234 canvas.elementModel.selection = "Line"; 235 canvas.elementModel.selection = "Line";
235 canvas.elementModel.pi = "LinePi"; 236 canvas.elementModel.pi = "LinePi";
236 canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; 237 canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units;
237 canvas.elementModel.shapeModel.stroke = strokeColor;
238 if(strokeColor)
239 {
240 canvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke;
241 }
242
243 canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial;
244 238
245 canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex; 239 canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex;
246 canvas.elementModel.shapeModel.strokeStyle = strokeStyle; 240 canvas.elementModel.shapeModel.strokeStyle = strokeStyle;
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js
index a10e0bb5..c09c9bc7 100755
--- a/js/tools/OvalTool.js
+++ b/js/tools/OvalTool.js
@@ -53,12 +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 57
57 var fillM = this.options.fillMaterial; 58 var fillM = this.options.fillMaterial;
58 if(fillM) 59 if(fillM)
59 { 60 {
60 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); 61 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM));
61 } 62 }
63 fillColor = this._getMaterialColor(fillM) || fillColor;
62 } 64 }
63 65
64 var world = this.getGLWorld(canvas, this.options.use3D); 66 var world = this.getGLWorld(canvas, this.options.use3D);
@@ -78,22 +80,9 @@ exports.OvalTool = Montage.create(ShapeTool, {
78 canvas.elementModel.selection = "Oval"; 80 canvas.elementModel.selection = "Oval";
79 canvas.elementModel.pi = "OvalPi"; 81 canvas.elementModel.pi = "OvalPi";
80 canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; 82 canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units;
81 canvas.elementModel.shapeModel.stroke = strokeColor;
82 canvas.elementModel.shapeModel.fill = fillColor;
83 if(strokeColor)
84 {
85 canvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke;
86 }
87 if(fillColor)
88 {
89 canvas.elementModel.shapeModel.background = this.application.ninja.colorController.colorToolbar.fill;
90 }
91 83
92 canvas.elementModel.shapeModel.innerRadius = this.options.innerRadius.value + " " + this.options.innerRadius.units; 84 canvas.elementModel.shapeModel.innerRadius = this.options.innerRadius.value + " " + this.options.innerRadius.units;
93 85
94 canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial;
95 canvas.elementModel.shapeModel.fillMaterial = fillMaterial;
96
97 canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex; 86 canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex;
98 canvas.elementModel.shapeModel.strokeStyle = strokeStyle; 87 canvas.elementModel.shapeModel.strokeStyle = strokeStyle;
99 88
diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js
index 957afea9..d69aa933 100755
--- a/js/tools/RectTool.js
+++ b/js/tools/RectTool.js
@@ -72,12 +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 76
76 var fillM = this.options.fillMaterial; 77 var fillM = this.options.fillMaterial;
77 if(fillM) 78 if(fillM)
78 { 79 {
79 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); 80 fillMaterial = Object.create(MaterialsModel.getMaterial(fillM));
80 } 81 }
82 fillColor = this._getMaterialColor(fillM) || fillColor;
81 } 83 }
82 84
83 var world = this.getGLWorld(canvas, this.options.use3D); 85 var world = this.getGLWorld(canvas, this.options.use3D);
@@ -98,25 +100,12 @@ exports.RectTool = Montage.create(ShapeTool, {
98 canvas.elementModel.selection = "Rectangle"; 100 canvas.elementModel.selection = "Rectangle";
99 canvas.elementModel.pi = "RectanglePi"; 101 canvas.elementModel.pi = "RectanglePi";
100 canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units; 102 canvas.elementModel.shapeModel.strokeSize = this.options.strokeSize.value + " " + this.options.strokeSize.units;
101 canvas.elementModel.shapeModel.stroke = strokeColor;
102 canvas.elementModel.shapeModel.fill = fillColor;
103 if(strokeColor)
104 {
105 canvas.elementModel.shapeModel.border = this.application.ninja.colorController.colorToolbar.stroke;
106 }
107 if(fillColor)
108 {
109 canvas.elementModel.shapeModel.background = this.application.ninja.colorController.colorToolbar.fill;
110 }
111 103
112 canvas.elementModel.shapeModel.tlRadius = this.options.TLRadiusControl.value + " " + this.options.TLRadiusControl.units; 104 canvas.elementModel.shapeModel.tlRadius = this.options.TLRadiusControl.value + " " + this.options.TLRadiusControl.units;
113 canvas.elementModel.shapeModel.trRadius = this.options.TRRadiusControl.value + " " + this.options.TRRadiusControl.units; 105 canvas.elementModel.shapeModel.trRadius = this.options.TRRadiusControl.value + " " + this.options.TRRadiusControl.units;
114 canvas.elementModel.shapeModel.blRadius = this.options.BLRadiusControl.value + " " + this.options.BLRadiusControl.units; 106 canvas.elementModel.shapeModel.blRadius = this.options.BLRadiusControl.value + " " + this.options.BLRadiusControl.units;
115 canvas.elementModel.shapeModel.brRadius = this.options.BRRadiusControl.value + " " + this.options.BRRadiusControl.units; 107 canvas.elementModel.shapeModel.brRadius = this.options.BRRadiusControl.value + " " + this.options.BRRadiusControl.units;
116 108
117 canvas.elementModel.shapeModel.strokeMaterial = strokeMaterial;
118 canvas.elementModel.shapeModel.fillMaterial = fillMaterial;
119
120 canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex; 109 canvas.elementModel.shapeModel.strokeStyleIndex = strokeStyleIndex;
121 canvas.elementModel.shapeModel.strokeStyle = strokeStyle; 110 canvas.elementModel.shapeModel.strokeStyle = strokeStyle;
122 111
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index d3a36163..1a12401f 100755
--- a/js/tools/ShapeTool.js
+++ b/js/tools/ShapeTool.js
@@ -206,7 +206,32 @@ 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 }
209 231
232 return null;
233 }
234 },
210 235
211 // We can draw on an existing canvas unless it has only a single shape object 236 // We can draw on an existing canvas unless it has only a single shape object
212 _useExistingCanvas: { 237 _useExistingCanvas: {
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js
index 07b6d04d..005b9749 100755
--- a/js/tools/Translate3DToolBase.js
+++ b/js/tools/Translate3DToolBase.js
@@ -66,10 +66,6 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
66 delta[0] = 0; 66 delta[0] = 0;
67 delta[1] = 0; 67 delta[1] = 0;
68 } 68 }
69 else
70 {
71 delta[2] = 0;
72 }
73 this._delta = delta.slice(0); 69 this._delta = delta.slice(0);
74 } 70 }
75 71