@thi.ng/grid-iterators 2.2.3 → 2.2.6
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 +8 -1
- package/README.md +1 -1
- package/circle.d.ts +8 -8
- package/circle.js +8 -8
- package/clipping.d.ts +20 -20
- package/clipping.js +20 -20
- package/columns.d.ts +2 -2
- package/columns.js +2 -2
- package/flood-fill.d.ts +5 -5
- package/flood-fill.js +5 -5
- package/line.d.ts +8 -8
- package/line.js +9 -9
- package/package.json +13 -13
- package/rows.d.ts +2 -2
- package/rows.js +2 -2
- package/utils.d.ts +1 -1
- package/utils.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**:
|
|
3
|
+
- **Last updated**: 2022-03-11T12:13:49Z
|
|
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,13 @@ 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.2.4](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@2.2.4) (2021-12-13)
|
|
13
|
+
|
|
14
|
+
#### 🩹 Bug fixes
|
|
15
|
+
|
|
16
|
+
- off-by-one error in lineClipped() ([537b17a](https://github.com/thi-ng/umbrella/commit/537b17a))
|
|
17
|
+
- update right/bottom clip coords
|
|
18
|
+
|
|
12
19
|
## [2.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/grid-iterators@2.2.0) (2021-11-17)
|
|
13
20
|
|
|
14
21
|
#### 🚀 Features
|
package/README.md
CHANGED
package/circle.d.ts
CHANGED
|
@@ -4,14 +4,14 @@ export declare function circle(cx: number, cy: number, r: number, fill?: boolean
|
|
|
4
4
|
* `left,top`..`right,bottom`. Returns undefined if circle lies completely
|
|
5
5
|
* outside given clip rectangle.
|
|
6
6
|
*
|
|
7
|
-
* @param cx
|
|
8
|
-
* @param cy
|
|
9
|
-
* @param r
|
|
10
|
-
* @param left
|
|
11
|
-
* @param top
|
|
12
|
-
* @param right
|
|
13
|
-
* @param bottom
|
|
14
|
-
* @param fill
|
|
7
|
+
* @param cx -
|
|
8
|
+
* @param cy -
|
|
9
|
+
* @param r -
|
|
10
|
+
* @param left -
|
|
11
|
+
* @param top -
|
|
12
|
+
* @param right -
|
|
13
|
+
* @param bottom -
|
|
14
|
+
* @param fill -
|
|
15
15
|
*/
|
|
16
16
|
export declare const circleClipped: (cx: number, cy: number, r: number, left: number, top: number, right: number, bottom: number, fill?: boolean) => Generator<number[], void, unknown> | undefined;
|
|
17
17
|
//# sourceMappingURL=circle.d.ts.map
|
package/circle.js
CHANGED
|
@@ -57,14 +57,14 @@ export function* circle(cx, cy, r, fill = true) {
|
|
|
57
57
|
* `left,top`..`right,bottom`. Returns undefined if circle lies completely
|
|
58
58
|
* outside given clip rectangle.
|
|
59
59
|
*
|
|
60
|
-
* @param cx
|
|
61
|
-
* @param cy
|
|
62
|
-
* @param r
|
|
63
|
-
* @param left
|
|
64
|
-
* @param top
|
|
65
|
-
* @param right
|
|
66
|
-
* @param bottom
|
|
67
|
-
* @param fill
|
|
60
|
+
* @param cx -
|
|
61
|
+
* @param cy -
|
|
62
|
+
* @param r -
|
|
63
|
+
* @param left -
|
|
64
|
+
* @param top -
|
|
65
|
+
* @param right -
|
|
66
|
+
* @param bottom -
|
|
67
|
+
* @param fill -
|
|
68
68
|
*/
|
|
69
69
|
export const circleClipped = (cx, cy, r, left, top, right, bottom, fill = true) => {
|
|
70
70
|
return intersectRectCircle(left, top, right, bottom, cx, cy, r)
|
package/clipping.d.ts
CHANGED
|
@@ -3,23 +3,23 @@ import type { FnU7, FnU8, Tuple } from "@thi.ng/api";
|
|
|
3
3
|
* Filters points from `src` iterable to remove any falling outside the rect
|
|
4
4
|
* defined by `left,top`..`right,bottom`.
|
|
5
5
|
*
|
|
6
|
-
* @param src
|
|
7
|
-
* @param left
|
|
8
|
-
* @param top
|
|
9
|
-
* @param right
|
|
10
|
-
* @param bottom
|
|
6
|
+
* @param src -
|
|
7
|
+
* @param left -
|
|
8
|
+
* @param top -
|
|
9
|
+
* @param right -
|
|
10
|
+
* @param bottom -
|
|
11
11
|
*/
|
|
12
12
|
export declare function clipped(src: Iterable<number[]>, left: number, top: number, right: number, bottom: number): Generator<number[], void, unknown>;
|
|
13
13
|
/**
|
|
14
14
|
* Based on {@link @thi.ng/geom-isec}, but inlined to avoid dependency.
|
|
15
15
|
*
|
|
16
|
-
* @param x
|
|
17
|
-
* @param y
|
|
18
|
-
* @param w
|
|
19
|
-
* @param h
|
|
20
|
-
* @param cx
|
|
21
|
-
* @param cy
|
|
22
|
-
* @param r
|
|
16
|
+
* @param x -
|
|
17
|
+
* @param y -
|
|
18
|
+
* @param w -
|
|
19
|
+
* @param h -
|
|
20
|
+
* @param cx -
|
|
21
|
+
* @param cy -
|
|
22
|
+
* @param r -
|
|
23
23
|
*
|
|
24
24
|
* @internal
|
|
25
25
|
*/
|
|
@@ -27,14 +27,14 @@ export declare const intersectRectCircle: FnU7<number, boolean>;
|
|
|
27
27
|
/**
|
|
28
28
|
* Based on {@link @thi.ng/geom-clip-line#liangBarsky2Raw}, but with diff return type.
|
|
29
29
|
*
|
|
30
|
-
* @param ax
|
|
31
|
-
* @param ay
|
|
32
|
-
* @param bx
|
|
33
|
-
* @param by
|
|
34
|
-
* @param minx
|
|
35
|
-
* @param miny
|
|
36
|
-
* @param maxx
|
|
37
|
-
* @param maxy
|
|
30
|
+
* @param ax -
|
|
31
|
+
* @param ay -
|
|
32
|
+
* @param bx -
|
|
33
|
+
* @param by -
|
|
34
|
+
* @param minx -
|
|
35
|
+
* @param miny -
|
|
36
|
+
* @param maxx -
|
|
37
|
+
* @param maxy -
|
|
38
38
|
*
|
|
39
39
|
* @internal
|
|
40
40
|
*/
|
package/clipping.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Filters points from `src` iterable to remove any falling outside the rect
|
|
3
3
|
* defined by `left,top`..`right,bottom`.
|
|
4
4
|
*
|
|
5
|
-
* @param src
|
|
6
|
-
* @param left
|
|
7
|
-
* @param top
|
|
8
|
-
* @param right
|
|
9
|
-
* @param bottom
|
|
5
|
+
* @param src -
|
|
6
|
+
* @param left -
|
|
7
|
+
* @param top -
|
|
8
|
+
* @param right -
|
|
9
|
+
* @param bottom -
|
|
10
10
|
*/
|
|
11
11
|
export function* clipped(src, left, top, right, bottom) {
|
|
12
12
|
for (let p of src) {
|
|
@@ -19,13 +19,13 @@ const axis = (a, b, c) => (a < b ? a - b : a > b + c ? a - b - c : 0) ** 2;
|
|
|
19
19
|
/**
|
|
20
20
|
* Based on {@link @thi.ng/geom-isec}, but inlined to avoid dependency.
|
|
21
21
|
*
|
|
22
|
-
* @param x
|
|
23
|
-
* @param y
|
|
24
|
-
* @param w
|
|
25
|
-
* @param h
|
|
26
|
-
* @param cx
|
|
27
|
-
* @param cy
|
|
28
|
-
* @param r
|
|
22
|
+
* @param x -
|
|
23
|
+
* @param y -
|
|
24
|
+
* @param w -
|
|
25
|
+
* @param h -
|
|
26
|
+
* @param cx -
|
|
27
|
+
* @param cy -
|
|
28
|
+
* @param r -
|
|
29
29
|
*
|
|
30
30
|
* @internal
|
|
31
31
|
*/
|
|
@@ -33,14 +33,14 @@ export const intersectRectCircle = (x, y, w, h, cx, cy, r) => axis(cx, x, w) + a
|
|
|
33
33
|
/**
|
|
34
34
|
* Based on {@link @thi.ng/geom-clip-line#liangBarsky2Raw}, but with diff return type.
|
|
35
35
|
*
|
|
36
|
-
* @param ax
|
|
37
|
-
* @param ay
|
|
38
|
-
* @param bx
|
|
39
|
-
* @param by
|
|
40
|
-
* @param minx
|
|
41
|
-
* @param miny
|
|
42
|
-
* @param maxx
|
|
43
|
-
* @param maxy
|
|
36
|
+
* @param ax -
|
|
37
|
+
* @param ay -
|
|
38
|
+
* @param bx -
|
|
39
|
+
* @param by -
|
|
40
|
+
* @param minx -
|
|
41
|
+
* @param miny -
|
|
42
|
+
* @param maxx -
|
|
43
|
+
* @param maxy -
|
|
44
44
|
*
|
|
45
45
|
* @internal
|
|
46
46
|
*/
|
package/columns.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Yields sequence of 2D grid coordinates in column-major order.
|
|
3
3
|
*
|
|
4
|
-
* @param cols
|
|
5
|
-
* @param rows
|
|
4
|
+
* @param cols -
|
|
5
|
+
* @param rows -
|
|
6
6
|
*/
|
|
7
7
|
export declare const columns2d: (cols: number, rows?: number) => IterableIterator<number[]>;
|
|
8
8
|
//# sourceMappingURL=columns.d.ts.map
|
package/columns.js
CHANGED
|
@@ -4,7 +4,7 @@ import { swapxy } from "./utils.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Yields sequence of 2D grid coordinates in column-major order.
|
|
6
6
|
*
|
|
7
|
-
* @param cols
|
|
8
|
-
* @param rows
|
|
7
|
+
* @param cols -
|
|
8
|
+
* @param rows -
|
|
9
9
|
*/
|
|
10
10
|
export const columns2d = (cols, rows = cols) => map(swapxy, range2d(rows | 0, cols | 0));
|
package/flood-fill.d.ts
CHANGED
|
@@ -27,11 +27,11 @@ import type { Predicate2 } from "@thi.ng/api";
|
|
|
27
27
|
* // ]
|
|
28
28
|
* ```
|
|
29
29
|
*
|
|
30
|
-
* @param pred
|
|
31
|
-
* @param x
|
|
32
|
-
* @param y
|
|
33
|
-
* @param width
|
|
34
|
-
* @param height
|
|
30
|
+
* @param pred -
|
|
31
|
+
* @param x -
|
|
32
|
+
* @param y -
|
|
33
|
+
* @param width -
|
|
34
|
+
* @param height -
|
|
35
35
|
*/
|
|
36
36
|
export declare function floodFill(pred: Predicate2<number>, x: number, y: number, width: number, height: number): Generator<number[], void, unknown>;
|
|
37
37
|
//# sourceMappingURL=flood-fill.d.ts.map
|
package/flood-fill.js
CHANGED
|
@@ -27,11 +27,11 @@ import { defBitField } from "@thi.ng/bitfield/bitfield";
|
|
|
27
27
|
* // ]
|
|
28
28
|
* ```
|
|
29
29
|
*
|
|
30
|
-
* @param pred
|
|
31
|
-
* @param x
|
|
32
|
-
* @param y
|
|
33
|
-
* @param width
|
|
34
|
-
* @param height
|
|
30
|
+
* @param pred -
|
|
31
|
+
* @param x -
|
|
32
|
+
* @param y -
|
|
33
|
+
* @param width -
|
|
34
|
+
* @param height -
|
|
35
35
|
*/
|
|
36
36
|
export function* floodFill(pred, x, y, width, height) {
|
|
37
37
|
x |= 0;
|
package/line.d.ts
CHANGED
|
@@ -4,14 +4,14 @@ export declare function line(ax: number, ay: number, bx: number, by: number): Ge
|
|
|
4
4
|
* `left,top`..`right,bottom`. Returns undefined if circle lies completely
|
|
5
5
|
* outside given clip rectangle.
|
|
6
6
|
*
|
|
7
|
-
* @param x1
|
|
8
|
-
* @param y1
|
|
9
|
-
* @param x2
|
|
10
|
-
* @param y2
|
|
11
|
-
* @param left
|
|
12
|
-
* @param top
|
|
13
|
-
* @param right
|
|
14
|
-
* @param bottom
|
|
7
|
+
* @param x1 -
|
|
8
|
+
* @param y1 -
|
|
9
|
+
* @param x2 -
|
|
10
|
+
* @param y2 -
|
|
11
|
+
* @param left -
|
|
12
|
+
* @param top -
|
|
13
|
+
* @param right -
|
|
14
|
+
* @param bottom -
|
|
15
15
|
*/
|
|
16
16
|
export declare const lineClipped: (x1: number, y1: number, x2: number, y2: number, left: number, top: number, right: number, bottom: number) => Generator<number[], void, unknown> | undefined;
|
|
17
17
|
//# sourceMappingURL=line.d.ts.map
|
package/line.js
CHANGED
|
@@ -27,16 +27,16 @@ export function* line(ax, ay, bx, by) {
|
|
|
27
27
|
* `left,top`..`right,bottom`. Returns undefined if circle lies completely
|
|
28
28
|
* outside given clip rectangle.
|
|
29
29
|
*
|
|
30
|
-
* @param x1
|
|
31
|
-
* @param y1
|
|
32
|
-
* @param x2
|
|
33
|
-
* @param y2
|
|
34
|
-
* @param left
|
|
35
|
-
* @param top
|
|
36
|
-
* @param right
|
|
37
|
-
* @param bottom
|
|
30
|
+
* @param x1 -
|
|
31
|
+
* @param y1 -
|
|
32
|
+
* @param x2 -
|
|
33
|
+
* @param y2 -
|
|
34
|
+
* @param left -
|
|
35
|
+
* @param top -
|
|
36
|
+
* @param right -
|
|
37
|
+
* @param bottom -
|
|
38
38
|
*/
|
|
39
39
|
export const lineClipped = (x1, y1, x2, y2, left, top, right, bottom) => {
|
|
40
|
-
const res = liangBarsky(x1, y1, x2, y2, left, top, right, bottom);
|
|
40
|
+
const res = liangBarsky(x1, y1, x2, y2, left, top, right - 1, bottom - 1);
|
|
41
41
|
return res ? line(res[0], res[1], res[2], res[3]) : undefined;
|
|
42
42
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/grid-iterators",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"description": "2D grid and shape iterators w/ multiple orderings",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
"test": "testament test"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@thi.ng/api": "^8.3.
|
|
39
|
-
"@thi.ng/arrays": "^2.
|
|
40
|
-
"@thi.ng/binary": "^3.
|
|
41
|
-
"@thi.ng/bitfield": "^2.1.
|
|
42
|
-
"@thi.ng/morton": "^3.1.
|
|
43
|
-
"@thi.ng/random": "^3.2.
|
|
44
|
-
"@thi.ng/transducers": "^8.
|
|
38
|
+
"@thi.ng/api": "^8.3.4",
|
|
39
|
+
"@thi.ng/arrays": "^2.2.0",
|
|
40
|
+
"@thi.ng/binary": "^3.2.0",
|
|
41
|
+
"@thi.ng/bitfield": "^2.1.5",
|
|
42
|
+
"@thi.ng/morton": "^3.1.4",
|
|
43
|
+
"@thi.ng/random": "^3.2.4",
|
|
44
|
+
"@thi.ng/transducers": "^8.3.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@microsoft/api-extractor": "^7.
|
|
48
|
-
"@thi.ng/testament": "^0.2.
|
|
47
|
+
"@microsoft/api-extractor": "^7.19.4",
|
|
48
|
+
"@thi.ng/testament": "^0.2.4",
|
|
49
49
|
"rimraf": "^3.0.2",
|
|
50
50
|
"tools": "^0.0.1",
|
|
51
|
-
"typedoc": "^0.22.
|
|
52
|
-
"typescript": "^4.
|
|
51
|
+
"typedoc": "^0.22.13",
|
|
52
|
+
"typescript": "^4.6.2"
|
|
53
53
|
},
|
|
54
54
|
"keywords": [
|
|
55
55
|
"2d",
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
],
|
|
150
150
|
"year": 2019
|
|
151
151
|
},
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "0fc692a3225c068aacafdc4cb6140cf603c67ad8\n"
|
|
153
153
|
}
|
package/rows.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Yields sequence of 2D grid coordinates in row-major order. Same as
|
|
3
3
|
* {@link @thi.ng/transducers#range2d}.
|
|
4
4
|
*
|
|
5
|
-
* @param cols
|
|
6
|
-
* @param rows
|
|
5
|
+
* @param cols -
|
|
6
|
+
* @param rows -
|
|
7
7
|
*/
|
|
8
8
|
export declare const rows2d: (cols: number, rows?: number) => IterableIterator<[number, number]>;
|
|
9
9
|
//# sourceMappingURL=rows.d.ts.map
|
package/rows.js
CHANGED
|
@@ -3,7 +3,7 @@ import { range2d } from "@thi.ng/transducers/range2d";
|
|
|
3
3
|
* Yields sequence of 2D grid coordinates in row-major order. Same as
|
|
4
4
|
* {@link @thi.ng/transducers#range2d}.
|
|
5
5
|
*
|
|
6
|
-
* @param cols
|
|
7
|
-
* @param rows
|
|
6
|
+
* @param cols -
|
|
7
|
+
* @param rows -
|
|
8
8
|
*/
|
|
9
9
|
export const rows2d = (cols, rows = cols) => range2d(cols | 0, rows | 0);
|
package/utils.d.ts
CHANGED