@thi.ng/geom 5.0.7 → 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-08-04T10:58:19Z
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/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.7",
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",
@@ -398,5 +398,5 @@
398
398
  ],
399
399
  "year": 2013
400
400
  },
401
- "gitHead": "9fa3f7f8169efa30e3c71b43c82f77393581c3b5\n"
401
+ "gitHead": "888293c74f2e9a481d500d4ec319f1e2bd765ec6\n"
402
402
  }