diff options
author | Pushkar Joshi | 2012-06-11 14:06:09 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-06-11 14:06:09 -0700 |
commit | 76db3eb0aa4ffe9e75812db570c793e9f852f853 (patch) | |
tree | 53c351050d19ad9d6f218319ef4d51679379e6b5 | |
parent | ce9439ffaa82d5a2dd93dfa39da4f513c31f6824 (diff) | |
download | ninja-76db3eb0aa4ffe9e75812db570c793e9f852f853.tar.gz |
fix the brush tool runtime: update the brush coordinates to account for change in bounding box due to smoothing
-rw-r--r-- | assets/canvas-runtime.js | 35 | ||||
-rw-r--r-- | js/io/system/ninjalibrary.json | 2 |
2 files changed, 35 insertions, 2 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 | ||
diff --git a/js/io/system/ninjalibrary.json b/js/io/system/ninjalibrary.json index e9df5e58..03753da9 100644 --- a/js/io/system/ninjalibrary.json +++ b/js/io/system/ninjalibrary.json | |||
@@ -1,6 +1,6 @@ | |||
1 | { | 1 | { |
2 | "libraries": [ | 2 | "libraries": [ |
3 | {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.10.0.0"}, | 3 | {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.10.0.0"}, |
4 | {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.9.0"} | 4 | {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.6.0.0"} |
5 | ] | 5 | ] |
6 | } \ No newline at end of file | 6 | } \ No newline at end of file |