@thi.ng/geom-trace-bitmap 0.3.81 → 0.3.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/extract.js +1 -2
- package/package.json +12 -12
- package/trace.js +4 -8
package/CHANGELOG.md
CHANGED
package/extract.js
CHANGED
|
@@ -2,8 +2,7 @@ import { comparator2 } from "@thi.ng/vectors/compare";
|
|
|
2
2
|
const extractSegmentsX = (pts, maxD = 5) => __extract(pts, maxD, 1);
|
|
3
3
|
const extractSegmentsY = (pts, maxDist = 5) => __extract(pts, maxDist, 0);
|
|
4
4
|
const __extract = (pts, maxD, order) => {
|
|
5
|
-
if (pts.length < 2)
|
|
6
|
-
return { segments: [], points: pts };
|
|
5
|
+
if (pts.length < 2) return { segments: [], points: pts };
|
|
7
6
|
const $ = order ? (p) => [p[1], p[0]] : (p) => p;
|
|
8
7
|
pts = pts.sort(comparator2(order, order ^ 1));
|
|
9
8
|
const segments = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/geom-trace-bitmap",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.82",
|
|
4
4
|
"description": "Bitmap image to hairline vector and point cloud conversions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.11.
|
|
40
|
-
"@thi.ng/errors": "^2.5.
|
|
41
|
-
"@thi.ng/grid-iterators": "^4.0.
|
|
42
|
-
"@thi.ng/matrices": "^2.3.
|
|
43
|
-
"@thi.ng/pixel": "^6.1.
|
|
44
|
-
"@thi.ng/vectors": "^7.10.
|
|
39
|
+
"@thi.ng/api": "^8.11.2",
|
|
40
|
+
"@thi.ng/errors": "^2.5.7",
|
|
41
|
+
"@thi.ng/grid-iterators": "^4.0.74",
|
|
42
|
+
"@thi.ng/matrices": "^2.3.37",
|
|
43
|
+
"@thi.ng/pixel": "^6.1.32",
|
|
44
|
+
"@thi.ng/vectors": "^7.10.31"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@microsoft/api-extractor": "^7.43.
|
|
48
|
-
"esbuild": "^0.
|
|
49
|
-
"typedoc": "^0.25.
|
|
50
|
-
"typescript": "^5.4.
|
|
47
|
+
"@microsoft/api-extractor": "^7.43.2",
|
|
48
|
+
"esbuild": "^0.21.1",
|
|
49
|
+
"typedoc": "^0.25.13",
|
|
50
|
+
"typescript": "^5.4.5"
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
53
53
|
"bitmap",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"status": "alpha",
|
|
101
101
|
"year": 2022
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
|
|
104
104
|
}
|
package/trace.js
CHANGED
|
@@ -75,8 +75,7 @@ const traceLines = (opts, order, border, tx, acc = []) => {
|
|
|
75
75
|
let prevBorder = false;
|
|
76
76
|
const $record = () => {
|
|
77
77
|
acc.push([curr[0], curr[curr.length - 1]]);
|
|
78
|
-
for (let q of curr)
|
|
79
|
-
img.setAtUnsafe(q[0], q[1], clear);
|
|
78
|
+
for (let q of curr) img.setAtUnsafe(q[0], q[1], clear);
|
|
80
79
|
};
|
|
81
80
|
for (let p of order({ cols: img.width, rows: img.height, tx })) {
|
|
82
81
|
const c = select(img.getAtUnsafe(p[0], p[1]), p);
|
|
@@ -86,8 +85,7 @@ const traceLines = (opts, order, border, tx, acc = []) => {
|
|
|
86
85
|
if (isBorder || n >= max) {
|
|
87
86
|
if (n > 0) {
|
|
88
87
|
if (prevBorder) {
|
|
89
|
-
if (n > min)
|
|
90
|
-
$record();
|
|
88
|
+
if (n > min) $record();
|
|
91
89
|
curr = [p];
|
|
92
90
|
} else {
|
|
93
91
|
if (n >= min) {
|
|
@@ -104,8 +102,7 @@ const traceLines = (opts, order, border, tx, acc = []) => {
|
|
|
104
102
|
}
|
|
105
103
|
} else if (n > 0) {
|
|
106
104
|
if (n > min) {
|
|
107
|
-
if (last)
|
|
108
|
-
curr.push(p);
|
|
105
|
+
if (last) curr.push(p);
|
|
109
106
|
$record();
|
|
110
107
|
}
|
|
111
108
|
curr = [];
|
|
@@ -115,8 +112,7 @@ const traceLines = (opts, order, border, tx, acc = []) => {
|
|
|
115
112
|
return acc;
|
|
116
113
|
};
|
|
117
114
|
const tracePoints = ({ img, select, clear }, acc = []) => {
|
|
118
|
-
if (clear === void 0)
|
|
119
|
-
clear = 0;
|
|
115
|
+
if (clear === void 0) clear = 0;
|
|
120
116
|
for (let i = 0, n = img.data.length, w = img.width; i < n; i++) {
|
|
121
117
|
if (select(img.data[i], [i % w, i / w | 0])) {
|
|
122
118
|
acc.push([i % w, i / w | 0]);
|