From 806974142d44afdd23534bf2d18eff0a8e701e0c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 8 Jun 2012 16:59:59 -0700 Subject: rewrite: currentSelectedContainer -> domContainer Fixed the currentSelectedContainer by removing bindings and using property change on the current document added the red outline back. Signed-off-by: Valerio Virgillito --- js/lib/NJUtils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/lib') diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index 0dec6345..b35e29bc 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -96,8 +96,8 @@ exports.NJUtils = Montage.create(Component, { var styles = {}; styles['position'] = pos ? pos: "absolute"; - styles['left'] = (Math.round(drawData.midPt[0] - 0.5 * width)) - this.application.ninja.currentSelectedContainer.offsetLeft + 'px'; - styles['top'] = (Math.round(drawData.midPt[1] - 0.5 * height)) - this.application.ninja.currentSelectedContainer.offsetTop + 'px'; + styles['left'] = (Math.round(drawData.midPt[0] - 0.5 * width)) - this.application.ninja.currentDocument.model.domContainer.offsetLeft + 'px'; + styles['top'] = (Math.round(drawData.midPt[1] - 0.5 * height)) - this.application.ninja.currentDocument.model.domContainer.offsetTop + 'px'; styles['width'] = width + 'px'; styles['height'] = height + 'px'; -- 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/lib') 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 From 250d84a79d9f72c6a98cbbecfe4e21f2c0d53a19 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Wed, 13 Jun 2012 10:55:21 -0700 Subject: fixes bug #1623: middle transform handle causes the brush stroke to have a zero width or height and brush stroke cannot be recovered --- js/lib/geom/brush-stroke.js | 69 ++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 26 deletions(-) (limited to 'js/lib') diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js index 0e0406dd..b69139b6 100755 --- a/js/lib/geom/brush-stroke.js +++ b/js/lib/geom/brush-stroke.js @@ -31,6 +31,8 @@ var BrushStroke = function GLBrushStroke() { //the HTML5 canvas that holds this brush stroke this._canvas = null; + //flag indicating whether or not to freeze the size and position of canvas + this._freezeCanvas = false; //stroke information this._strokeWidth = 1.0; @@ -174,11 +176,15 @@ BrushStroke.prototype.getStrokeWidth = function () { }; BrushStroke.prototype.setStrokeWidth = function (w) { - this._strokeWidth = w; - if (this._strokeWidth<1) { - this._strokeWidth = 1; + if (this._strokeWidth!==w) { + this._strokeWidth = w; + + if (this._strokeWidth<1) { + this._strokeWidth = 1; + } + this._isDirty=true; + this._freezeCanvas=false; } - this._isDirty=true; }; /* BrushStroke.prototype.getStrokeMaterial = function () { @@ -236,6 +242,7 @@ BrushStroke.prototype.setSmoothingAmount = function(a){ if (this._strokeAmountSmoothing!==a) { this._strokeAmountSmoothing = a; this._isDirty = true; + this._freezeCanvas=false; } }; @@ -274,27 +281,32 @@ BrushStroke.prototype.setStrokeStyle = function (s) { }; BrushStroke.prototype.setWidth = function (newW) { - if (newW<1) { - newW=1; //clamp minimum width to 1 + //get the old width from the canvas controller if the canvas is frozen, or from bbox if not frozen. + var oldCanvasWidth = parseInt(CanvasController.getProperty(this._canvas, "width")); + if (!this._freezeCanvas){ + oldCanvasWidth = Math.round(this._BBoxMax[0]-this._BBoxMin[0]); + } + var minWidth = 1+this._strokeWidth; + if (newW