aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements/shapes-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/elements/shapes-controller.js')
-rwxr-xr-xjs/controllers/elements/shapes-controller.js140
1 files changed, 129 insertions, 11 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index 3423a5a7..d72d9c14 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -259,24 +259,82 @@ exports.ShapesController = Montage.create(CanvasController, {
259 } 259 }
260 }, 260 },
261 261
262 setColor: { 262 _setGradientMaterial: {
263 value: function(el, color, isFill) { 263 value: function(el, gradientMode, isFill) {
264 var webGl = color.webGlColor || color.color.webGlColor; 264 var m = "LinearGradientMaterial",
265 if(!webGl) 265 fm;
266 if(gradientMode === "radial")
266 { 267 {
267 webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color); 268 m = "RadialGradientMaterial";
268 } 269 }
270
269 if(isFill) 271 if(isFill)
270 { 272 {
271 el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl); 273 if(el.elementModel.shapeModel.fillMaterial.getName() !== m)
272 this.setShapeProperty(el, "fill", webGl); 274 {
273 this.setShapeProperty(el, "background", color); 275 fm = Object.create(MaterialsModel.getMaterial(m));
276 if(fm)
277 {
278 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm);
279 el.elementModel.shapeModel.fillMaterial = fm;
280 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
281 }
282 }
274 } 283 }
275 else 284 else
276 { 285 {
277 el.elementModel.shapeModel.GLGeomObj.setStrokeColor(webGl); 286 if(el.elementModel.shapeModel.strokeMaterial.getName() !== m)
278 this.setShapeProperty(el, "stroke", webGl); 287 {
279 this.setShapeProperty(el, "border", color); 288 fm = Object.create(MaterialsModel.getMaterial(m));
289 if(fm)
290 {
291 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(fm);
292 el.elementModel.shapeModel.strokeMaterial = fm;
293 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
294 }
295 }
296 }
297 }
298 },
299
300 setColor: {
301 value: function(el, color, isFill) {
302 var mode = color.mode,
303 webGl;
304 if(isFill)
305 {
306 if(mode)
307 {
308 switch (mode) {
309 case 'nocolor':
310 el.elementModel.shapeModel.GLGeomObj.setFillColor(null);
311 this.setShapeProperty(el, "fill", null);
312 this.setShapeProperty(el, "background", color);
313 el.elementModel.fill = null;
314 return;
315 case 'gradient':
316 if(el.elementModel.shapeModel.useWebGl)
317 {
318 this._setGradientMaterial(el, color.color.gradientMode, isFill);
319 }
320 el.elementModel.shapeModel.GLGeomObj.setFillColor({gradientMode:color.color.gradientMode, color:color.color.stops});
321 el.elementModel.shapeModel.GLWorld.render();
322 this.setShapeProperty(el, "fill", color.color.css);
323 this.setShapeProperty(el, "background", color);
324 el.elementModel.fill = color;
325 break;
326 default:
327 webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color);
328 el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl);
329 this.setShapeProperty(el, "fill", webGl);
330 this.setShapeProperty(el, "background", color);
331 el.elementModel.fill = color;
332 }
333 }
334 }
335 else
336 {
337 // Support for ink-bottle tool
280 if(color.strokeInfo) 338 if(color.strokeInfo)
281 { 339 {
282 var strokeWidth = this.GetValueInPixels(color.strokeInfo.strokeSize, 340 var strokeWidth = this.GetValueInPixels(color.strokeInfo.strokeSize,
@@ -285,7 +343,67 @@ exports.ShapesController = Montage.create(CanvasController, {
285 this.setShapeProperty(el, "strokeSize", color.strokeInfo.strokeSize + " " 343 this.setShapeProperty(el, "strokeSize", color.strokeInfo.strokeSize + " "
286 + color.strokeInfo.strokeUnits); 344 + color.strokeInfo.strokeUnits);
287 } 345 }
346
347 if(mode)
348 {
349 switch (mode) {
350 case 'nocolor':
351 el.elementModel.shapeModel.GLGeomObj.setStrokeColor(null);
352 this.setShapeProperty(el, "stroke", null);
353 this.setShapeProperty(el, "border", color);
354 el.elementModel.fill = null;
355 return;
356 case 'gradient':
357 if(el.elementModel.shapeModel.useWebGl)
358 {
359 this._setGradientMaterial(el, color.color.gradientMode, isFill);
360 }
361 el.elementModel.shapeModel.GLGeomObj.setStrokeColor({gradientMode:color.color.gradientMode, color:color.color.stops});
362 el.elementModel.shapeModel.GLWorld.render();
363 this.setShapeProperty(el, "stroke", color.color.css);
364 this.setShapeProperty(el, "border", color);
365 el.elementModel.fill = color;
366 break;
367 default:
368 webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color);
369 el.elementModel.shapeModel.GLGeomObj.setStrokeColor(webGl);
370 this.setShapeProperty(el, "stroke", webGl);
371 this.setShapeProperty(el, "border", color);
372 el.elementModel.fill = color;
373 }
374 }
288 } 375 }
376
377
378
379
380
381
382// var webGl = color.webGlColor || color.color.webGlColor;
383// if(!webGl)
384// {
385// webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color);
386// }
387// if(isFill)
388// {
389// el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl);
390// this.setShapeProperty(el, "fill", webGl);
391// this.setShapeProperty(el, "background", color);
392// }
393// else
394// {
395// el.elementModel.shapeModel.GLGeomObj.setStrokeColor(webGl);
396// this.setShapeProperty(el, "stroke", webGl);
397// this.setShapeProperty(el, "border", color);
398// if(color.strokeInfo)
399// {
400// var strokeWidth = this.GetValueInPixels(color.strokeInfo.strokeSize,
401// color.strokeInfo.strokeUnits);
402// el.elementModel.shapeModel.GLGeomObj.setStrokeWidth(strokeWidth);
403// this.setShapeProperty(el, "strokeSize", color.strokeInfo.strokeSize + " "
404// + color.strokeInfo.strokeUnits);
405// }
406// }
289 el.elementModel.shapeModel.GLWorld.render(); 407 el.elementModel.shapeModel.GLWorld.render();
290 } 408 }
291 }, 409 },