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/geom/brush-stroke.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 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/geom/brush-stroke.js') 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