@thi.ng/grid-iterators 2.1.1 → 2.2.2
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 +88 -54
- package/README.md +1 -1
- package/internal/clipping.d.ts +27 -0
- package/internal/clipping.js +55 -0
- package/package.json +149 -144
- package/tools/build-assets.js +68 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,96 +1,130 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
## [2.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/grid-iterators@2.1.0...@thi.ng/grid-iterators@2.1.1) (2021-11-04)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @thi.ng/grid-iterators
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
- **Last updated**: 2021-11-21T17:09:28Z
|
|
4
|
+
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
11
5
|
|
|
6
|
+
All notable changes to this project will be documented in this file.
|
|
7
|
+
See [Conventional Commits](https://conventionalcommits.org/) for commit guidelines.
|
|
12
8
|
|
|
9
|
+
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
|
+
and/or version bumps of transitive dependencies.
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
### Bug Fixes
|
|
18
|
-
|
|
19
|
-
* **grid-iterators:** fix imports, readme ([adff976](https://github.com/thi-ng/umbrella/commit/adff976f8b370108fbc29796a39f243513bc5504))
|
|
20
|
-
|
|
12
|
+
## [2.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@2.2.0) (2021-11-17)
|
|
21
13
|
|
|
22
|
-
|
|
14
|
+
#### 🚀 Features
|
|
23
15
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
- Using workspaces for local tools ([bf7a404](https://github.com/thi-ng/umbrella/commit/bf7a404))
|
|
17
|
+
Improving the overall build ergonomics
|
|
18
|
+
- introduced a tools workspaces
|
|
19
|
+
- imported it in all needed packages/examples
|
|
20
|
+
- inclusive project root
|
|
27
21
|
|
|
22
|
+
#### ♻️ Refactoring
|
|
28
23
|
|
|
24
|
+
- testrunner to binary ([4ebbbb2](https://github.com/thi-ng/umbrella/commit/4ebbbb2))
|
|
25
|
+
this commit reverts (partly) changes made in:
|
|
26
|
+
ef346d7a8753590dc9094108a3d861a8dbd5dd2c
|
|
27
|
+
overall purpose is better testament ergonomics:
|
|
28
|
+
instead of having to pass NODE_OPTIONS with every invocation
|
|
29
|
+
having a binary to handle this for us.
|
|
29
30
|
|
|
31
|
+
## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@2.1.0) (2021-11-03)
|
|
30
32
|
|
|
33
|
+
#### 🚀 Features
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
- add clipped shape iterators ([611f0da](https://github.com/thi-ng/umbrella/commit/611f0da))
|
|
36
|
+
- add generic clipped() filter iterator
|
|
37
|
+
- add circleClipped()
|
|
38
|
+
- add [hv]lineClipped()
|
|
39
|
+
- add flood fill functions ([65796b9](https://github.com/thi-ng/umbrella/commit/65796b9))
|
|
40
|
+
- add floodFill(), update deps ([4634cf1](https://github.com/thi-ng/umbrella/commit/4634cf1))
|
|
33
41
|
|
|
42
|
+
#### 🩹 Bug fixes
|
|
34
43
|
|
|
35
|
-
|
|
44
|
+
- fix imports, readme ([adff976](https://github.com/thi-ng/umbrella/commit/adff976))
|
|
36
45
|
|
|
37
|
-
|
|
46
|
+
#### ♻️ Refactoring
|
|
38
47
|
|
|
48
|
+
- update floodFill() predicate type ([dec44e0](https://github.com/thi-ng/umbrella/commit/dec44e0))
|
|
49
|
+
- update docs
|
|
50
|
+
- update clipped shape iters ([dc065ed](https://github.com/thi-ng/umbrella/commit/dc065ed))
|
|
51
|
+
- better pre-clipping for circle/line
|
|
52
|
+
- intern intersection/clipping helpers
|
|
53
|
+
- replace/re-use asInt() helper ([1b80de4](https://github.com/thi-ng/umbrella/commit/1b80de4))
|
|
39
54
|
|
|
40
|
-
###
|
|
55
|
+
### [2.0.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@2.0.1) (2021-10-13)
|
|
41
56
|
|
|
42
|
-
|
|
57
|
+
#### ♻️ Refactoring
|
|
43
58
|
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
- `node --experimental-specifier-resolution=node --experimental-repl-await`
|
|
48
|
-
- in the node REPL use `await import(...)` instead of `require()`
|
|
49
|
-
- UMD obsolete due to widespread browser support for ESM
|
|
59
|
+
- update imports in all tests/pkgs ([effd591](https://github.com/thi-ng/umbrella/commit/effd591))
|
|
60
|
+
- update imports in all pkgs ([5fa2b6f](https://github.com/thi-ng/umbrella/commit/5fa2b6f))
|
|
61
|
+
- add .js suffix for all relative imports
|
|
50
62
|
|
|
51
|
-
|
|
52
|
-
- normalize/restructure/reorg all package.json files
|
|
53
|
-
- cleanup all build scripts, remove obsolete
|
|
54
|
-
- switch from mocha to @thi.ng/testament for all tests
|
|
63
|
+
# [2.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@2.0.0) (2021-10-12)
|
|
55
64
|
|
|
65
|
+
#### 🛑 Breaking changes
|
|
56
66
|
|
|
67
|
+
- major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea))
|
|
68
|
+
- BREAKING CHANGE: discontinue CommonJS & UMD versions
|
|
69
|
+
- only ESM modules will be published from now on
|
|
70
|
+
- CJS obsolete due to ESM support in recent versions of node:
|
|
71
|
+
- i.e. launch NodeJS via:
|
|
72
|
+
- `node --experimental-specifier-resolution=node --experimental-repl-await`
|
|
73
|
+
- in the node REPL use `await import(...)` instead of `require()`
|
|
74
|
+
- UMD obsolete due to widespread browser support for ESM
|
|
75
|
+
Also:
|
|
76
|
+
- normalize/restructure/reorg all package.json files
|
|
77
|
+
- cleanup all build scripts, remove obsolete
|
|
78
|
+
- switch from mocha to [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament) for all tests
|
|
57
79
|
|
|
80
|
+
#### ♻️ Refactoring
|
|
58
81
|
|
|
82
|
+
- minor pkg restructure (various) ([47f88d2](https://github.com/thi-ng/umbrella/commit/47f88d2))
|
|
83
|
+
- update imports (transducers) ([cab1ea8](https://github.com/thi-ng/umbrella/commit/cab1ea8))
|
|
84
|
+
- update imports ([138571a](https://github.com/thi-ng/umbrella/commit/138571a))
|
|
85
|
+
- update all test stubs ([f2d6d53](https://github.com/thi-ng/umbrella/commit/f2d6d53))
|
|
86
|
+
- update all tests in _all_ pkgs ([8b582bc](https://github.com/thi-ng/umbrella/commit/8b582bc))
|
|
87
|
+
- update all to use [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament)
|
|
59
88
|
|
|
89
|
+
### [0.4.24](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@0.4.24) (2021-03-03)
|
|
60
90
|
|
|
61
|
-
|
|
91
|
+
#### 🩹 Bug fixes
|
|
62
92
|
|
|
63
|
-
|
|
93
|
+
- enforce int coords ([e8e570f](https://github.com/thi-ng/umbrella/commit/e8e570f))
|
|
64
94
|
|
|
65
|
-
|
|
95
|
+
### [0.4.15](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@0.4.15) (2020-12-07)
|
|
66
96
|
|
|
67
|
-
|
|
97
|
+
#### ♻️ Refactoring
|
|
68
98
|
|
|
69
|
-
-
|
|
99
|
+
- update type-only imports in various tests/pkgs ([3fd9c24](https://github.com/thi-ng/umbrella/commit/3fd9c24))
|
|
70
100
|
|
|
71
|
-
|
|
101
|
+
## [0.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@0.4.0) (2020-06-20)
|
|
72
102
|
|
|
73
|
-
|
|
103
|
+
#### 🚀 Features
|
|
74
104
|
|
|
75
|
-
-
|
|
105
|
+
- add new iterators ([e08985e](https://github.com/thi-ng/umbrella/commit/e08985e))
|
|
106
|
+
- add columns, rows
|
|
107
|
+
- add columnEnds, diagonalEnds, rowEnds
|
|
76
108
|
|
|
77
|
-
|
|
109
|
+
## [0.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@0.3.0) (2020-02-25)
|
|
78
110
|
|
|
79
|
-
|
|
111
|
+
#### 🚀 Features
|
|
80
112
|
|
|
81
|
-
-
|
|
113
|
+
- add line & circle iterators ([a6b757d](https://github.com/thi-ng/umbrella/commit/a6b757d))
|
|
114
|
+
- add line(), hline(), vline()
|
|
115
|
+
- add circle()
|
|
82
116
|
|
|
83
|
-
|
|
117
|
+
## [0.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@0.2.0) (2019-11-09)
|
|
84
118
|
|
|
85
|
-
|
|
119
|
+
#### 🚀 Features
|
|
86
120
|
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
121
|
+
- add zigzagDiagonal(), update readme, rename files ([5630055](https://github.com/thi-ng/umbrella/commit/5630055))
|
|
122
|
+
- add interleave fns ([c883ea0](https://github.com/thi-ng/umbrella/commit/c883ea0))
|
|
123
|
+
- add z-curve & random iterators, add deps ([ba8ed18](https://github.com/thi-ng/umbrella/commit/ba8ed18))
|
|
124
|
+
- make row args optional ([60dccfc](https://github.com/thi-ng/umbrella/commit/60dccfc))
|
|
91
125
|
|
|
92
|
-
|
|
126
|
+
## [0.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@0.1.0) (2019-09-21)
|
|
93
127
|
|
|
94
|
-
|
|
128
|
+
#### 🚀 Features
|
|
95
129
|
|
|
96
|
-
-
|
|
130
|
+
- import as new package, incl. assets ([fe4ee00](https://github.com/thi-ng/umbrella/commit/fe4ee00))
|
package/README.md
CHANGED
|
@@ -225,7 +225,7 @@ node --experimental-repl-await
|
|
|
225
225
|
> const gridIterators = await import("@thi.ng/grid-iterators");
|
|
226
226
|
```
|
|
227
227
|
|
|
228
|
-
Package sizes (gzipped, pre-treeshake): ESM: 2.
|
|
228
|
+
Package sizes (gzipped, pre-treeshake): ESM: 2.22 KB
|
|
229
229
|
|
|
230
230
|
## Dependencies
|
|
231
231
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { FnU7, FnU8, Tuple } from "@thi.ng/api";
|
|
2
|
+
/**
|
|
3
|
+
* Based on {@link @thi.ng/geom-isec}, but inlined to avoid dependency.
|
|
4
|
+
*
|
|
5
|
+
* @param x
|
|
6
|
+
* @param y
|
|
7
|
+
* @param w
|
|
8
|
+
* @param h
|
|
9
|
+
* @param cx
|
|
10
|
+
* @param cy
|
|
11
|
+
* @param r
|
|
12
|
+
*/
|
|
13
|
+
export declare const intersectRectCircle: FnU7<number, boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Based on {@link @thi.ng/geom-clip-line#liangBarsky2Raw}, but with diff return type.
|
|
16
|
+
*
|
|
17
|
+
* @param ax
|
|
18
|
+
* @param ay
|
|
19
|
+
* @param bx
|
|
20
|
+
* @param by
|
|
21
|
+
* @param minx
|
|
22
|
+
* @param miny
|
|
23
|
+
* @param maxx
|
|
24
|
+
* @param maxy
|
|
25
|
+
*/
|
|
26
|
+
export declare const liangBarsky: FnU8<number, Tuple<number, 4> | undefined>;
|
|
27
|
+
//# sourceMappingURL=clipping.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const axis = (a, b, c) => (a < b ? a - b : a > b + c ? a - b - c : 0) ** 2;
|
|
2
|
+
/**
|
|
3
|
+
* Based on {@link @thi.ng/geom-isec}, but inlined to avoid dependency.
|
|
4
|
+
*
|
|
5
|
+
* @param x
|
|
6
|
+
* @param y
|
|
7
|
+
* @param w
|
|
8
|
+
* @param h
|
|
9
|
+
* @param cx
|
|
10
|
+
* @param cy
|
|
11
|
+
* @param r
|
|
12
|
+
*/
|
|
13
|
+
export const intersectRectCircle = (x, y, w, h, cx, cy, r) => axis(cx, x, w) + axis(cy, y, h) <= r * r;
|
|
14
|
+
/**
|
|
15
|
+
* Based on {@link @thi.ng/geom-clip-line#liangBarsky2Raw}, but with diff return type.
|
|
16
|
+
*
|
|
17
|
+
* @param ax
|
|
18
|
+
* @param ay
|
|
19
|
+
* @param bx
|
|
20
|
+
* @param by
|
|
21
|
+
* @param minx
|
|
22
|
+
* @param miny
|
|
23
|
+
* @param maxx
|
|
24
|
+
* @param maxy
|
|
25
|
+
*/
|
|
26
|
+
export const liangBarsky = (ax, ay, bx, by, minx, miny, maxx, maxy) => {
|
|
27
|
+
const dx = bx - ax;
|
|
28
|
+
const dy = by - ay;
|
|
29
|
+
let alpha = 0;
|
|
30
|
+
let beta = 1;
|
|
31
|
+
const clip = (p, q) => {
|
|
32
|
+
if (p < 0) {
|
|
33
|
+
const r = q / p;
|
|
34
|
+
if (r > beta)
|
|
35
|
+
return false;
|
|
36
|
+
r > alpha && (alpha = r);
|
|
37
|
+
}
|
|
38
|
+
else if (p > 0) {
|
|
39
|
+
const r = q / p;
|
|
40
|
+
if (r < alpha)
|
|
41
|
+
return false;
|
|
42
|
+
r < beta && (beta = r);
|
|
43
|
+
}
|
|
44
|
+
else if (q < 0) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
49
|
+
return clip(-dx, ax - minx) &&
|
|
50
|
+
clip(dx, maxx - ax) &&
|
|
51
|
+
clip(-dy, ay - miny) &&
|
|
52
|
+
clip(dy, maxy - ay)
|
|
53
|
+
? [alpha * dx + ax, alpha * dy + ay, beta * dx + ax, beta * dy + ay]
|
|
54
|
+
: undefined;
|
|
55
|
+
};
|
package/package.json
CHANGED
|
@@ -1,148 +1,153 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
|
|
2
|
+
"name": "@thi.ng/grid-iterators",
|
|
3
|
+
"version": "2.2.2",
|
|
4
|
+
"description": "2D grid and shape iterators w/ multiple orderings",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "./index.js",
|
|
7
|
+
"typings": "./index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/grid-iterators#readme",
|
|
14
|
+
"funding": [
|
|
15
|
+
{
|
|
16
|
+
"type": "github",
|
|
17
|
+
"url": "https://github.com/sponsors/postspectacular"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"type": "patreon",
|
|
21
|
+
"url": "https://patreon.com/thing_umbrella"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"author": "Karsten Schmidt <k+npm@thi.ng>",
|
|
25
|
+
"license": "Apache-2.0",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "yarn clean && tsc --declaration",
|
|
28
|
+
"build:assets": "node tools/build-assets",
|
|
29
|
+
"clean": "rimraf '*.js' '*.d.ts' '*.map' doc",
|
|
30
|
+
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
31
|
+
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
32
|
+
"doc:readme": "yarn doc:stats && tools:readme",
|
|
33
|
+
"doc:stats": "tools:module-stats",
|
|
34
|
+
"pub": "yarn npm publish --access public",
|
|
35
|
+
"test": "testament test"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@thi.ng/api": "^8.3.2",
|
|
39
|
+
"@thi.ng/arrays": "^2.1.2",
|
|
40
|
+
"@thi.ng/binary": "^3.1.2",
|
|
41
|
+
"@thi.ng/bitfield": "^2.1.2",
|
|
42
|
+
"@thi.ng/morton": "^3.1.2",
|
|
43
|
+
"@thi.ng/random": "^3.2.2",
|
|
44
|
+
"@thi.ng/transducers": "^8.1.2"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@microsoft/api-extractor": "^7.18.19",
|
|
48
|
+
"@thi.ng/testament": "^0.2.2",
|
|
49
|
+
"rimraf": "^3.0.2",
|
|
50
|
+
"tools": "^0.0.1",
|
|
51
|
+
"typedoc": "^0.22.9",
|
|
52
|
+
"typescript": "^4.5.2"
|
|
53
|
+
},
|
|
54
|
+
"keywords": [
|
|
55
|
+
"2d",
|
|
56
|
+
"binary",
|
|
57
|
+
"circle",
|
|
58
|
+
"clipping",
|
|
59
|
+
"diagonal",
|
|
60
|
+
"floodfill",
|
|
61
|
+
"grid",
|
|
62
|
+
"hilbert",
|
|
63
|
+
"iterator",
|
|
64
|
+
"line",
|
|
65
|
+
"morton",
|
|
66
|
+
"random",
|
|
67
|
+
"spiral",
|
|
68
|
+
"typescript",
|
|
69
|
+
"z-curve",
|
|
70
|
+
"zigzag"
|
|
71
|
+
],
|
|
72
|
+
"publishConfig": {
|
|
73
|
+
"access": "public"
|
|
74
|
+
},
|
|
75
|
+
"engines": {
|
|
76
|
+
"node": ">=12.7"
|
|
77
|
+
},
|
|
78
|
+
"files": [
|
|
79
|
+
"*.js",
|
|
80
|
+
"*.d.ts"
|
|
81
|
+
],
|
|
82
|
+
"exports": {
|
|
83
|
+
".": {
|
|
84
|
+
"import": "./index.js"
|
|
85
|
+
},
|
|
86
|
+
"./circle": {
|
|
87
|
+
"import": "./circle.js"
|
|
88
|
+
},
|
|
89
|
+
"./clipping": {
|
|
90
|
+
"import": "./clipping.js"
|
|
91
|
+
},
|
|
92
|
+
"./column-ends": {
|
|
93
|
+
"import": "./column-ends.js"
|
|
94
|
+
},
|
|
95
|
+
"./columns": {
|
|
96
|
+
"import": "./columns.js"
|
|
97
|
+
},
|
|
98
|
+
"./diagonal-ends": {
|
|
99
|
+
"import": "./diagonal-ends.js"
|
|
100
|
+
},
|
|
101
|
+
"./diagonal": {
|
|
102
|
+
"import": "./diagonal.js"
|
|
103
|
+
},
|
|
104
|
+
"./flood-fill": {
|
|
105
|
+
"import": "./flood-fill.js"
|
|
106
|
+
},
|
|
107
|
+
"./hilbert": {
|
|
108
|
+
"import": "./hilbert.js"
|
|
109
|
+
},
|
|
110
|
+
"./hvline": {
|
|
111
|
+
"import": "./hvline.js"
|
|
112
|
+
},
|
|
113
|
+
"./interleave": {
|
|
114
|
+
"import": "./interleave.js"
|
|
115
|
+
},
|
|
116
|
+
"./line": {
|
|
117
|
+
"import": "./line.js"
|
|
118
|
+
},
|
|
119
|
+
"./random": {
|
|
120
|
+
"import": "./random.js"
|
|
121
|
+
},
|
|
122
|
+
"./row-ends": {
|
|
123
|
+
"import": "./row-ends.js"
|
|
124
|
+
},
|
|
125
|
+
"./rows": {
|
|
126
|
+
"import": "./rows.js"
|
|
127
|
+
},
|
|
128
|
+
"./spiral": {
|
|
129
|
+
"import": "./spiral.js"
|
|
130
|
+
},
|
|
131
|
+
"./zcurve": {
|
|
132
|
+
"import": "./zcurve.js"
|
|
133
|
+
},
|
|
134
|
+
"./zigzag-columns": {
|
|
135
|
+
"import": "./zigzag-columns.js"
|
|
69
136
|
},
|
|
70
|
-
"
|
|
71
|
-
|
|
137
|
+
"./zigzag-diagonal": {
|
|
138
|
+
"import": "./zigzag-diagonal.js"
|
|
72
139
|
},
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
140
|
+
"./zigzag-rows": {
|
|
141
|
+
"import": "./zigzag-rows.js"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"thi.ng": {
|
|
145
|
+
"related": [
|
|
146
|
+
"morton",
|
|
147
|
+
"rasterize",
|
|
148
|
+
"transducers"
|
|
76
149
|
],
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"./circle": {
|
|
82
|
-
"import": "./circle.js"
|
|
83
|
-
},
|
|
84
|
-
"./clipping": {
|
|
85
|
-
"import": "./clipping.js"
|
|
86
|
-
},
|
|
87
|
-
"./column-ends": {
|
|
88
|
-
"import": "./column-ends.js"
|
|
89
|
-
},
|
|
90
|
-
"./columns": {
|
|
91
|
-
"import": "./columns.js"
|
|
92
|
-
},
|
|
93
|
-
"./diagonal-ends": {
|
|
94
|
-
"import": "./diagonal-ends.js"
|
|
95
|
-
},
|
|
96
|
-
"./diagonal": {
|
|
97
|
-
"import": "./diagonal.js"
|
|
98
|
-
},
|
|
99
|
-
"./flood-fill": {
|
|
100
|
-
"import": "./flood-fill.js"
|
|
101
|
-
},
|
|
102
|
-
"./hilbert": {
|
|
103
|
-
"import": "./hilbert.js"
|
|
104
|
-
},
|
|
105
|
-
"./hvline": {
|
|
106
|
-
"import": "./hvline.js"
|
|
107
|
-
},
|
|
108
|
-
"./interleave": {
|
|
109
|
-
"import": "./interleave.js"
|
|
110
|
-
},
|
|
111
|
-
"./line": {
|
|
112
|
-
"import": "./line.js"
|
|
113
|
-
},
|
|
114
|
-
"./random": {
|
|
115
|
-
"import": "./random.js"
|
|
116
|
-
},
|
|
117
|
-
"./row-ends": {
|
|
118
|
-
"import": "./row-ends.js"
|
|
119
|
-
},
|
|
120
|
-
"./rows": {
|
|
121
|
-
"import": "./rows.js"
|
|
122
|
-
},
|
|
123
|
-
"./spiral": {
|
|
124
|
-
"import": "./spiral.js"
|
|
125
|
-
},
|
|
126
|
-
"./zcurve": {
|
|
127
|
-
"import": "./zcurve.js"
|
|
128
|
-
},
|
|
129
|
-
"./zigzag-columns": {
|
|
130
|
-
"import": "./zigzag-columns.js"
|
|
131
|
-
},
|
|
132
|
-
"./zigzag-diagonal": {
|
|
133
|
-
"import": "./zigzag-diagonal.js"
|
|
134
|
-
},
|
|
135
|
-
"./zigzag-rows": {
|
|
136
|
-
"import": "./zigzag-rows.js"
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
"thi.ng": {
|
|
140
|
-
"related": [
|
|
141
|
-
"morton",
|
|
142
|
-
"rasterize",
|
|
143
|
-
"transducers"
|
|
144
|
-
],
|
|
145
|
-
"year": 2019
|
|
146
|
-
},
|
|
147
|
-
"gitHead": "d6aca4b4edb697613ed6635b1c0b12f0bf27b1f0"
|
|
148
|
-
}
|
|
150
|
+
"year": 2019
|
|
151
|
+
},
|
|
152
|
+
"gitHead": "e8a7c2a40191b391cef182c2978e5a6c85987a87\n"
|
|
153
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const g = require("@thi.ng/geom");
|
|
2
|
+
const gi = require("@thi.ng/grid-iterators");
|
|
3
|
+
const str = require("@thi.ng/strings");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const execSync = require("child_process").execSync;
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
fs.mkdirSync("export");
|
|
9
|
+
} catch (e) {}
|
|
10
|
+
|
|
11
|
+
[
|
|
12
|
+
gi.columns2d,
|
|
13
|
+
gi.rows2d,
|
|
14
|
+
gi.diagonal2d,
|
|
15
|
+
gi.hilbert2d,
|
|
16
|
+
gi.interleaveColumns2d,
|
|
17
|
+
gi.interleaveRows2d,
|
|
18
|
+
gi.random2d,
|
|
19
|
+
gi.spiral2d,
|
|
20
|
+
gi.zcurve2d,
|
|
21
|
+
gi.zigzagColumns2d,
|
|
22
|
+
gi.zigzagDiagonal2d,
|
|
23
|
+
gi.zigzagRows2d,
|
|
24
|
+
].forEach((fn) => {
|
|
25
|
+
console.log(`generating ${fn.name}...`);
|
|
26
|
+
const pts = [...fn(16)];
|
|
27
|
+
const base = `export/${fn.name.toLowerCase()}`;
|
|
28
|
+
for (let i = 1; i <= 128; i++) {
|
|
29
|
+
fs.writeFileSync(
|
|
30
|
+
`${base}-${str.Z3(i)}.svg`,
|
|
31
|
+
g.asSvg(
|
|
32
|
+
g.svgDoc(
|
|
33
|
+
{
|
|
34
|
+
width: 600,
|
|
35
|
+
height: 600,
|
|
36
|
+
viewBox: "-1 -1 18 18",
|
|
37
|
+
stroke: "black",
|
|
38
|
+
"stroke-width": 0.1,
|
|
39
|
+
},
|
|
40
|
+
g.polyline(
|
|
41
|
+
pts.slice(0, i * 2).map(([x, y]) => [x + 0.5, y + 0.5])
|
|
42
|
+
),
|
|
43
|
+
g.group(
|
|
44
|
+
{ fill: [0, 1, 0.5, 0.25], stroke: "none" },
|
|
45
|
+
pts.slice(0, i * 2 - 1).map((p) => g.rect(p, 1))
|
|
46
|
+
),
|
|
47
|
+
g.rect(pts[i * 2 - 1], 1, {
|
|
48
|
+
fill: [0, 1, 0.5, 0.85],
|
|
49
|
+
stroke: "none",
|
|
50
|
+
})
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
console.log(`\tconverting to PNG...`);
|
|
56
|
+
execSync(`../../scripts/svg2png ${base}*.svg`);
|
|
57
|
+
console.log(`\tremoving SVG files...`);
|
|
58
|
+
execSync(`rm ${base}*.svg`);
|
|
59
|
+
console.log(`\tbuilding GIFs...`);
|
|
60
|
+
execSync(`gm convert -delay 6 ${base}*.png ${base}.gif`);
|
|
61
|
+
execSync(
|
|
62
|
+
`gm convert -delay 6 -resize 200x200 ${base}*.png ${base}-small.gif`
|
|
63
|
+
);
|
|
64
|
+
console.log(`\tbuilding MP4...`);
|
|
65
|
+
execSync(
|
|
66
|
+
`ffmpeg -r 30 -i ${base}-%03d.png -c:v libx264 -pix_fmt yuv420p -y ${base}.mp4`
|
|
67
|
+
);
|
|
68
|
+
});
|