aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorValerio Virgillito2012-03-13 11:16:47 -0700
committerValerio Virgillito2012-03-13 11:16:47 -0700
commit9f3307810541ca6f95d7ca6d1febe8afdcd2c101 (patch)
treedac91cf9c9f65b33886160db3aae364873a4352b /js
parent91335d6572a611ecde7a71dbbfdb82bdb40f7e2b (diff)
parent2ac9a855724cc4ccf147ce4130a733a84cc647c3 (diff)
downloadninja-9f3307810541ca6f95d7ca6d1febe8afdcd2c101.tar.gz
Merge pull request #110 from mqg734/WebGLFixes
Gradient Support for Shapes and Eyedropper support for gradients. Also fixed 3d bug when moving multiple selections in 3d using the Selection Tool
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/elements/element-controller.js32
-rwxr-xr-xjs/controllers/elements/shapes-controller.js140
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js12
-rwxr-xr-xjs/lib/drawing/world.js10
-rwxr-xr-xjs/lib/geom/circle.js95
-rwxr-xr-xjs/lib/geom/geom-obj.js123
-rwxr-xr-xjs/lib/geom/line.js57
-rwxr-xr-xjs/lib/geom/rectangle.js102
-rwxr-xr-xjs/mediators/element-mediator.js15
-rwxr-xr-xjs/models/color-model.js3
-rwxr-xr-xjs/panels/Color/colorpanelpopup.reel/colorpanelpopup.js2
-rwxr-xr-xjs/panels/properties.reel/properties.js4
-rwxr-xr-xjs/tools/EyedropperTool.js133
-rwxr-xr-xjs/tools/SelectionTool.js28
-rwxr-xr-xjs/tools/Translate3DToolBase.js1
-rwxr-xr-xjs/tools/TranslateObject3DTool.js2
-rwxr-xr-xjs/tools/modifier-tool-base.js12
17 files changed, 639 insertions, 132 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index ec0335b4..9f00604f 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -74,8 +74,9 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
74 74
75 //-------------------------------------------------------------------------------------------------------- 75 //--------------------------------------------------------------------------------------------------------
76 // Routines to get/set color properties 76 // Routines to get/set color properties
77 // borderSide : "top", "right", "bottom", or "left"
77 getColor: { 78 getColor: {
78 value: function(el, isFill) { 79 value: function(el, isFill, borderSide) {
79 var colorObj, 80 var colorObj,
80 color, 81 color,
81 image; 82 image;
@@ -87,22 +88,29 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
87 { 88 {
88 return el.elementModel.fill; 89 return el.elementModel.fill;
89 } 90 }
90// return this.application.ninja.stylesController.getElementStyle(el, "background-color");
91 //TODO: Once logic for color and gradient is established, this needs to be revised 91 //TODO: Once logic for color and gradient is established, this needs to be revised
92 color = this.getProperty(el, "background-color"); 92 color = this.getProperty(el, "background-color");
93 image = this.getProperty(el, "background-image"); 93 image = this.getProperty(el, "background-image");
94 } 94 }
95 else 95 else
96 { 96 {
97 // TODO - Need to figure out which border side user wants 97 // Try getting border color from specific side first
98 if(el.elementModel.stroke) 98 if(borderSide)
99 { 99 {
100 return el.elementModel.stroke; 100 color = this.getProperty(el, "border-" + borderSide + "-color");
101 image = this.getProperty(el, "border-" + borderSide + "-image");
102 }
103
104 // If no color was found, look up the shared border color
105 if(!color && !image)
106 {
107 if(el.elementModel.stroke)
108 {
109 return el.elementModel.stroke;
110 }
111 color = this.getProperty(el, "border-color");
112 image = this.getProperty(el, "border-image");
101 } 113 }
102 // TODO - Need to figure out which border side user wants
103// return this.application.ninja.stylesController.getElementStyle(el, "border-color");
104 color = this.getProperty(el, "border-color");
105 image = this.getProperty(el, "border-image");
106 } 114 }
107 115
108 if(color || image) { 116 if(color || image) {
@@ -120,11 +128,15 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
120 { 128 {
121 el.elementModel.fill = colorObj; 129 el.elementModel.fill = colorObj;
122 } 130 }
123 else 131 else if(!borderSide)
124 { 132 {
125 // TODO - Need to update border style and width also 133 // TODO - Need to update border style and width also
126 el.elementModel.stroke = colorObj; 134 el.elementModel.stroke = colorObj;
127 } 135 }
136 else
137 {
138 // TODO - Should update specific border sides too
139 }
128 140
129 return colorObj; 141 return colorObj;
130 } 142 }
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);