From 76db3eb0aa4ffe9e75812db570c793e9f852f853 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Mon, 11 Jun 2012 14:06:09 -0700 Subject: fix the brush tool runtime: update the brush coordinates to account for change in bounding box due to smoothing --- js/io/system/ninjalibrary.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/io/system/ninjalibrary.json b/js/io/system/ninjalibrary.json index e9df5e58..03753da9 100644 --- a/js/io/system/ninjalibrary.json +++ b/js/io/system/ninjalibrary.json @@ -1,6 +1,6 @@ { "libraries": [ {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.10.0.0"}, - {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.9.0"} + {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.6.0.0"} ] } \ No newline at end of file -- cgit v1.2.3 From e170a58eb8905d98fcdad3d61d652dad45443019 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 12 Jun 2012 09:14:32 -0700 Subject: allow the addition of anchor points to a closed path (the mouse move cursor still needs to be updated) --- js/tools/PenTool.js | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'js') diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index e296d0e5..52af294a 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -288,16 +288,35 @@ exports.PenTool = Montage.create(ShapeTool, { //assume we are not starting a new path as we will set this to true if we create a new Subpath() this._isNewPath = false; - - //if we had closed the selected subpath previously, or if we have not yet started anything, create a subpath - if (this._entryEditMode !== this.ENTRY_SELECT_PATH && this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._makeMultipleSubpaths) { - this._selectedSubpath = null; - } if (this._subtool !== this.SUBTOOL_NONE && this._selectedSubpath===null) { //do nothing because the pen plus and pen minus subtools need a selected subpath return; } + + //build the hit record for the current mouse position (on the stage or the plane of the path canvas) + var hitRec = this.getHitRecord(event.pageX, event.pageY, false); + var globalMousePos=null, localMousePos=null, stageWorldMousePos = null, drawingCanvas=null; + if (this._selectedSubpathCanvas){ + globalMousePos = hitRec.getScreenPoint(); + localMousePos = ViewUtils.globalToLocal(globalMousePos, this._selectedSubpathCanvas); + } + + //if we have a selected subpath and canvas, check if the current click location hits the path + // todo optimize this...currently pickPath is called twice (see later in this function) + var hitPath = false; + if (this._selectedSubpath && this._selectedSubpathCanvas ) { + var tempSelAnchorAndParamAndCode = this._selectedSubpath.pickPath(localMousePos[0], localMousePos[1], localMousePos[2], this._PICK_POINT_RADIUS, true); + if (tempSelAnchorAndParamAndCode[2] !== this._selectedSubpath.SEL_NONE){ // ******* if we hit the path anywhere ********* + hitPath = true; + } + } + + //if we had closed the selected subpath previously, or if we have not yet started anything, create a subpath + if (this._entryEditMode !== this.ENTRY_SELECT_PATH && this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._makeMultipleSubpaths && !hitPath) { + this._selectedSubpath = null; + } + if (this._selectedSubpath === null) { this._selectedSubpath = new SubPath(); this._selectedSubpathCanvas = null; @@ -335,9 +354,7 @@ exports.PenTool = Montage.create(ShapeTool, { this._selectedSubpath.setFillColor(colorArray); } //if the selectedSubpath was null and needed to be constructed - //build the hit record for the current mouse position (on the stage or the plane of the path canvas) - var hitRec = this.getHitRecord(event.pageX, event.pageY, false); - var globalMousePos=null, localMousePos=null, stageWorldMousePos = null, drawingCanvas=null; + //build the current mouse position in stage world space in case we don't already have a canvas if (!this._selectedSubpathCanvas){ drawingCanvas = this.application.ninja.currentDocument.model.documentRoot;//ViewUtils.getStageElement(); stageWorldMousePos = hitRec.calculateStageWorldPoint(); @@ -345,10 +362,7 @@ exports.PenTool = Montage.create(ShapeTool, { stageWorldMousePos[1]+= snapManager.getStageHeight()*0.5; localMousePos = stageWorldMousePos; //since the subpath points are in stage world space, set the 'localMousePos' to be stage world as well } - else { - globalMousePos = hitRec.getScreenPoint(); - localMousePos = ViewUtils.globalToLocal(globalMousePos, this._selectedSubpathCanvas); - } + if (this._selectedSubpathCanvas === null && this._subtool===this.SUBTOOL_NONE){ //IF this is the first anchor point of the selected subpath @@ -358,7 +372,6 @@ exports.PenTool = Montage.create(ShapeTool, { if (this._selectedSubpath.getNumAnchors()===0) { this._selectedSubpathPlaneMat = hitRec.getPlaneMatrix(); } - //check if the mouse click location is close to the existing anchor var indexAndCode = this._selectedSubpath.pickAnchor(stageWorldMousePos[0], stageWorldMousePos[1], stageWorldMousePos[2], this._PICK_POINT_RADIUS); if (indexAndCode[0]>=0){ @@ -853,9 +866,9 @@ exports.PenTool = Montage.create(ShapeTool, { this._editMode = this.EDIT_NONE; //if we're not in edit_path mode and we closed the selected subpath, then we are going to start a new subpath, so we nullify the selected subpath - if (this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._entryEditMode !== this.ENTRY_SELECT_PATH){ - this._selectedSubpath = null; - } + //if (this._selectedSubpath && this._selectedSubpath.getIsClosed() && this._entryEditMode !== this.ENTRY_SELECT_PATH){ + // this._selectedSubpath = null; + //} if (this._selectedSubpath){ this.DrawSubpathAnchors(this._selectedSubpath);//render the subpath anchors on canvas -- cgit v1.2.3 From 0dd995834865202de1c51b1b4635f6515f54b1ea Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 12 Jun 2012 09:57:13 -0700 Subject: correct mouse cursor on mousemove --- js/tools/PenTool.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 52af294a..33ca5c71 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -539,7 +539,9 @@ exports.PenTool = Montage.create(ShapeTool, { //set the cursor to be the default cursor (depending on whether the selected subpath has any points yet) if (this._subtool===this.SUBTOOL_NONE){ - if (this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0){ + if ((this._selectedSubpath && this._selectedSubpath.getNumAnchors()>0 && !this._selectedSubpath.getIsClosed()) + || + this._entryEditMode === this.ENTRY_SELECT_PATH){ this.application.ninja.stage.drawingCanvas.style.cursor = //"auto"; "url('images/cursors/penCursors/Pen_.png') 5 1, default"; } -- cgit v1.2.3 From 4d9b676db06a3d4ff5f4cf0f35e8fc998e0000c5 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 12 Jun 2012 10:16:20 -0700 Subject: ignore hardness for calligraphic brushes if stroke width is 1 --- js/lib/geom/brush-stroke.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js index d9c2ab53..0e0406dd 100755 --- a/js/lib/geom/brush-stroke.js +++ b/js/lib/geom/brush-stroke.js @@ -719,7 +719,10 @@ BrushStroke.prototype.drawToContext = function(ctx, drawStageWorldPts, stageWorl var disp = [brushStamp[t][0], brushStamp[t][1]]; var alphaVal = 1.0; var distFromOpaqueRegion = Math.abs(t-halfNumTraces) - opaqueRegionHalfWidth; - if (distFromOpaqueRegion>0) { + if (numTraces === 1){ + distFromOpaqueRegion = 0; + } + else if (distFromOpaqueRegion>0) { var transparencyFactor = distFromOpaqueRegion/maxTransparentRegionHalfWidth; alphaVal = 1.0 - transparencyFactor;//(transparencyFactor*transparencyFactor);//the square term produces nonlinearly varying alpha values alphaVal *= 0.5; //factor that accounts for lineWidth == 2 -- cgit v1.2.3