diff options
author | Armen Kesablyan | 2012-06-11 11:17:41 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-06-11 11:17:41 -0700 |
commit | 278769df00ced8620fd73371e38fe2e43f07ca3b (patch) | |
tree | deb505c8a66b660eee1f17a2c6c4c575c7939f6f /js/tools/BrushTool.js | |
parent | 555fd6efa605b937800b3979a4c68fa7eb8666ae (diff) | |
parent | 0f040acabfb7a4bf3138debec5aff869487ceb11 (diff) | |
download | ninja-278769df00ced8620fd73371e38fe2e43f07ca3b.tar.gz |
Merge branch 'refs/heads/master' into binding
Conflicts:
js/document/models/html.js
js/document/views/design.js
js/ninja.reel/ninja.js
Signed-off-by: Armen Kesablyan <armen@motorola.com>
Diffstat (limited to 'js/tools/BrushTool.js')
-rw-r--r-- | js/tools/BrushTool.js | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index 0be378fd..5d983a93 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js | |||
@@ -39,7 +39,7 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
39 | //view options | 39 | //view options |
40 | _brushStrokeCanvas: {value: null, writable: true}, | 40 | _brushStrokeCanvas: {value: null, writable: true}, |
41 | _brushStrokePlaneMat: {value: null, writable: true}, | 41 | _brushStrokePlaneMat: {value: null, writable: true}, |
42 | _draggingPlane: {value: null, writable: true}, | 42 | dragPlane: {value: null, writable: true}, |
43 | 43 | ||
44 | //the current brush stroke | 44 | //the current brush stroke |
45 | _selectedBrushStroke: {value: null, writable: true}, | 45 | _selectedBrushStroke: {value: null, writable: true}, |
@@ -67,7 +67,7 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
67 | 67 | ||
68 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); | 68 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); |
69 | var unsnappedpos = DrawingToolBase.getHitRecPos(snapManager.snap(point.x, point.y, false)); | 69 | var unsnappedpos = DrawingToolBase.getHitRecPos(snapManager.snap(point.x, point.y, false)); |
70 | this._draggingPlane = snapManager.getDragPlane(); | 70 | this.dragPlane = snapManager.getDragPlane(); |
71 | 71 | ||
72 | snapManager.enableElementSnap(elemSnap); | 72 | snapManager.enableElementSnap(elemSnap); |
73 | snapManager.enableGridSnap(gridSnap); | 73 | snapManager.enableGridSnap(gridSnap); |
@@ -100,7 +100,7 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
100 | } | 100 | } |
101 | var tmpPoint = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); | 101 | var tmpPoint = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); |
102 | var hitRec = snapManager.snap(tmpPoint.x, tmpPoint.y, false); | 102 | var hitRec = snapManager.snap(tmpPoint.x, tmpPoint.y, false); |
103 | this._draggingPlane = snapManager.getDragPlane(); | 103 | this.dragPlane = snapManager.getDragPlane(); |
104 | if (this._selectedSubpathCanvas){ | 104 | if (this._selectedSubpathCanvas){ |
105 | snapManager.popWorkingPlane(); | 105 | snapManager.popWorkingPlane(); |
106 | } | 106 | } |
@@ -138,7 +138,7 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
138 | } else { | 138 | } else { |
139 | colorArray = [1,1,1,0]; | 139 | colorArray = [1,1,1,0]; |
140 | } | 140 | } |
141 | this._selectedBrushStroke.setStrokeColor(colorArray); | 141 | this._selectedBrushStroke.setFillColor(colorArray); |
142 | 142 | ||
143 | //add this point to the brush stroke in case the user does a mouse up before doing a mouse move | 143 | //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(); | 144 | var currMousePos = hitRec.calculateStageWorldPoint(); |
@@ -225,9 +225,11 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
225 | this._hasDraw = false; | 225 | this._hasDraw = false; |
226 | 226 | ||
227 | //finish giving enough info. to the brush stroke | 227 | //finish giving enough info. to the brush stroke |
228 | this._selectedBrushStroke.setPlaneMatrix(this._brushStrokePlaneMat); | 228 | if (this._selectedBrushStroke){ |
229 | this._selectedBrushStroke.setPlaneMatrixInverse(glmat4.inverse(this._brushStrokePlaneMat,[])); | 229 | this._selectedBrushStroke.setPlaneMatrix(this._brushStrokePlaneMat); |
230 | this._selectedBrushStroke.setDragPlane(this._draggingPlane); | 230 | this._selectedBrushStroke.setPlaneMatrixInverse(glmat4.inverse(this._brushStrokePlaneMat,[])); |
231 | this._selectedBrushStroke.setDragPlane(this.dragPlane); | ||
232 | } | ||
231 | 233 | ||
232 | //display the previously drawn stroke in a separate canvas | 234 | //display the previously drawn stroke in a separate canvas |
233 | this.RenderCurrentBrushStroke(); | 235 | this.RenderCurrentBrushStroke(); |
@@ -376,7 +378,6 @@ exports.BrushTool = Montage.create(ShapeTool, { | |||
376 | 378 | ||
377 | if (!canvas) { | 379 | if (!canvas) { |
378 | var newCanvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); | 380 | var newCanvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); |
379 | document.application.njUtils.createModelWithShape(newCanvas, "Brushstroke"); | ||
380 | var styles = document.application.njUtils.stylesFromDraw(newCanvas, w, h, {midPt: midPt, planeMat: planeMat}); | 381 | var styles = document.application.njUtils.stylesFromDraw(newCanvas, w, h, {midPt: midPt, planeMat: planeMat}); |
381 | this.application.ninja.elementMediator.addElements(newCanvas, styles, false); | 382 | this.application.ninja.elementMediator.addElements(newCanvas, styles, false); |
382 | 383 | ||