aboutsummaryrefslogtreecommitdiff
path: root/assets/canvas-runtime.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/canvas-runtime.js')
-rw-r--r--assets/canvas-runtime.js35
1 files changed, 34 insertions, 1 deletions
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, {
2107 } 2107 }
2108 this._LocalPoints = newPoints.slice(0); 2108 this._LocalPoints = newPoints.slice(0);
2109 } 2109 }
2110 } 2110
2111 // *** compute the bounding box *********
2112 var BBoxMin = [Infinity, Infinity, Infinity];
2113 var BBoxMax = [-Infinity, -Infinity, -Infinity];
2114 if (numPoints === 0) {
2115 BBoxMin = [0, 0, 0];
2116 BBoxMax = [0, 0, 0];
2117 } else {
2118 for (var i=0;i<numPoints;i++){
2119 var pt = this._LocalPoints[i];
2120 for (var d = 0; d < 3; d++) {
2121 if (BBoxMin[d] > pt[d]) {
2122 BBoxMin[d] = pt[d];
2123 }
2124 if (BBoxMax[d] < pt[d]) {
2125 BBoxMax[d] = pt[d];
2126 }
2127 }//for every dimension d from 0 to 2
2128 }
2129 }
2130
2131 //increase the bbox given the stroke width and the angle (in case of calligraphic brush)
2132 var bboxPadding = this._strokeWidth*0.5;
2133 for (var d = 0; d < 3; d++) {
2134 BBoxMin[d]-= bboxPadding;
2135 BBoxMax[d]+= bboxPadding;
2136 }//for every dimension d from 0 to 2
2137
2138 //******* update the local coords so that the bbox min is at the origin ******
2139 for (var i=0;i<numPoints;i++) {
2140 this._LocalPoints[i][0]-= BBoxMin[0];
2141 this._LocalPoints[i][1]-= BBoxMin[1];
2142 }
2143 }//if we need to do smoothing
2111 } 2144 }
2112 }, 2145 },
2113 2146