@thi.ng/geom-isoline 2.1.126 → 2.1.128
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 +7 -1
- package/README.md +1 -1
- package/index.js +13 -14
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-06-21T19:34:38Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
### [2.1.128](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-isoline@2.1.128) (2024-06-21)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
|
|
17
|
+
|
|
12
18
|
### [2.1.82](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-isoline@2.1.82) (2023-11-09)
|
|
13
19
|
|
|
14
20
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 193 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
package/index.js
CHANGED
|
@@ -49,7 +49,7 @@ const setBorder = (src, w, h, val) => {
|
|
|
49
49
|
}
|
|
50
50
|
return src;
|
|
51
51
|
};
|
|
52
|
-
const
|
|
52
|
+
const __encodeCrossings = (src, w, h, iso) => {
|
|
53
53
|
const out = new Uint8Array(src.length);
|
|
54
54
|
const w1 = w - 1;
|
|
55
55
|
const h1 = h - 1;
|
|
@@ -61,22 +61,22 @@ const encodeCrossings = (src, w, h, iso) => {
|
|
|
61
61
|
}
|
|
62
62
|
return out;
|
|
63
63
|
};
|
|
64
|
-
const
|
|
64
|
+
const __cellValue = (src, w, idx) => {
|
|
65
65
|
return (src[idx] + src[idx + 1] + src[idx + w] + src[idx + w + 1]) * 0.25;
|
|
66
66
|
};
|
|
67
|
-
const
|
|
67
|
+
const __mix = (src, w, x1, y1, x2, y2, iso) => {
|
|
68
68
|
const a = src[y1 * w + x1];
|
|
69
69
|
const b = src[y2 * w + x2];
|
|
70
70
|
return a === b ? 0 : (a - iso) / (a - b);
|
|
71
71
|
};
|
|
72
|
-
const
|
|
73
|
-
(src, w, x, y, iso) => [x +
|
|
74
|
-
(src, w, x, y, iso) => [x + 1, y +
|
|
75
|
-
(src, w, x, y, iso) => [x +
|
|
76
|
-
(src, w, x, y, iso) => [x, y +
|
|
72
|
+
const __contourVertex = [
|
|
73
|
+
(src, w, x, y, iso) => [x + __mix(src, w, x, y, x + 1, y, iso), y],
|
|
74
|
+
(src, w, x, y, iso) => [x + 1, y + __mix(src, w, x + 1, y, x + 1, y + 1, iso)],
|
|
75
|
+
(src, w, x, y, iso) => [x + __mix(src, w, x, y + 1, x + 1, y + 1, iso), y + 1],
|
|
76
|
+
(src, w, x, y, iso) => [x, y + __mix(src, w, x, y, x, y + 1, iso)]
|
|
77
77
|
];
|
|
78
78
|
function* isolines(src, w, h, iso, scale = 1) {
|
|
79
|
-
const coded =
|
|
79
|
+
const coded = __encodeCrossings(src, w, h, iso);
|
|
80
80
|
let curr = [];
|
|
81
81
|
let from;
|
|
82
82
|
let to = -1;
|
|
@@ -93,8 +93,7 @@ function* isolines(src, w, h, iso, scale = 1) {
|
|
|
93
93
|
from = to;
|
|
94
94
|
if (next) {
|
|
95
95
|
const c = cells.next();
|
|
96
|
-
if (c.done)
|
|
97
|
-
break;
|
|
96
|
+
if (c.done) break;
|
|
98
97
|
[y, x] = c.value;
|
|
99
98
|
next = false;
|
|
100
99
|
}
|
|
@@ -105,11 +104,11 @@ function* isolines(src, w, h, iso, scale = 1) {
|
|
|
105
104
|
const i = y * w + x;
|
|
106
105
|
const id = coded[i];
|
|
107
106
|
if (id === 10) {
|
|
108
|
-
idx = (
|
|
107
|
+
idx = (__cellValue(src, w, i) > iso ? 0 : 4) + (from === 6 ? 0 : 2);
|
|
109
108
|
to = S5[idx];
|
|
110
109
|
clear = S5[idx + 1];
|
|
111
110
|
} else if (id === 20) {
|
|
112
|
-
idx =
|
|
111
|
+
idx = __cellValue(src, w, i) > iso ? from === 0 ? 0 : 2 : from === 4 ? 4 : 6;
|
|
113
112
|
to = S10[idx];
|
|
114
113
|
clear = S10[idx + 1];
|
|
115
114
|
} else {
|
|
@@ -124,7 +123,7 @@ function* isolines(src, w, h, iso, scale = 1) {
|
|
|
124
123
|
coded[i] = clear;
|
|
125
124
|
}
|
|
126
125
|
if (to >= 0) {
|
|
127
|
-
const p =
|
|
126
|
+
const p = __contourVertex[to >> 1](src, w, x, y, iso);
|
|
128
127
|
p[0] = (p[0] + 0.5) * sx;
|
|
129
128
|
p[1] = (p[1] + 0.5) * sy;
|
|
130
129
|
curr.push(p);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/geom-isoline",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.128",
|
|
4
4
|
"description": "Fast 2D contour line extraction / generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://thi.ng/geom-isoline",
|
|
14
14
|
"funding": [
|
|
15
15
|
{
|
|
16
16
|
"type": "github",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.11.
|
|
40
|
-
"@thi.ng/transducers": "^9.0.
|
|
41
|
-
"@thi.ng/vectors": "^7.
|
|
39
|
+
"@thi.ng/api": "^8.11.3",
|
|
40
|
+
"@thi.ng/transducers": "^9.0.6",
|
|
41
|
+
"@thi.ng/vectors": "^7.11.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@microsoft/api-extractor": "^7.
|
|
45
|
-
"esbuild": "^0.
|
|
46
|
-
"typedoc": "^0.25.
|
|
47
|
-
"typescript": "^5.
|
|
44
|
+
"@microsoft/api-extractor": "^7.47.0",
|
|
45
|
+
"esbuild": "^0.21.5",
|
|
46
|
+
"typedoc": "^0.25.13",
|
|
47
|
+
"typescript": "^5.5.2"
|
|
48
48
|
},
|
|
49
49
|
"keywords": [
|
|
50
50
|
"2d",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"parent": "@thi.ng/geom",
|
|
79
79
|
"year": 2015
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
|
|
82
82
|
}
|