From e1a65d0c2a13e12ee53be98c731616e35aa07a41 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 28 Feb 2012 13:58:34 -0800 Subject: new anchor control guide rendering (smaller handles) and clamp min. width and height to 1 while resizing subpaths --- js/tools/PenTool.js | 83 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 22 deletions(-) (limited to 'js/tools/PenTool.js') diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index bb9c71e7..ddc8bc04 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -66,14 +66,14 @@ exports.PenTool = Montage.create(ShapeTool, { _penPlaneMat: { value: null, writable: true }, //index of the anchor point that the user has hovered over - _hoveredAnchorIndex: {value: null, writable: true}, + _hoveredAnchorIndex: {value: -1, writable: true}, //constants used for picking points --- NOTE: these should be user-settable parameters _PICK_POINT_RADIUS: { value: 10, writable: false }, _DISPLAY_ANCHOR_RADIUS: { value: 5, writable: false }, _DISPLAY_SELECTED_ANCHOR_RADIUS: { value: 10, writable: false }, - _DISPLAY_SELECTED_ANCHOR_PREV_RADIUS: { value: 5, writable: false }, - _DISPLAY_SELECTED_ANCHOR_NEXT_RADIUS: { value: 5, writable: false }, + _DISPLAY_SELECTED_ANCHOR_PREV_RADIUS: { value: 2, writable: false }, + _DISPLAY_SELECTED_ANCHOR_NEXT_RADIUS: { value: 2, writable: false }, //constants used for editing modes (can be OR-ed) EDIT_NONE: { value: 0, writable: false }, @@ -760,9 +760,7 @@ exports.PenTool = Montage.create(ShapeTool, { var verticalOffset = this.application.ninja.stage.userContentTop; //display the subpath as a sequence of cubic beziers ctx.lineWidth = 1;//TODO replace hardcoded stroke width with some programmatically set value (should not be same as stroke width) - if (ctx.lineWidth == subpath.getStrokeWidth()) - ctx.lineWidth = 3; - ctx.strokeStyle = "black"; + ctx.strokeStyle = "green"; //if (subpath.getStrokeColor()) // ctx.strokeStyle = MathUtils.colorToHex( subpath.getStrokeColor() ); ctx.beginPath(); @@ -812,34 +810,53 @@ exports.PenTool = Montage.create(ShapeTool, { var verticalOffset = this.application.ninja.stage.userContentTop;//stageManagerModule.stageManager.userContentTop; //display circles and squares near all control points - ctx.fillStyle = "#FF4444"; - ctx.lineWidth = 2; - ctx.strokeStyle = "black"; + ctx.fillStyle = "#FFFFFF"; + ctx.lineWidth = 1; + ctx.strokeStyle = "green"; + var anchorDelta = 2; + var selAnchorDelta = 4; + for (var i = 0; i < numAnchors; i++) { var px = subpath.getAnchor(i).getPosX(); var py = subpath.getAnchor(i).getPosY(); ctx.beginPath(); - ctx.arc(px + horizontalOffset, py + verticalOffset, this._DISPLAY_ANCHOR_RADIUS, 0, 2 * Math.PI, false); + //ctx.arc(px + horizontalOffset, py + verticalOffset, this._DISPLAY_ANCHOR_RADIUS, 0, 2 * Math.PI, false); + ctx.moveTo(px-anchorDelta+horizontalOffset, py-anchorDelta+verticalOffset); + ctx.lineTo(px+anchorDelta+horizontalOffset, py-anchorDelta+verticalOffset); + ctx.lineTo(px+anchorDelta+horizontalOffset, py+anchorDelta+verticalOffset); + ctx.lineTo(px-anchorDelta+horizontalOffset, py+anchorDelta+verticalOffset); + ctx.closePath(); ctx.fill(); ctx.stroke(); } //display the hovered over anchor point ctx.lineWidth = 2; - ctx.strokeStyle = "black"; - if (this._hoveredAnchorIndex && this._hoveredAnchorIndex>=0 && this._hoveredAnchorIndex=0 && this._hoveredAnchorIndex