From dae3041e6b8269da3d593a44c09e2288bb434a02 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Mon, 9 Apr 2012 15:55:10 -0700 Subject: snapping feedback for pen tool, correct for subpaths that may lie on rotated canvas, and with a rotated view --- js/helper-classes/3D/vec-utils.js | 19 ++++++++++++ js/lib/geom/sub-path.js | 29 +++++++++++++++--- js/tools/PenTool.js | 63 ++++++++++++++++++++++++++++++++------- 3 files changed, 97 insertions(+), 14 deletions(-) diff --git a/js/helper-classes/3D/vec-utils.js b/js/helper-classes/3D/vec-utils.js index 4eacd856..0916c840 100755 --- a/js/helper-classes/3D/vec-utils.js +++ b/js/helper-classes/3D/vec-utils.js @@ -113,6 +113,25 @@ var VecUtils = exports.VecUtils = Object.create(Object.prototype, } }, + vecDistSq : { + value: function( dimen, a, b ) { + var sum; + + if ((a.length < dimen) || (b.length < dimen)) + { + throw new Error( "dimension error in VecUtils.vecDistSq" ); + } + + var sum = 0.0; + for (var i=0; ianchorIndex && this._LocalPoints.length > this._anchorSampleIndex[anchorIndex]) { + var localCoord = this._LocalPoints[this._anchorSampleIndex[anchorIndex]] + var distSq = VecUtils.vecDistSq(3, [pickX, pickY, pickZ], localCoord); + //check the anchor point + if (distSq < radSq && distSq=0 && this._selectedAnchorIndex=0) { this._hoveredAnchorIndex = selAnchorRetCode[0]; var lastAnchorIndex = this._selectedSubpath.getNumAnchors()-1; @@ -599,12 +631,23 @@ exports.PenTool = Montage.create(ShapeTool, { strokeSize = ShapesController.GetValueInPixels(this.options.strokeSize.value, this.options.strokeSize.units); } this._selectedSubpath.setStrokeWidth(strokeSize); - if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){ - this._selectedSubpath.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor); + + var colorArray=[]; + var color = this.application.ninja.colorController.colorToolbar.stroke.color; + if (color){ + colorArray = [color.r/255, color.g/255, color.b/255, color.a]; + }else { + colorArray = [1,1,1,0]; } - if (this.application.ninja.colorController.colorToolbar.fill.webGlColor){ - this._selectedSubpath.setFillColor(this.application.ninja.colorController.colorToolbar.fill.webGlColor); + this._selectedSubpath.setStrokeColor(colorArray); + + color = this.application.ninja.colorController.colorToolbar.fill.color; + if (color){ + colorArray = [color.r/255, color.g/255, color.b/255, color.a]; + } else { + colorArray = [1,1,1,0]; } + this._selectedSubpath.setFillColor(colorArray); } //if this is a new path being rendered this._selectedSubpath.makeDirty(); -- cgit v1.2.3