@thi.ng/grid-iterators 2.1.2 → 2.2.3

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 CHANGED
@@ -1,104 +1,130 @@
1
1
  # Change Log
2
2
 
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [2.1.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/grid-iterators@2.1.1...@thi.ng/grid-iterators@2.1.2) (2021-11-10)
7
-
8
- **Note:** Version bump only for package @thi.ng/grid-iterators
9
-
10
-
11
-
12
-
13
-
14
- ## [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)
3
+ - **Last updated**: 2021-11-21T17:09:28Z
4
+ - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
15
5
 
16
- **Note:** Version bump only for package @thi.ng/grid-iterators
17
-
18
-
19
-
20
-
21
-
22
- # [2.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/grid-iterators@2.0.6...@thi.ng/grid-iterators@2.1.0) (2021-11-03)
23
-
24
-
25
- ### Bug Fixes
6
+ All notable changes to this project will be documented in this file.
7
+ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelines.
26
8
 
27
- * **grid-iterators:** fix imports, readme ([adff976](https://github.com/thi-ng/umbrella/commit/adff976f8b370108fbc29796a39f243513bc5504))
9
+ **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
+ and/or version bumps of transitive dependencies.
28
11
 
12
+ ## [2.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@2.2.0) (2021-11-17)
29
13
 
30
- ### Features
14
+ #### 🚀 Features
31
15
 
32
- * **grid-iterators:** add clipped shape iterators ([611f0da](https://github.com/thi-ng/umbrella/commit/611f0da940ab05e1e88b3daafb6cacb8297580a5))
33
- * **grid-iterators:** add floodFill(), update deps ([4634cf1](https://github.com/thi-ng/umbrella/commit/4634cf14aed00837068ffa6a77735f5ab04faf73))
34
- * **pixel:** add flood fill functions ([65796b9](https://github.com/thi-ng/umbrella/commit/65796b96fe77d5c4b999dd8cedfd142ea243a200))
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
35
21
 
22
+ #### ♻️ Refactoring
36
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.
37
30
 
31
+ ## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@2.1.0) (2021-11-03)
38
32
 
33
+ #### 🚀 Features
39
34
 
40
- # [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/grid-iterators@1.0.5...@thi.ng/grid-iterators@2.0.0) (2021-10-12)
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))
41
41
 
42
+ #### 🩹 Bug fixes
42
43
 
43
- ### Build System
44
+ - fix imports, readme ([adff976](https://github.com/thi-ng/umbrella/commit/adff976))
44
45
 
45
- * major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea9fab2a645d6c5f2bf2591459b939c09b6))
46
+ #### ♻️ Refactoring
46
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))
47
54
 
48
- ### BREAKING CHANGES
55
+ ### [2.0.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@2.0.1) (2021-10-13)
49
56
 
50
- * discontinue CommonJS & UMD versions
57
+ #### ♻️ Refactoring
51
58
 
52
- - only ESM modules will be published from now on
53
- - CJS obsolete due to ESM support in recent versions of node:
54
- - i.e. launch NodeJS via:
55
- - `node --experimental-specifier-resolution=node --experimental-repl-await`
56
- - in the node REPL use `await import(...)` instead of `require()`
57
- - 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
58
62
 
59
- Also:
60
- - normalize/restructure/reorg all package.json files
61
- - cleanup all build scripts, remove obsolete
62
- - 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)
63
64
 
65
+ #### 🛑 Breaking changes
64
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
65
79
 
80
+ #### ♻️ Refactoring
66
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)
67
88
 
89
+ ### [0.4.24](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@0.4.24) (2021-03-03)
68
90
 
69
- ## [1.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/grid-iterators@1.0.4...@thi.ng/grid-iterators@1.0.5) (2021-09-03)
91
+ #### 🩹 Bug fixes
70
92
 
71
- **Note:** Version bump only for package @thi.ng/grid-iterators
93
+ - enforce int coords ([e8e570f](https://github.com/thi-ng/umbrella/commit/e8e570f))
72
94
 
73
- ## [0.4.24](https://github.com/thi-ng/umbrella/compare/@thi.ng/grid-iterators@0.4.23...@thi.ng/grid-iterators@0.4.24) (2021-03-03)
95
+ ### [0.4.15](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@0.4.15) (2020-12-07)
74
96
 
75
- ### Bug Fixes
97
+ #### ♻️ Refactoring
76
98
 
77
- - **grid-iterators:** enforce int coords ([e8e570f](https://github.com/thi-ng/umbrella/commit/e8e570fa57640569554084a846cbde54966c0b06))
99
+ - update type-only imports in various tests/pkgs ([3fd9c24](https://github.com/thi-ng/umbrella/commit/3fd9c24))
78
100
 
79
- # [0.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/grid-iterators@0.3.17...@thi.ng/grid-iterators@0.4.0) (2020-06-20)
101
+ ## [0.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@0.4.0) (2020-06-20)
80
102
 
81
- ### Features
103
+ #### 🚀 Features
82
104
 
83
- - **grid-iterators:** add new iterators ([e08985e](https://github.com/thi-ng/umbrella/commit/e08985ee07a2bc449e4f2126191a96261ef6dfb0))
105
+ - add new iterators ([e08985e](https://github.com/thi-ng/umbrella/commit/e08985e))
106
+ - add columns, rows
107
+ - add columnEnds, diagonalEnds, rowEnds
84
108
 
85
- # [0.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/grid-iterators@0.2.3...@thi.ng/grid-iterators@0.3.0) (2020-02-25)
109
+ ## [0.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@0.3.0) (2020-02-25)
86
110
 
87
- ### Features
111
+ #### 🚀 Features
88
112
 
89
- - **grid-iterators:** add line & circle iterators ([a6b757d](https://github.com/thi-ng/umbrella/commit/a6b757dd350e46404bfd2f82e58d8a3bc2c5b133))
113
+ - add line & circle iterators ([a6b757d](https://github.com/thi-ng/umbrella/commit/a6b757d))
114
+ - add line(), hline(), vline()
115
+ - add circle()
90
116
 
91
- # [0.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/grid-iterators@0.1.0...@thi.ng/grid-iterators@0.2.0) (2019-11-09)
117
+ ## [0.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@0.2.0) (2019-11-09)
92
118
 
93
- ### Features
119
+ #### 🚀 Features
94
120
 
95
- - **grid-iterators:** add interleave fns ([c883ea0](https://github.com/thi-ng/umbrella/commit/c883ea03d9a37698533d981a96f7122828731364))
96
- - **grid-iterators:** add z-curve & random iterators, add deps ([ba8ed18](https://github.com/thi-ng/umbrella/commit/ba8ed18cd84db77ccb35ed95586c66151cf1d690))
97
- - **grid-iterators:** add zigzagDiagonal(), update readme, rename files ([5630055](https://github.com/thi-ng/umbrella/commit/56300557f395698f82b453c79956ada72726444a))
98
- - **grid-iterators:** make row args optional ([60dccfc](https://github.com/thi-ng/umbrella/commit/60dccfcb0ba1d731eeecd4c12433d44b5491e7a7))
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))
99
125
 
100
- # 0.1.0 (2019-09-21)
126
+ ## [0.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@0.1.0) (2019-09-21)
101
127
 
102
- ### Features
128
+ #### 🚀 Features
103
129
 
104
- - **grid-iterators:** import as new package, incl. assets ([fe4ee00](https://github.com/thi-ng/umbrella/commit/fe4ee00))
130
+ - import as new package, incl. assets ([fe4ee00](https://github.com/thi-ng/umbrella/commit/fe4ee00))
@@ -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
- "name": "@thi.ng/grid-iterators",
3
- "version": "2.1.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 && node_modules/.bin/api-extractor run --local --verbose",
32
- "doc:readme": "yarn doc:stats && ../../scripts/node-esm ../../tools/src/readme.ts",
33
- "doc:stats": "../../scripts/node-esm ../../tools/src/module-stats.ts",
34
- "pub": "yarn build && yarn publish --access public",
35
- "test": "testament test"
36
- },
37
- "dependencies": {
38
- "@thi.ng/api": "^8.2.0",
39
- "@thi.ng/arrays": "^2.0.8",
40
- "@thi.ng/binary": "^3.0.8",
41
- "@thi.ng/bitfield": "^2.0.8",
42
- "@thi.ng/morton": "^3.0.8",
43
- "@thi.ng/random": "^3.1.4",
44
- "@thi.ng/transducers": "^8.0.8"
45
- },
46
- "devDependencies": {
47
- "@thi.ng/testament": "^0.1.6"
48
- },
49
- "keywords": [
50
- "2d",
51
- "binary",
52
- "circle",
53
- "clipping",
54
- "diagonal",
55
- "floodfill",
56
- "grid",
57
- "hilbert",
58
- "iterator",
59
- "line",
60
- "morton",
61
- "random",
62
- "spiral",
63
- "typescript",
64
- "z-curve",
65
- "zigzag"
66
- ],
67
- "publishConfig": {
68
- "access": "public"
2
+ "name": "@thi.ng/grid-iterators",
3
+ "version": "2.2.3",
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.3",
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
- "engines": {
71
- "node": ">=12.7"
137
+ "./zigzag-diagonal": {
138
+ "import": "./zigzag-diagonal.js"
72
139
  },
73
- "files": [
74
- "*.js",
75
- "*.d.ts"
140
+ "./zigzag-rows": {
141
+ "import": "./zigzag-rows.js"
142
+ }
143
+ },
144
+ "thi.ng": {
145
+ "related": [
146
+ "morton",
147
+ "rasterize",
148
+ "transducers"
76
149
  ],
77
- "exports": {
78
- ".": {
79
- "import": "./index.js"
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": "5fe52419af63984ebe53032201b2a6174b9cb159"
148
- }
150
+ "year": 2019
151
+ },
152
+ "gitHead": "32cf1a96854f9bb97aca65ffa05ca862ea377059\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
+ });