@thi.ng/geom 5.0.6 → 5.1.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**: 2023-06-14T07:58:51Z
3
+ - **Last updated**: 2023-08-06T09:21:31Z
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,15 @@ 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
+ ## [5.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom@5.1.0) (2023-08-06)
13
+
14
+ #### 🚀 Features
15
+
16
+ - update API for various shape types ([3a45c5f](https://github.com/thi-ng/umbrella/commit/3a45c5f))
17
+ - add IClear impls for APC, Group, Path
18
+ - add .add() methods for APC, Group, Polygon, Polyline
19
+ - update Path.add() to accept multiple args
20
+
12
21
  # [5.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom@5.0.0) (2023-04-08)
13
22
 
14
23
  #### 🛑 Breaking changes
package/README.md CHANGED
@@ -199,7 +199,7 @@ For Node.js REPL:
199
199
  const geom = await import("@thi.ng/geom");
200
200
  ```
201
201
 
202
- Package sizes (brotli'd, pre-treeshake): ESM: 12.71 KB
202
+ Package sizes (brotli'd, pre-treeshake): ESM: 12.66 KB
203
203
 
204
204
  ## Dependencies
205
205
 
@@ -241,6 +241,7 @@ A selection:
241
241
 
242
242
  | Screenshot | Description | Live demo | Source |
243
243
  |:-----------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:------------------------------------------------------------|:-----------------------------------------------------------------------------------------|
244
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/fiber-basics.png" width="240"/> | Fiber-based cooperative multitasking basics | [Demo](https://demo.thi.ng/umbrella/fiber-basics/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/fiber-basics) |
244
245
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/geom-convex-hull.png" width="240"/> | Convex hull & shape clipping of 2D polygons | [Demo](https://demo.thi.ng/umbrella/geom-convex-hull/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/geom-convex-hull) |
245
246
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/geom/geom-fuzz.png" width="240"/> | geom-fuzz basic shape & fill examples | [Demo](https://demo.thi.ng/umbrella/geom-fuzz-basics/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/geom-fuzz-basics) |
246
247
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/geom/tessel.png" width="240"/> | Animated, recursive polygon tessellations | [Demo](https://demo.thi.ng/umbrella/geom-tessel/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/geom-tessel) |
package/api/apc.d.ts CHANGED
@@ -1,6 +1,7 @@
1
+ import type { IClear } from "@thi.ng/api";
1
2
  import type { Attribs, PCLike } from "@thi.ng/geom-api";
2
3
  import type { Vec } from "@thi.ng/vectors";
3
- export declare abstract class APC implements PCLike {
4
+ export declare abstract class APC implements IClear, PCLike {
4
5
  points: Vec[];
5
6
  attribs?: Attribs | undefined;
6
7
  constructor(points?: Vec[], attribs?: Attribs | undefined);
@@ -8,5 +9,6 @@ export declare abstract class APC implements PCLike {
8
9
  abstract copy(): APC;
9
10
  abstract withAttribs(attribs: Attribs): APC;
10
11
  [Symbol.iterator](): Generator<Vec, void, undefined>;
12
+ clear(): void;
11
13
  }
12
14
  //# sourceMappingURL=apc.d.ts.map
package/api/apc.js CHANGED
@@ -6,4 +6,7 @@ export class APC {
6
6
  *[Symbol.iterator]() {
7
7
  yield* this.points;
8
8
  }
9
+ clear() {
10
+ this.points.length = 0;
11
+ }
9
12
  }
package/api/group.d.ts CHANGED
@@ -1,11 +1,25 @@
1
- import type { Fn } from "@thi.ng/api";
1
+ import type { Fn, IClear } from "@thi.ng/api";
2
2
  import type { Attribs, IHiccupShape } from "@thi.ng/geom-api";
3
- export declare class Group implements IHiccupShape {
3
+ /**
4
+ * Geometry/shape group container for other {@link IHiccupShape}s, incl. nested
5
+ * groups.
6
+ */
7
+ export declare class Group implements IClear, IHiccupShape {
4
8
  attribs?: Attribs | undefined;
5
9
  children: IHiccupShape[];
6
10
  constructor(attribs?: Attribs | undefined, children?: IHiccupShape[]);
7
11
  get type(): string;
8
12
  [Symbol.iterator](): Generator<IHiccupShape, void, undefined>;
13
+ /**
14
+ * Appends given `shapes` to this {@link Group.children} array.
15
+ *
16
+ * @param shapes
17
+ */
18
+ add(...shapes: IHiccupShape[]): this;
19
+ /**
20
+ * Removes all children from the group.
21
+ */
22
+ clear(): void;
9
23
  copy(): Group;
10
24
  copyTransformed(fn: Fn<IHiccupShape, IHiccupShape>): Group;
11
25
  withAttribs(attribs: Attribs): Group;
package/api/group.js CHANGED
@@ -1,5 +1,9 @@
1
1
  import { equiv } from "@thi.ng/equiv";
2
2
  import { __copyAttribs } from "../internal/copy.js";
3
+ /**
4
+ * Geometry/shape group container for other {@link IHiccupShape}s, incl. nested
5
+ * groups.
6
+ */
3
7
  export class Group {
4
8
  constructor(attribs, children = []) {
5
9
  this.attribs = attribs;
@@ -11,6 +15,21 @@ export class Group {
11
15
  *[Symbol.iterator]() {
12
16
  yield* this.children;
13
17
  }
18
+ /**
19
+ * Appends given `shapes` to this {@link Group.children} array.
20
+ *
21
+ * @param shapes
22
+ */
23
+ add(...shapes) {
24
+ this.children.push(...shapes);
25
+ return this;
26
+ }
27
+ /**
28
+ * Removes all children from the group.
29
+ */
30
+ clear() {
31
+ this.children.length = 0;
32
+ }
14
33
  copy() {
15
34
  return this.copyTransformed((c) => c.copy());
16
35
  }
package/api/path.d.ts CHANGED
@@ -1,15 +1,17 @@
1
+ import type { IClear } from "@thi.ng/api";
1
2
  import type { Attribs, IHiccupShape, PathSegment } from "@thi.ng/geom-api";
2
- export declare class Path implements IHiccupShape {
3
+ export declare class Path implements IClear, IHiccupShape {
3
4
  segments: PathSegment[];
4
5
  attribs?: Attribs | undefined;
5
6
  closed: boolean;
6
7
  constructor(segments?: PathSegment[], attribs?: Attribs | undefined);
7
8
  get type(): string;
8
9
  [Symbol.iterator](): Generator<PathSegment, void, undefined>;
10
+ clear(): void;
9
11
  copy(): Path;
10
12
  withAttribs(attribs: Attribs): Path;
11
13
  equiv(o: any): boolean;
12
- add(s: PathSegment): void;
14
+ add(...segments: PathSegment[]): void;
13
15
  toHiccup(): (string | any[] | Attribs)[];
14
16
  }
15
17
  //# sourceMappingURL=path.d.ts.map
package/api/path.js CHANGED
@@ -14,6 +14,9 @@ export class Path {
14
14
  *[Symbol.iterator]() {
15
15
  yield* this.segments;
16
16
  }
17
+ clear() {
18
+ this.segments.length = 0;
19
+ }
17
20
  copy() {
18
21
  const p = new Path(this.segments.map((s) => {
19
22
  const d = { type: s.type };
@@ -32,10 +35,10 @@ export class Path {
32
35
  equiv(o) {
33
36
  return o instanceof Path && equiv(this.segments, o.segments);
34
37
  }
35
- add(s) {
38
+ add(...segments) {
36
39
  if (this.closed)
37
40
  illegalState("path already closed");
38
- this.segments.push(s);
41
+ this.segments.push(...segments);
39
42
  }
40
43
  toHiccup() {
41
44
  let dest = [];
package/api/polygon.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import type { Attribs, IHiccupShape } from "@thi.ng/geom-api";
2
+ import type { Vec } from "@thi.ng/vectors";
2
3
  import { APC } from "./apc.js";
3
4
  export declare class Polygon extends APC implements IHiccupShape {
4
5
  get type(): string;
6
+ add(...points: Vec[]): void;
5
7
  copy(): Polygon;
6
8
  withAttribs(attribs: Attribs): Polygon;
7
- toHiccup(): (string | import("@thi.ng/vectors").Vec[] | Attribs | undefined)[];
9
+ toHiccup(): (string | Vec[] | Attribs | undefined)[];
8
10
  }
9
11
  //# sourceMappingURL=polygon.d.ts.map
package/api/polygon.js CHANGED
@@ -4,6 +4,9 @@ export class Polygon extends APC {
4
4
  get type() {
5
5
  return "poly";
6
6
  }
7
+ add(...points) {
8
+ this.points.push(...points);
9
+ }
7
10
  copy() {
8
11
  return __copyShape(Polygon, this);
9
12
  }
package/api/polyline.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import type { Attribs, IHiccupPathSegment, IHiccupShape } from "@thi.ng/geom-api";
2
+ import type { Vec } from "@thi.ng/vectors";
2
3
  import { APC } from "./apc.js";
3
4
  export declare class Polyline extends APC implements IHiccupShape, IHiccupPathSegment {
4
5
  get type(): string;
6
+ add(...points: Vec[]): void;
5
7
  copy(): Polyline;
6
8
  withAttribs(attribs: Attribs): Polyline;
7
- toHiccup(): (string | import("@thi.ng/vectors").Vec[] | {
9
+ toHiccup(): (string | Vec[] | {
8
10
  fill: string;
9
11
  })[];
10
12
  toHiccupPathSegments(): any[];
package/api/polyline.js CHANGED
@@ -4,6 +4,9 @@ export class Polyline extends APC {
4
4
  get type() {
5
5
  return "polyline";
6
6
  }
7
+ add(...points) {
8
+ this.points.push(...points);
9
+ }
7
10
  copy() {
8
11
  return __copyShape(Polyline, this);
9
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/geom",
3
- "version": "5.0.6",
3
+ "version": "5.1.0",
4
4
  "description": "Functional, polymorphic API for 2D geometry types & SVG generation",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -35,41 +35,41 @@
35
35
  "tool:bpatch": "tools:node-esm tools/bpatch.ts"
36
36
  },
37
37
  "dependencies": {
38
- "@thi.ng/api": "^8.8.2",
39
- "@thi.ng/arrays": "^2.5.14",
40
- "@thi.ng/associative": "^6.2.39",
41
- "@thi.ng/checks": "^3.3.14",
42
- "@thi.ng/defmulti": "^2.1.38",
43
- "@thi.ng/equiv": "^2.1.24",
44
- "@thi.ng/errors": "^2.2.17",
45
- "@thi.ng/geom-api": "^3.4.19",
46
- "@thi.ng/geom-arc": "^2.1.62",
47
- "@thi.ng/geom-clip-line": "^2.3.19",
48
- "@thi.ng/geom-clip-poly": "^2.1.61",
49
- "@thi.ng/geom-closest-point": "^2.1.57",
50
- "@thi.ng/geom-hull": "^2.1.57",
51
- "@thi.ng/geom-isec": "^2.1.61",
52
- "@thi.ng/geom-poly-utils": "^2.3.45",
53
- "@thi.ng/geom-resample": "^2.2.19",
54
- "@thi.ng/geom-splines": "^2.2.36",
55
- "@thi.ng/geom-subdiv-curve": "^2.1.61",
56
- "@thi.ng/geom-tessellate": "^2.1.61",
57
- "@thi.ng/hiccup": "^4.2.42",
58
- "@thi.ng/hiccup-svg": "^5.0.6",
59
- "@thi.ng/math": "^5.5.0",
60
- "@thi.ng/matrices": "^2.1.58",
61
- "@thi.ng/random": "^3.5.0",
62
- "@thi.ng/strings": "^3.4.7",
63
- "@thi.ng/transducers": "^8.4.7",
64
- "@thi.ng/vectors": "^7.7.1"
38
+ "@thi.ng/api": "^8.9.0",
39
+ "@thi.ng/arrays": "^2.5.15",
40
+ "@thi.ng/associative": "^6.2.40",
41
+ "@thi.ng/checks": "^3.4.0",
42
+ "@thi.ng/defmulti": "^2.1.39",
43
+ "@thi.ng/equiv": "^2.1.25",
44
+ "@thi.ng/errors": "^2.3.0",
45
+ "@thi.ng/geom-api": "^3.4.20",
46
+ "@thi.ng/geom-arc": "^2.1.63",
47
+ "@thi.ng/geom-clip-line": "^2.3.20",
48
+ "@thi.ng/geom-clip-poly": "^2.1.62",
49
+ "@thi.ng/geom-closest-point": "^2.1.58",
50
+ "@thi.ng/geom-hull": "^2.1.58",
51
+ "@thi.ng/geom-isec": "^2.1.62",
52
+ "@thi.ng/geom-poly-utils": "^2.3.46",
53
+ "@thi.ng/geom-resample": "^2.2.20",
54
+ "@thi.ng/geom-splines": "^2.2.37",
55
+ "@thi.ng/geom-subdiv-curve": "^2.1.62",
56
+ "@thi.ng/geom-tessellate": "^2.1.62",
57
+ "@thi.ng/hiccup": "^4.2.43",
58
+ "@thi.ng/hiccup-svg": "^5.0.7",
59
+ "@thi.ng/math": "^5.5.1",
60
+ "@thi.ng/matrices": "^2.1.59",
61
+ "@thi.ng/random": "^3.5.1",
62
+ "@thi.ng/strings": "^3.4.8",
63
+ "@thi.ng/transducers": "^8.5.0",
64
+ "@thi.ng/vectors": "^7.7.2"
65
65
  },
66
66
  "devDependencies": {
67
- "@microsoft/api-extractor": "^7.35.3",
68
- "@thi.ng/testament": "^0.3.17",
67
+ "@microsoft/api-extractor": "^7.36.3",
68
+ "@thi.ng/testament": "^0.3.18",
69
69
  "rimraf": "^5.0.1",
70
70
  "tools": "^0.0.1",
71
71
  "typedoc": "^0.24.8",
72
- "typescript": "^5.1.3"
72
+ "typescript": "^5.1.6"
73
73
  },
74
74
  "keywords": [
75
75
  "2d",
@@ -398,5 +398,5 @@
398
398
  ],
399
399
  "year": 2013
400
400
  },
401
- "gitHead": "88cfe77770f3b07c788301dccefcb9547cd4aff6\n"
401
+ "gitHead": "888293c74f2e9a481d500d4ec319f1e2bd765ec6\n"
402
402
  }