@thi.ng/geom-fuzz 2.1.43 → 2.2.0

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,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2022-12-16T12:52:25Z
3
+ - **Last updated**: 2022-12-22T21:47:07Z
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.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-fuzz@2.2.0) (2022-12-22)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add hatch flip/mirror options ([f19c5d4](https://github.com/thi-ng/umbrella/commit/f19c5d4))
17
+ - add HatchOpts.tx point transform support ([c665406](https://github.com/thi-ng/umbrella/commit/c665406))
18
+
12
19
  ## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-fuzz@2.1.0) (2021-11-17)
13
20
 
14
21
  #### 🚀 Features
package/README.md CHANGED
@@ -21,7 +21,7 @@ This project is part of the
21
21
 
22
22
  ## About
23
23
 
24
- Highly configurable, fuzzy line & polygon creation with presets and composable fill & stroke styles. Canvas & SVG support
24
+ Highly configurable, fuzzy line & polygon creation with presets and composable fill & stroke styles. Canvas & SVG support. This is a support package for [@thi.ng/geom](https://github.com/thi-ng/umbrella/tree/develop/packages/geom).
25
25
 
26
26
  ![example output](https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/geom/geom-fuzz.png)
27
27
 
@@ -56,7 +56,7 @@ For Node.js REPL:
56
56
  const geomFuzz = await import("@thi.ng/geom-fuzz");
57
57
  ```
58
58
 
59
- Package sizes (brotli'd, pre-treeshake): ESM: 1.13 KB
59
+ Package sizes (brotli'd, pre-treeshake): ESM: 1.20 KB
60
60
 
61
61
  ## Dependencies
62
62
 
package/api.d.ts CHANGED
@@ -2,9 +2,11 @@ import type { Fn } from "@thi.ng/api";
2
2
  import type { IColor } from "@thi.ng/color";
3
3
  import type { Polygon } from "@thi.ng/geom";
4
4
  import type { IHiccupShape } from "@thi.ng/geom-api";
5
+ import type { PointTransform } from "@thi.ng/grid-iterators/api";
5
6
  export type Color = string | number[] | IColor;
6
7
  export type FillFn = Fn<Polygon, IHiccupShape>;
7
8
  export type HatchDir = "d" | "h" | "v";
9
+ export type FlipDir = "x" | "y" | "xy";
8
10
  export interface FuzzyPolygonOpts {
9
11
  num: number;
10
12
  jitter: number;
@@ -19,6 +21,14 @@ export interface FuzzyLineOpts {
19
21
  }
20
22
  export interface HatchOpts {
21
23
  dir: HatchDir;
24
+ /**
25
+ * Optional transform fn for generated grid points. If given,
26
+ * {@link HatchOpts.flip} will be ignored. See
27
+ * [`PointTransform`](https://docs.thi.ng/umbrella/grid-iterators/types/PointTransform.html)
28
+ * for more details.
29
+ */
30
+ tx?: PointTransform;
31
+ flip?: FlipDir;
22
32
  space: number;
23
33
  line: Partial<FuzzyLineOpts>;
24
34
  }
package/hatch.js CHANGED
@@ -7,6 +7,7 @@ import { unmapPoint } from "@thi.ng/geom/unmap-point";
7
7
  import { columnEnds2d } from "@thi.ng/grid-iterators/column-ends";
8
8
  import { diagonalEnds2d } from "@thi.ng/grid-iterators/diagonal-ends";
9
9
  import { rowEnds2d } from "@thi.ng/grid-iterators/row-ends";
10
+ import { flipX, flipXY, flipY, ident } from "@thi.ng/grid-iterators/transforms";
10
11
  import { partition } from "@thi.ng/transducers/partition";
11
12
  import { div2 } from "@thi.ng/vectors/div";
12
13
  import { DEFAULT_LINE } from "./api.js";
@@ -30,7 +31,15 @@ export const defHatch = (opts = {}) => {
30
31
  const rows = ~~(h / opts.space);
31
32
  const maxg = [cols - 1, rows - 1];
32
33
  const acc = group(opts.line ? opts.line.attribs : null);
33
- for (let [a, b] of partition(2, HATCH_DIRS[opts.dir](cols, rows))) {
34
+ const grid = HATCH_DIRS[opts.dir]({
35
+ cols,
36
+ rows,
37
+ tx: opts.tx ||
38
+ (opts.flip
39
+ ? { x: flipX, y: flipY, xy: flipXY }[opts.flip]
40
+ : ident),
41
+ });
42
+ for (let [a, b] of partition(2, grid)) {
34
43
  unmapPoint(box, div2(null, a, maxg), a);
35
44
  unmapPoint(box, div2(null, b, maxg), b);
36
45
  const segments = clipLinePoly(a, b, shape.points);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/geom-fuzz",
3
- "version": "2.1.43",
3
+ "version": "2.2.0",
4
4
  "description": "Highly configurable, fuzzy line & polygon creation with presets and composable fill & stroke styles. Canvas & SVG support",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -34,20 +34,20 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.6.1",
38
- "@thi.ng/associative": "^6.2.20",
39
- "@thi.ng/color": "^5.2.14",
40
- "@thi.ng/geom": "^4.0.2",
41
- "@thi.ng/geom-api": "^3.3.22",
42
- "@thi.ng/geom-clip-line": "^2.2.2",
43
- "@thi.ng/geom-resample": "^2.1.40",
44
- "@thi.ng/grid-iterators": "^2.3.26",
45
- "@thi.ng/transducers": "^8.3.27",
46
- "@thi.ng/vectors": "^7.5.28"
37
+ "@thi.ng/api": "^8.6.2",
38
+ "@thi.ng/associative": "^6.2.21",
39
+ "@thi.ng/color": "^5.2.15",
40
+ "@thi.ng/geom": "^4.1.0",
41
+ "@thi.ng/geom-api": "^3.3.23",
42
+ "@thi.ng/geom-clip-line": "^2.2.3",
43
+ "@thi.ng/geom-resample": "^2.1.41",
44
+ "@thi.ng/grid-iterators": "^3.0.0",
45
+ "@thi.ng/transducers": "^8.3.28",
46
+ "@thi.ng/vectors": "^7.5.29"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@microsoft/api-extractor": "^7.33.7",
50
- "@thi.ng/testament": "^0.3.7",
50
+ "@thi.ng/testament": "^0.3.8",
51
51
  "rimraf": "^3.0.2",
52
52
  "tools": "^0.0.1",
53
53
  "typedoc": "^0.23.22",
@@ -120,5 +120,5 @@
120
120
  ],
121
121
  "year": 2020
122
122
  },
123
- "gitHead": "7b2af448da8a63fb21704a79cc4cdf1f3d7d7a64\n"
123
+ "gitHead": "bc6f7f5e2765bb96fe64db804eaf4b2443b47fc6\n"
124
124
  }