diff options
Diffstat (limited to 'js/tools')
-rw-r--r-- | js/tools/BrushTool.js | 17 | ||||
-rwxr-xr-x | js/tools/EyedropperTool.js | 1 | ||||
-rwxr-xr-x | js/tools/FillTool.js | 33 | ||||
-rwxr-xr-x | js/tools/InkBottleTool.js | 50 | ||||
-rwxr-xr-x | js/tools/LineTool.js | 109 | ||||
-rwxr-xr-x | js/tools/PanTool.js | 1 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 445 | ||||
-rwxr-xr-x | js/tools/RotateStage3DTool.js | 11 | ||||
-rwxr-xr-x | js/tools/SelectionTool.js | 114 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 45 | ||||
-rwxr-xr-x | js/tools/TagTool.js | 15 | ||||
-rwxr-xr-x | js/tools/TextTool.js | 29 | ||||
-rwxr-xr-x | js/tools/drawing-tool-base.js | 2 | ||||
-rwxr-xr-x | js/tools/drawing-tool.js | 3 | ||||
-rwxr-xr-x | js/tools/modifier-tool-base.js | 2 |
15 files changed, 622 insertions, 255 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 | ||
diff --git a/js/tools/EyedropperTool.js b/js/tools/EyedropperTool.js index 6678e498..6a56004d 100755 --- a/js/tools/EyedropperTool.js +++ b/js/tools/EyedropperTool.js | |||
@@ -376,7 +376,6 @@ exports.EyedropperTool = Montage.create(toolBase, { | |||
376 | if(worldData) | 376 | if(worldData) |
377 | { | 377 | { |
378 | this._webGlDataCanvas = njModule.NJUtils.make("canvas", {"data-RDGE-id": njModule.NJUtils.generateRandom()}, this.application.ninja.currentDocument); | 378 | this._webGlDataCanvas = njModule.NJUtils.make("canvas", {"data-RDGE-id": njModule.NJUtils.generateRandom()}, this.application.ninja.currentDocument); |
379 | njModule.NJUtils.createModelWithShape(this._webGlDataCanvas, "Canvas"); | ||
380 | this._applyElementStyles(elt, this._webGlDataCanvas, ["display", "position", "width", "height", | 379 | this._applyElementStyles(elt, this._webGlDataCanvas, ["display", "position", "width", "height", |
381 | "-webkit-transform", "-webkit-transform-style"]); | 380 | "-webkit-transform", "-webkit-transform-style"]); |
382 | this._webGlDataCanvas.style.left = eltCoords[0] + "px"; | 381 | this._webGlDataCanvas.style.left = eltCoords[0] + "px"; |
diff --git a/js/tools/FillTool.js b/js/tools/FillTool.js index 66dd9305..e08ec1da 100755 --- a/js/tools/FillTool.js +++ b/js/tools/FillTool.js | |||
@@ -70,25 +70,32 @@ exports.FillTool = Montage.create(ModifierToolBase, { | |||
70 | // Called by modifier tool base's HandleLeftButtonDown after updating selection (if needed) | 70 | // Called by modifier tool base's HandleLeftButtonDown after updating selection (if needed) |
71 | startDraw: { | 71 | startDraw: { |
72 | value: function(event) { | 72 | value: function(event) { |
73 | this.drawData = null; | ||
73 | this.isDrawing = true; | 74 | this.isDrawing = true; |
74 | 75 | ||
75 | if(this._canColor && this.application.ninja.selectedElements.length) { | 76 | if(this._canColor && this.application.ninja.selectedElements.length) { |
77 | var fillInfo = {}, | ||
78 | color; | ||
79 | if(this.options.useFillColor.checked) { | ||
80 | fillInfo.colorInfo = {}; | ||
81 | color = this.options.fill; | ||
82 | if(color && color.color) | ||
83 | { | ||
84 | fillInfo.colorInfo.mode = color.colorMode; | ||
85 | fillInfo.colorInfo.color = color.color; | ||
86 | } else { | ||
87 | fillInfo.colorInfo.mode = "nocolor"; | ||
88 | fillInfo.colorInfo.color = null; | ||
89 | } | ||
90 | } | ||
76 | 91 | ||
77 | var color = this.options.fill, | 92 | if(this.options.useWebGL.checked) { |
78 | colorInfo; | 93 | fillInfo.webGLInfo = {}; |
79 | if(color && color.color) | 94 | fillInfo.webGLInfo.material = this.options.fillMaterial.value; |
80 | { | ||
81 | colorInfo = { mode:color.colorMode, | ||
82 | color:color.color | ||
83 | }; | ||
84 | } | 95 | } |
85 | else | 96 | if(fillInfo.colorInfo || fillInfo.webGLInfo) { |
86 | { | 97 | ElementsMediator.setFill(this.application.ninja.selectedElements, fillInfo, "Change", "fillTool"); |
87 | colorInfo = { mode:"nocolor", | ||
88 | color:color.color | ||
89 | }; | ||
90 | } | 98 | } |
91 | ElementsMediator.setColor(this.application.ninja.selectedElements, colorInfo, true, "Change", "fillTool"); | ||
92 | } | 99 | } |
93 | } | 100 | } |
94 | } | 101 | } |
diff --git a/js/tools/InkBottleTool.js b/js/tools/InkBottleTool.js index 2c03d133..c5640b10 100755 --- a/js/tools/InkBottleTool.js +++ b/js/tools/InkBottleTool.js | |||
@@ -65,43 +65,51 @@ exports.InkBottleTool = Montage.create(ModifierToolBase, { | |||
65 | // Called by modifier tool base's HandleLeftButtonDown after updating selection (if needed) | 65 | // Called by modifier tool base's HandleLeftButtonDown after updating selection (if needed) |
66 | startDraw: { | 66 | startDraw: { |
67 | value: function(event) { | 67 | value: function(event) { |
68 | this.drawData = null; | ||
68 | this.isDrawing = true; | 69 | this.isDrawing = true; |
69 | 70 | ||
70 | if(this._canColor && this.application.ninja.selectedElements.length) | 71 | if(this._canColor && this.application.ninja.selectedElements.length) |
71 | { | 72 | { |
72 | var color = this.options.stroke, | 73 | var strokeInfo = {}, |
73 | colorInfo; | 74 | color; |
74 | if(color && color.color) | 75 | if(this.options.useStrokeColor.checked) { |
75 | { | 76 | strokeInfo.colorInfo = {}; |
76 | colorInfo = { mode:color.colorMode, | 77 | color = this.options.stroke; |
77 | color:color.color | 78 | if(color && color.color) |
78 | }; | 79 | { |
79 | } | 80 | strokeInfo.colorInfo.mode = color.colorMode; |
80 | else | 81 | strokeInfo.colorInfo.color = color.color; |
81 | { | 82 | } else { |
82 | colorInfo = { mode:"nocolor", | 83 | strokeInfo.colorInfo.mode = "nocolor"; |
83 | color:color.color | 84 | strokeInfo.colorInfo.color = null; |
84 | }; | 85 | } |
85 | } | 86 | } |
86 | 87 | ||
87 | if(this.options.useBorderWidth.checked || this.options.useBorderStyle.checked) { | 88 | if(this.options.useBorderWidth.checked || this.options.useBorderStyle.checked) { |
88 | colorInfo.borderInfo = {}; | 89 | strokeInfo.borderInfo = {}; |
89 | if(this.options.useBorderWidth.checked) { | 90 | if(this.options.useBorderWidth.checked) { |
90 | colorInfo.borderInfo.borderWidth = this.options._borderWidth.value; | 91 | strokeInfo.borderInfo.borderWidth = this.options.borderWidth.value; |
91 | colorInfo.borderInfo.borderUnits = this.options._borderWidth.units; | 92 | strokeInfo.borderInfo.borderUnits = this.options.borderWidth.units; |
92 | } | 93 | } |
93 | if(this.options.useBorderStyle.checked) { | 94 | if(this.options.useBorderStyle.checked) { |
94 | colorInfo.borderInfo.borderStyle = this.options._borderStyle.value; | 95 | strokeInfo.borderInfo.borderStyle = this.options.borderStyle.value; |
95 | } | 96 | } |
96 | } | 97 | } |
97 | 98 | ||
98 | if(this.options.useStrokeSize.checked) { | 99 | if(this.options.useStrokeSize.checked) { |
99 | colorInfo.strokeInfo = {}; | 100 | strokeInfo.shapeInfo = {}; |
100 | colorInfo.strokeInfo.strokeSize = this.options._strokeSize.value; | 101 | strokeInfo.shapeInfo.strokeSize = this.options.strokeSize.value; |
101 | colorInfo.strokeInfo.strokeUnits = this.options._strokeSize.units; | 102 | strokeInfo.shapeInfo.strokeUnits = this.options.strokeSize.units; |
103 | } | ||
104 | |||
105 | if(this.options.useWebGL.checked) { | ||
106 | strokeInfo.webGLInfo = {}; | ||