diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 269 | ||||
-rwxr-xr-x | js/document/html-document.js | 11 | ||||
-rwxr-xr-x | js/lib/drawing/world.js | 2 | ||||
-rwxr-xr-x | js/lib/geom/circle.js | 19 | ||||
-rwxr-xr-x | js/lib/geom/geom-obj.js | 82 | ||||
-rwxr-xr-x | js/lib/geom/line.js | 10 | ||||
-rwxr-xr-x | js/lib/geom/rectangle.js | 15 | ||||
-rwxr-xr-x | js/models/color-model.js | 56 | ||||
-rwxr-xr-x | js/models/shape-model.js | 7 | ||||
-rwxr-xr-x | js/tools/LineTool.js | 8 | ||||
-rwxr-xr-x | js/tools/OvalTool.js | 15 | ||||
-rwxr-xr-x | js/tools/RectTool.js | 15 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 25 | ||||
-rwxr-xr-x | js/tools/Translate3DToolBase.js | 4 |
14 files changed, 316 insertions, 222 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index ef453bea..a4d53e50 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js | |||
@@ -84,7 +84,6 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
84 | if(sm) | 84 | if(sm) |
85 | { | 85 | { |
86 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); | 86 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); |
87 | el.elementModel.shapeModel.strokeMaterial = sm; | ||
88 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); | 87 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); |
89 | el.elementModel.shapeModel.GLWorld.render(); | 88 | el.elementModel.shapeModel.GLWorld.render(); |
90 | } | 89 | } |
@@ -94,16 +93,15 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
94 | if(fm) | 93 | if(fm) |
95 | { | 94 | { |
96 | el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); | 95 | el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); |
97 | el.elementModel.shapeModel.fillMaterial = fm; | ||
98 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); | 96 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); |
99 | el.elementModel.shapeModel.GLWorld.render(); | 97 | el.elementModel.shapeModel.GLWorld.render(); |
100 | } | 98 | } |
101 | break; | 99 | break; |
102 | case "editStrokeMaterial": | 100 | case "editStrokeMaterial": |
103 | NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.strokeMaterial.getName()}); | 101 | NJevent("showMaterialPopup",{materialId : this.getProperty(el, "strokeMaterial")}); |
104 | break; | 102 | break; |
105 | case "editFillMaterial": | 103 | case "editFillMaterial": |
106 | NJevent("showMaterialPopup",{materialId : el.elementModel.shapeModel.fillMaterial.getName()}); | 104 | NJevent("showMaterialPopup",{materialId : this.getProperty(el, "fillMaterial")}); |
107 | break; | 105 | break; |
108 | case "animate": | 106 | case "animate": |
109 | if(value) | 107 | if(value) |
@@ -159,11 +157,13 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
159 | case "trRadius": | 157 | case "trRadius": |
160 | case "blRadius": | 158 | case "blRadius": |
161 | case "brRadius": | 159 | case "brRadius": |
162 | case "border": | ||
163 | case "background": | ||
164 | case "useWebGl": | 160 | case "useWebGl": |
165 | case "animate": | 161 | case "animate": |
166 | return this.getShapeProperty(el, p); | 162 | return this.getShapeProperty(el, p); |
163 | case "border": | ||
164 | return this.getColor(el, false); | ||
165 | case "background": | ||
166 | return this.getColor(el, true); | ||
167 | case "strokeHardness": | 167 | case "strokeHardness": |
168 | if (el.elementModel && el.elementModel.shapeModel){ | 168 | if (el.elementModel && el.elementModel.shapeModel){ |
169 | return el.elementModel.shapeModel.GLGeomObj.getStrokeHardness(); | 169 | return el.elementModel.shapeModel.GLGeomObj.getStrokeHardness(); |
@@ -202,11 +202,20 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
202 | 202 | ||
203 | 203 | ||
204 | case "strokeMaterial": | 204 | case "strokeMaterial": |
205 | var sm = el.elementModel.shapeModel.GLGeomObj.getStrokeMaterial(); | ||
206 | if(sm) | ||
207 | { | ||
208 | return sm.getName(); | ||
209 | } | ||
210 | else | ||
211 | { | ||
212 | return "FlatMaterial"; | ||
213 | } | ||
205 | case "fillMaterial": | 214 | case "fillMaterial": |
206 | var m = this.getShapeProperty(el, p); | 215 | var fm = el.elementModel.shapeModel.GLGeomObj.getFillMaterial(); |
207 | if(m) | 216 | if(fm) |
208 | { | 217 | { |
209 | return this.getShapeProperty(el, p).getName(); | 218 | return fm.getName(); |
210 | } | 219 | } |
211 | else | 220 | else |
212 | { | 221 | { |
@@ -317,76 +326,104 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
317 | // Routines to get/set color properties | 326 | // Routines to get/set color properties |
318 | getColor: { | 327 | getColor: { |
319 | value: function(el, isFill) { | 328 | value: function(el, isFill) { |
320 | var color, | ||
321 | css; | ||
322 | if(isFill) | 329 | if(isFill) |
323 | { | 330 | { |
324 | if(el.elementModel.shapeModel.background) | 331 | if(el.elementModel.shapeModel.GLGeomObj.getFillColor) |
325 | { | 332 | { |
326 | return el.elementModel.shapeModel.background; | 333 | return this.application.ninja.colorController.colorModel.webGlToColor(el.elementModel.shapeModel.GLGeomObj.getFillColor()); |
327 | } | 334 | } |
328 | color = this.getShapeProperty(el, "fill"); | ||
329 | } | ||
330 | else | 335 | else |
331 | { | 336 | { |
332 | if(el.elementModel.shapeModel.border) | 337 | return null; |
333 | { | ||
334 | return el.elementModel.shapeModel.border; | ||
335 | } | 338 | } |
336 | color = this.getShapeProperty(el, "stroke"); | ||
337 | } | 339 | } |
338 | 340 | else | |
339 | if(!css) { | 341 | { |
340 | return null; | 342 | return this.application.ninja.colorController.colorModel.webGlToColor(el.elementModel.shapeModel.GLGeomObj.getStrokeColor()); |
341 | } | 343 | } |
342 | |||
343 | css = this.application.ninja.colorController.colorModel.webGlToCss(color); | ||
344 | return this.application.ninja.colorController.getColorObjFromCss(css); | ||
345 | } | 344 | } |
346 | }, | 345 | }, |
347 | 346 | ||
348 | _setGradientMaterial: { | 347 | _setGradientMaterial: { |
349 | value: function(el, gradientMode, isFill) { | 348 | value: function(el, gradientMode, isFill) { |
350 | var m = "LinearGradientMaterial", | 349 | var m, |
351 | fm; | 350 | gradientM; |
351 | if(isFill) | ||
352 | { | ||
353 | m = el.elementModel.shapeModel.GLGeomObj.getFillMaterial(); | ||
354 | } | ||
355 | else | ||
356 | { | ||
357 | m = el.elementModel.shapeModel.GLGeomObj.getStrokeMaterial(); | ||
358 | } | ||
359 | |||
352 | if(gradientMode === "radial") | 360 | if(gradientMode === "radial") |
353 | { | 361 | { |
354 | m = "RadialGradientMaterial"; | 362 | if( !m || (m.getName() !== "RadialGradientMaterial") ) |
363 | { | ||
364 | gradientM = Object.create(MaterialsModel.getMaterial("RadialGradientMaterial")); | ||
365 | } | ||
366 | } | ||
367 | else | ||
368 | { | ||
369 | if( !m || (m.getName() !== "LinearGradientMaterial") ) | ||
370 | { | ||
371 | gradientM = Object.create(MaterialsModel.getMaterial("LinearGradientMaterial")); | ||
372 | } | ||
355 | } | 373 | } |
356 | 374 | ||
375 | if(gradientM) | ||
376 | { | ||
357 | if(isFill) | 377 | if(isFill) |
358 | { | 378 | { |
359 | if(el.elementModel.shapeModel.fillMaterial.getName() !== m) | 379 | el.elementModel.shapeModel.GLGeomObj.setFillMaterial(gradientM); |
380 | } | ||
381 | else | ||
360 | { | 382 | { |
361 | fm = Object.create(MaterialsModel.getMaterial(m)); | 383 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(gradientM); |
362 | if(fm) | 384 | } |
363 | { | ||
364 | el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); | ||
365 | el.elementModel.shapeModel.fillMaterial = fm; | ||
366 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); | 385 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); |
367 | } | 386 | } |
368 | } | 387 | } |
388 | }, | ||
389 | |||
390 | _setFlatMaterial: { | ||
391 | value: function(el, isFill) { | ||
392 | var m, | ||
393 | flatM; | ||
394 | if(isFill) | ||
395 | { | ||
396 | m = el.elementModel.shapeModel.GLGeomObj.getFillMaterial(); | ||
369 | } | 397 | } |
370 | else | 398 | else |
371 | { | 399 | { |
372 | if(el.elementModel.shapeModel.strokeMaterial.getName() !== m) | 400 | m = el.ele |