diff options
Diffstat (limited to 'js/tools')
-rw-r--r-- | js/tools/BrushTool.js | 15 | ||||
-rwxr-xr-x | js/tools/LineTool.js | 3 | ||||
-rwxr-xr-x | js/tools/OvalTool.js | 3 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 32 | ||||
-rwxr-xr-x | js/tools/RectTool.js | 3 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 26 |
6 files changed, 62 insertions, 20 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index 5d983a93..85a9e963 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js | |||
@@ -131,14 +131,17 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
131 | //start a new brush stroke | 131 | //start a new brush stroke |
132 | if (this._selectedBrushStroke === null){ | 132 | if (this._selectedBrushStroke === null){ |
133 | this._selectedBrushStroke = new BrushStroke(); | 133 | this._selectedBrushStroke = new BrushStroke(); |
134 | var colorArray=[0,0,0,0]; | 134 | var colorObj; |
135 | var color = this.options.fill.color; | 135 | var fill = this.options.fill; |
136 | if (color){ | 136 | var color = fill.color; |
137 | colorArray = [color.r/255, color.g/255, color.b/255, color.a]; | 137 | if(fill.colorMode === "gradient") { |
138 | colorObj = {gradientMode:fill.color.gradientMode, color:fill.color.stops}; | ||
139 | } else if (color) { | ||
140 | colorObj = [color.r/255, color.g/255, color.b/255, color.a]; | ||
138 | } else { | 141 | } else { |
139 | colorArray = [1,1,1,0]; | 142 | colorObj = [1,1,1,0]; |
140 | } | 143 | } |
141 | this._selectedBrushStroke.setFillColor(colorArray); | 144 | this._selectedBrushStroke.setFillColor(colorObj); |
142 | 145 | ||
143 | //add this point to the brush stroke in case the user does a mouse up before doing a mouse move | 146 | //add this point to the brush stroke in case the user does a mouse up before doing a mouse move |
144 | var currMousePos = hitRec.calculateStageWorldPoint(); | 147 | var currMousePos = hitRec.calculateStageWorldPoint(); |
diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 07429bc0..fde09959 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js | |||
@@ -270,6 +270,9 @@ exports.LineTool = Montage.create(ShapeTool, { | |||
270 | // TODO - update the shape's info only. shapeModel will likely need an array of shapes. | 270 | // TODO - update the shape's info only. shapeModel will likely need an array of shapes. |
271 | } | 271 | } |
272 | 272 | ||
273 | // TODO - This needs to be moved into geom obj's init routine instead of here | ||
274 | this.setColor(this.options.stroke, null, canvas, "lineTool"); | ||
275 | |||
273 | if(canvas.elementModel.isShape) | 276 | if(canvas.elementModel.isShape) |
274 | { | 277 | { |
275 | this.application.ninja.selectionController.selectElement(canvas); | 278 | this.application.ninja.selectionController.selectElement(canvas); |
diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js index ce812398..33bf763d 100755 --- a/js/tools/OvalTool.js +++ b/js/tools/OvalTool.js | |||
@@ -94,6 +94,9 @@ exports.OvalTool = Montage.create(ShapeTool, { | |||
94 | // TODO - update the shape's info only. shapeModel will likely need an array of shapes. | 94 | // TODO - update the shape's info only. shapeModel will likely need an array of shapes. |
95 | } | 95 | } |
96 | 96 | ||
97 | // TODO - This needs to be moved into geom obj's init routine instead of here | ||
98 | this.setColor(this.options.stroke, this.options.fill, canvas, "ovalTool"); | ||
99 | |||
97 | if(canvas.elementModel.isShape) | 100 | if(canvas.elementModel.isShape) |
98 | { | 101 | { |
99 | this.application.ninja.selectionController.selectElement(canvas); | 102 | this.application.ninja.selectionController.selectElement(canvas); |
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 2cffb44d..1097f28c 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js | |||
@@ -338,22 +338,28 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
338 | } | 338 | } |
339 | this._selectedSubpath.setStrokeWidth(strokeSize); | 339 | this._selectedSubpath.setStrokeWidth(strokeSize); |
340 | 340 | ||
341 | var colorArray=[]; | 341 | var colorObj; |
342 | var color = this.options.stroke.color; | 342 | var stroke = this.options.stroke; |
343 | if (color){ | 343 | var color = stroke.color; |
344 | colorArray = [color.r/255, color.g/255, color.b/255, color.a]; | 344 | if(stroke.colorMode === "gradient") { |
345 | }else { | 345 | colorObj = {gradientMode:stroke.color.gradientMode, color:stroke.color.stops}; |
346 | colorArray = [1,1,1,0]; | 346 | } else if (color) { |
347 | colorObj = [color.r/255, color.g/255, color.b/255, color.a]; | ||
348 | } else { | ||
349 | colorObj = [1,1,1,0]; | ||
347 | } | 350 | } |
348 | this._selectedSubpath.setStrokeColor(colorArray); | 351 | this._selectedSubpath.setStrokeColor(colorObj); |
349 | 352 | ||
350 | color = this.options.fill.color; | 353 | var fill = this.options.fill; |
351 | if (color){ | 354 | color = fill.color; |
352 | colorArray = [color.r/255, color.g/255, color.b/255, color.a]; | 355 | if(fill.colorMode === "gradient") { |
356 | colorObj = {gradientMode:fill.color.gradientMode, color:fill.color.stops}; | ||
357 | } else if (color) { | ||
358 | colorObj = [color.r/255, color.g/255, color.b/255, color.a]; | ||
353 | } else { | 359 | } else { |
354 | colorArray = [1,1,1,0]; | 360 | colorObj = [1,1,1,0]; |
355 | } | 361 | } |
356 | this._selectedSubpath.setFillColor(colorArray); | 362 | this._selectedSubpath.setFillColor(colorObj); |
357 | } //if the selectedSubpath was null and needed to be constructed | 363 | } //if the selectedSubpath was null and needed to be constructed |
358 | 364 | ||
359 | //build the current mouse position in stage world space in case we don't already have a canvas | 365 | //build the current mouse position in stage world space in case we don't already have a canvas |
diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js index b35a101a..df049395 100755 --- a/js/tools/RectTool.js +++ b/js/tools/RectTool.js | |||
@@ -117,6 +117,9 @@ exports.RectTool = Montage.create(ShapeTool, { | |||
117 | // TODO - update the shape's info only. shapeModel will likely need an array of shapes. | 117 | // TODO - update the shape's info only. shapeModel will likely need an array of shapes. |
118 | } | 118 | } |
119 | 119 | ||
120 | // TODO - This needs to be moved into geom obj's init routine instead of here | ||
121 | this.setColor(this.options.stroke, this.options.fill, canvas, "rectTool"); | ||
122 | |||
120 | if(canvas.elementModel.isShape) | 123 | if(canvas.elementModel.isShape) |
121 | { | 124 | { |
122 | this.application.ninja.selectionController.selectElement(canvas); | 125 | this.application.ninja.selectionController.selectElement(canvas); |
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 8d381711..6ff61546 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js | |||
@@ -209,7 +209,31 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
209 | 209 | ||
210 | return target; | 210 | return target; |
211 | } | 211 | } |
212 | } | 212 | }, |
213 | |||
214 | // We can draw on an existing canvas unless it has only a single shape object | ||
215 | setColor: { | ||
216 | value: function(stroke, fill, canvas, toolId) | ||
217 | { | ||
218 | if(stroke && stroke.color) | ||
219 | { | ||
220 | this.application.ninja.elementMediator.setColor([canvas], {mode:stroke.colorMode, color:stroke.color}, false, "Change", toolId); | ||
221 | } | ||
222 | else | ||
223 | { | ||
224 | this.application.ninja.elementMediator.setColor([canvas], {mode:"nocolor", color:null}, false, "Change", toolId); | ||
225 | } | ||
226 | |||
227 | if(fill && fill.color) | ||
228 | { | ||
229 | this.application.ninja.elementMediator.setColor([canvas], {mode:fill.colorMode, color:fill.color}, true, "Change", toolId); | ||
230 | } | ||
231 | else | ||
232 | { | ||
233 | this.application.ninja.elementMediator.setColor([canvas], {mode:"nocolor", color:null}, true, "Change", toolId); | ||
234 | } | ||
235 | } | ||
236 | } | ||
213 | 237 | ||
214 | }); | 238 | }); |
215 | 239 | ||