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 --- assets/canvas-runtime.js | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'assets') diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index fe5f839c..c2ab0bd8 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js @@ -2107,7 +2107,40 @@ NinjaCvsRt.RuntimeBrushStroke = Object.create(NinjaCvsRt.RuntimeGeomObj, { } this._LocalPoints = newPoints.slice(0); } - } + + // *** compute the bounding box ********* + var BBoxMin = [Infinity, Infinity, Infinity]; + var BBoxMax = [-Infinity, -Infinity, -Infinity]; + if (numPoints === 0) { + BBoxMin = [0, 0, 0]; + BBoxMax = [0, 0, 0]; + } else { + for (var i=0;i pt[d]) { + BBoxMin[d] = pt[d]; + } + if (BBoxMax[d] < pt[d]) { + BBoxMax[d] = pt[d]; + } + }//for every dimension d from 0 to 2 + } + } + + //increase the bbox given the stroke width and the angle (in case of calligraphic brush) + var bboxPadding = this._strokeWidth*0.5; + for (var d = 0; d < 3; d++) { + BBoxMin[d]-= bboxPadding; + BBoxMax[d]+= bboxPadding; + }//for every dimension d from 0 to 2 + + //******* update the local coords so that the bbox min is at the origin ****** + for (var i=0;i0) { + 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 7214ada78f570f7897d33446e280086640666a14 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Wed, 13 Jun 2012 13:31:34 -0700 Subject: fix bug #1704 where small paths/strokes with large stroke width caused a flip of the gradient colors --- assets/canvas-runtime.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'assets') diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index feb35187..6268f0bb 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js @@ -1969,7 +1969,8 @@ NinjaCvsRt.RuntimeSubPath = Object.create(NinjaCvsRt.RuntimeGeomObj, { if (ipColor.gradientMode){ var position, gradient, cs, inset; //vars used in gradient calculations inset = Math.ceil( lw ) - 0.5; - + inset=0; + if(ipColor.gradientMode === "radial") { var ww = w - 2*lw, hh = h - 2*lw; gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(ww, hh)/2); @@ -2181,6 +2182,7 @@ NinjaCvsRt.RuntimeBrushStroke = Object.create(NinjaCvsRt.RuntimeGeomObj, { if (ipColor.gradientMode){ var position, gradient, cs, inset; //vars used in gradient calculations inset = Math.ceil( lw ) - 0.5; + inset=0; if(ipColor.gradientMode === "radial") { var ww = w - 2*lw, hh = h - 2*lw; -- cgit v1.2.3