@thi.ng/geom 6.0.7 → 6.0.8

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.
Files changed (104) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +1 -1
  3. package/aabb.js +31 -32
  4. package/api/aabb.js +34 -29
  5. package/api/apc.js +15 -13
  6. package/api/arc.js +82 -66
  7. package/api/bpatch.js +79 -96
  8. package/api/circle.js +21 -21
  9. package/api/cubic.js +28 -25
  10. package/api/ellipse.js +26 -21
  11. package/api/group.js +45 -47
  12. package/api/line.js +26 -27
  13. package/api/path.js +62 -58
  14. package/api/plane.js +21 -21
  15. package/api/points.js +30 -26
  16. package/api/polygon.js +19 -16
  17. package/api/polyline.js +25 -22
  18. package/api/quad.js +20 -17
  19. package/api/quad3.js +20 -17
  20. package/api/quadratic.js +28 -25
  21. package/api/ray.js +30 -26
  22. package/api/rect.js +34 -29
  23. package/api/sphere.js +21 -21
  24. package/api/text.js +21 -28
  25. package/api/triangle.js +20 -17
  26. package/apply-transforms.js +28 -48
  27. package/arc-length.js +17 -30
  28. package/arc.js +17 -6
  29. package/area.js +19 -45
  30. package/as-cubic.js +38 -57
  31. package/as-path.js +4 -8
  32. package/as-polygon.js +12 -29
  33. package/as-polyline.js +18 -38
  34. package/as-svg.js +32 -63
  35. package/bounds.js +46 -48
  36. package/bpatch.js +22 -14
  37. package/center.js +22 -17
  38. package/centroid.js +14 -34
  39. package/circle.js +11 -6
  40. package/classify-point.js +20 -27
  41. package/clip-convex.js +40 -39
  42. package/closest-point.js +28 -34
  43. package/convex-hull.js +12 -27
  44. package/cubic.js +13 -5
  45. package/edges.js +31 -60
  46. package/ellipse.js +5 -2
  47. package/fit-into-bounds.js +78 -61
  48. package/flip.js +24 -41
  49. package/group.js +4 -1
  50. package/internal/args.js +18 -51
  51. package/internal/bounds.js +23 -38
  52. package/internal/collate.js +33 -17
  53. package/internal/copy.js +12 -23
  54. package/internal/dispatch.js +6 -4
  55. package/internal/edges.js +4 -1
  56. package/internal/pclike.js +8 -4
  57. package/internal/points-as-shape.js +4 -3
  58. package/internal/rotate.js +6 -2
  59. package/internal/scale.js +8 -2
  60. package/internal/split.js +9 -6
  61. package/internal/transform.js +24 -12
  62. package/internal/translate.js +6 -2
  63. package/internal/vertices.js +15 -31
  64. package/intersects.js +15 -39
  65. package/line.js +11 -9
  66. package/map-point.js +10 -18
  67. package/offset.js +31 -29
  68. package/package.json +33 -30
  69. package/path-builder.js +152 -143
  70. package/path-from-svg.js +129 -131
  71. package/path.js +28 -25
  72. package/plane.js +10 -5
  73. package/point-at.js +12 -30
  74. package/point-inside.js +20 -25
  75. package/points.js +6 -2
  76. package/polygon.js +15 -47
  77. package/polyline.js +18 -22
  78. package/quad.js +23 -15
  79. package/quadratic.js +7 -3
  80. package/ray.js +4 -1
  81. package/rect.js +47 -46
  82. package/resample.js +12 -27
  83. package/rotate.js +30 -42
  84. package/scale.js +66 -64
  85. package/scatter.js +18 -30
  86. package/simplify.js +38 -55
  87. package/sphere.js +7 -3
  88. package/split-arclength.js +53 -108
  89. package/split-at.js +46 -26
  90. package/split-near.js +28 -22
  91. package/subdiv-curve.js +33 -72
  92. package/tangent-at.js +12 -24
  93. package/tessellate.js +22 -47
  94. package/text.js +4 -1
  95. package/transform-vertices.js +31 -55
  96. package/transform.js +31 -54
  97. package/translate.js +39 -46
  98. package/triangle.js +7 -3
  99. package/union.js +12 -15
  100. package/unmap-point.js +21 -25
  101. package/vertices.js +91 -113
  102. package/volume.js +10 -14
  103. package/warp-points.js +15 -25
  104. package/with-attribs.js +4 -11
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-12-09T19:12:03Z
3
+ - **Last updated**: 2023-12-11T10:07:09Z
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.
package/README.md CHANGED
@@ -200,7 +200,7 @@ For Node.js REPL:
200
200
  const geom = await import("@thi.ng/geom");
201
201
  ```
202
202
 
203
- Package sizes (brotli'd, pre-treeshake): ESM: 12.98 KB
203
+ Package sizes (brotli'd, pre-treeshake): ESM: 12.93 KB
204
204
 
205
205
  ## Dependencies
206
206
 
package/aabb.js CHANGED
@@ -8,38 +8,37 @@ import { sub3 } from "@thi.ng/vectors/sub";
8
8
  import { subN3 } from "@thi.ng/vectors/subn";
9
9
  import { AABB } from "./api/aabb.js";
10
10
  import { __argsVV } from "./internal/args.js";
11
- export function aabb(...args) {
12
- return new AABB(...__argsVV(args));
11
+ function aabb(...args) {
12
+ return new AABB(...__argsVV(args));
13
13
  }
14
- export const aabbFromMinMax = (min, max, attribs) => new AABB(min, sub3([], max, min), attribs);
15
- export const aabbFromMinMaxWithMargin = (min, max, margin, attribs) => aabbFromMinMax(min, max, attribs).offset(margin);
16
- export const aabbFromCentroid = (centroid, size, attribs) => new AABB(maddN3([], size, -0.5, centroid), size, attribs);
17
- export const aabbWithCentroidAndMargin = (centroid, size, margin, attribs) => aabbFromCentroid(centroid, size, attribs).offset(margin);
18
- /**
19
- * Returns the intersection AABB of given inputs or `undefined` if they
20
- * are non-overlapping.
21
- *
22
- * @param a -
23
- * @param b -
24
- */
25
- export const intersectionAABB = (a, b) => {
26
- const p = max3([], a.pos, b.pos);
27
- const q = min3(null, add3([], a.pos, a.size), add3([], b.pos, b.size));
28
- const size = max3(null, sub3(null, q, p), ZERO3);
29
- return size[0] > 0 && size[1] > 0 && size[2] > 0
30
- ? new AABB(p, size)
31
- : undefined;
14
+ const aabbFromMinMax = (min, max, attribs) => new AABB(min, sub3([], max, min), attribs);
15
+ const aabbFromMinMaxWithMargin = (min, max, margin, attribs) => aabbFromMinMax(min, max, attribs).offset(margin);
16
+ const aabbFromCentroid = (centroid, size, attribs) => new AABB(maddN3([], size, -0.5, centroid), size, attribs);
17
+ const aabbWithCentroidAndMargin = (centroid, size, margin, attribs) => aabbFromCentroid(centroid, size, attribs).offset(margin);
18
+ const intersectionAABB = (a, b) => {
19
+ const p = max3([], a.pos, b.pos);
20
+ const q = min3(null, add3([], a.pos, a.size), add3([], b.pos, b.size));
21
+ const size = max3(null, sub3(null, q, p), ZERO3);
22
+ return size[0] > 0 && size[1] > 0 && size[2] > 0 ? new AABB(p, size) : void 0;
32
23
  };
33
- export function inscribedAABB(...args) {
34
- let pos, r;
35
- if (args.length === 1) {
36
- const c = args[0];
37
- pos = c.pos;
38
- r = c.r;
39
- }
40
- else {
41
- [pos, r] = args;
42
- }
43
- r *= SQRT2_2;
44
- return aabb(subN3([], pos, r), r * 2);
24
+ function inscribedAABB(...args) {
25
+ let pos, r;
26
+ if (args.length === 1) {
27
+ const c = args[0];
28
+ pos = c.pos;
29
+ r = c.r;
30
+ } else {
31
+ [pos, r] = args;
32
+ }
33
+ r *= SQRT2_2;
34
+ return aabb(subN3([], pos, r), r * 2);
45
35
  }
36
+ export {
37
+ aabb,
38
+ aabbFromCentroid,
39
+ aabbFromMinMax,
40
+ aabbFromMinMaxWithMargin,
41
+ aabbWithCentroidAndMargin,
42
+ inscribedAABB,
43
+ intersectionAABB
44
+ };
package/api/aabb.js CHANGED
@@ -6,33 +6,38 @@ import { set3 } from "@thi.ng/vectors/set";
6
6
  import { subN3 } from "@thi.ng/vectors/subn";
7
7
  import { __asVec } from "../internal/args.js";
8
8
  import { __copyAttribs } from "../internal/copy.js";
9
- export class AABB {
10
- pos;
11
- attribs;
12
- size;
13
- constructor(pos = [0, 0, 0], size = 1, attribs) {
14
- this.pos = pos;
15
- this.attribs = attribs;
16
- this.size = __asVec(size, 3);
17
- }
18
- get type() {
19
- return "aabb";
20
- }
21
- copy() {
22
- return new AABB(set3([], this.pos), set3([], this.size), __copyAttribs(this));
23
- }
24
- withAttribs(attribs) {
25
- return new AABB(this.pos, this.size, attribs);
26
- }
27
- max() {
28
- return add3([], this.pos, this.size);
29
- }
30
- offset(offset) {
31
- subN3(null, this.pos, offset);
32
- max3(null, addN3(null, this.size, offset * 2), ZERO3);
33
- return this;
34
- }
35
- toHiccup() {
36
- return ["aabb", this.attribs, this.pos, this.size];
37
- }
9
+ class AABB {
10
+ constructor(pos = [0, 0, 0], size = 1, attribs) {
11
+ this.pos = pos;
12
+ this.attribs = attribs;
13
+ this.size = __asVec(size, 3);
14
+ }
15
+ size;
16
+ get type() {
17
+ return "aabb";
18
+ }
19
+ copy() {
20
+ return new AABB(
21
+ set3([], this.pos),
22
+ set3([], this.size),
23
+ __copyAttribs(this)
24
+ );
25
+ }
26
+ withAttribs(attribs) {
27
+ return new AABB(this.pos, this.size, attribs);
28
+ }
29
+ max() {
30
+ return add3([], this.pos, this.size);
31
+ }
32
+ offset(offset) {
33
+ subN3(null, this.pos, offset);
34
+ max3(null, addN3(null, this.size, offset * 2), ZERO3);
35
+ return this;
36
+ }
37
+ toHiccup() {
38
+ return ["aabb", this.attribs, this.pos, this.size];
39
+ }
38
40
  }
41
+ export {
42
+ AABB
43
+ };
package/api/apc.js CHANGED
@@ -1,15 +1,17 @@
1
1
  import { ensureArray } from "@thi.ng/arrays/ensure-array";
2
- export class APC {
3
- attribs;
4
- points;
5
- constructor(points, attribs) {
6
- this.attribs = attribs;
7
- this.points = points ? ensureArray(points) : [];
8
- }
9
- *[Symbol.iterator]() {
10
- yield* this.points;
11
- }
12
- clear() {
13
- this.points.length = 0;
14
- }
2
+ class APC {
3
+ constructor(points, attribs) {
4
+ this.attribs = attribs;
5
+ this.points = points ? ensureArray(points) : [];
6
+ }
7
+ points;
8
+ *[Symbol.iterator]() {
9
+ yield* this.points;
10
+ }
11
+ clear() {
12
+ this.points.length = 0;
13
+ }
15
14
  }
15
+ export {
16
+ APC
17
+ };
package/api/arc.js CHANGED
@@ -1,70 +1,86 @@
1
1
  import { equiv } from "@thi.ng/equiv";
2
- import { pointAt as arcPointAt, pointAtTheta as arcPointAtTheta, } from "@thi.ng/geom-arc/point-at";
2
+ import {
3
+ pointAt as arcPointAt,
4
+ pointAtTheta as arcPointAtTheta
5
+ } from "@thi.ng/geom-arc/point-at";
3
6
  import { set } from "@thi.ng/vectors/set";
4
7
  import { __copyAttribs } from "../internal/copy.js";
5
- export class Arc {
6
- pos;
7
- r;
8
- axis;
9
- start;
10
- end;
11
- xl;
12
- cw;
13
- attribs;
14
- constructor(pos, r, axis, start, end, xl = false, cw = false, attribs) {
15
- this.pos = pos;
16
- this.r = r;
17
- this.axis = axis;
18
- this.start = start;
19
- this.end = end;
20
- this.xl = xl;
21
- this.cw = cw;
22
- this.attribs = attribs;
23
- }
24
- get type() {
25
- return "arc";
26
- }
27
- copy() {
28
- return new Arc(set([], this.pos), set([], this.r), this.axis, this.start, this.end, this.xl, this.cw, __copyAttribs(this));
29
- }
30
- withAttribs(attribs) {
31
- return new Arc(this.pos, this.r, this.axis, this.start, this.end, this.xl, this.cw, attribs);
32
- }
33
- equiv(o) {
34
- return (o instanceof Arc &&
35
- equiv(this.pos, o.pos) &&
36
- equiv(this.r, o.r) &&
37
- this.start === o.start &&
38
- this.end === o.end &&
39
- this.axis === o.axis &&
40
- this.xl === o.xl &&
41
- this.cw &&
42
- o.cw);
43
- }
44
- pointAt(t, out = []) {
45
- return arcPointAt(this.pos, this.r, this.axis, this.start, this.end, t, out);
46
- }
47
- pointAtTheta(theta, out = []) {
48
- return arcPointAtTheta(this.pos, this.r, this.axis, theta, out);
49
- }
50
- toHiccup() {
51
- return [
52
- "path",
53
- this.attribs,
54
- [["M", this.pointAt(0)], ...this.toHiccupPathSegments()],
55
- ];
56
- }
57
- toHiccupPathSegments() {
58
- return [
59
- [
60
- "A",
61
- this.r[0],
62
- this.r[1],
63
- this.axis,
64
- this.xl,
65
- this.cw,
66
- this.pointAt(1),
67
- ],
68
- ];
69
- }
8
+ class Arc {
9
+ constructor(pos, r, axis, start, end, xl = false, cw = false, attribs) {
10
+ this.pos = pos;
11
+ this.r = r;
12
+ this.axis = axis;
13
+ this.start = start;
14
+ this.end = end;
15
+ this.xl = xl;
16
+ this.cw = cw;
17
+ this.attribs = attribs;
18
+ }
19
+ get type() {
20
+ return "arc";
21
+ }
22
+ copy() {
23
+ return new Arc(
24
+ set([], this.pos),
25
+ set([], this.r),
26
+ this.axis,
27
+ this.start,
28
+ this.end,
29
+ this.xl,
30
+ this.cw,
31
+ __copyAttribs(this)
32
+ );
33
+ }
34
+ withAttribs(attribs) {
35
+ return new Arc(
36
+ this.pos,
37
+ this.r,
38
+ this.axis,
39
+ this.start,
40
+ this.end,
41
+ this.xl,
42
+ this.cw,
43
+ attribs
44
+ );
45
+ }
46
+ equiv(o) {
47
+ return o instanceof Arc && equiv(this.pos, o.pos) && equiv(this.r, o.r) && this.start === o.start && this.end === o.end && this.axis === o.axis && this.xl === o.xl && this.cw && o.cw;
48
+ }
49
+ pointAt(t, out = []) {
50
+ return arcPointAt(
51
+ this.pos,
52
+ this.r,
53
+ this.axis,
54
+ this.start,
55
+ this.end,
56
+ t,
57
+ out
58
+ );
59
+ }
60
+ pointAtTheta(theta, out = []) {
61
+ return arcPointAtTheta(this.pos, this.r, this.axis, theta, out);
62
+ }
63
+ toHiccup() {
64
+ return [
65
+ "path",
66
+ this.attribs,
67
+ [["M", this.pointAt(0)], ...this.toHiccupPathSegments()]
68
+ ];
69
+ }
70
+ toHiccupPathSegments() {
71
+ return [
72
+ [
73
+ "A",
74
+ this.r[0],
75
+ this.r[1],
76
+ this.axis,
77
+ this.xl,
78
+ this.cw,
79
+ this.pointAt(1)
80
+ ]
81
+ ];
82
+ }
70
83
  }
84
+ export {
85
+ Arc
86
+ };
package/api/bpatch.js CHANGED
@@ -2,102 +2,85 @@ import { mixCubic } from "@thi.ng/vectors/mix-cubic";
2
2
  import { __copyShape } from "../internal/copy.js";
3
3
  import { __ensureNumVerts } from "../internal/pclike.js";
4
4
  import { APC } from "./apc.js";
5
- /**
6
- * nD Cubic bezier patch defined by array of 4x4 control points in this
7
- * order:
8
- *
9
- * ```
10
- * 7 11
11
- * 3 +---+---+---+ 15 (UV = 1,1)
12
- * | | | |
13
- * 2 +---+---+---+ 14
14
- * | | | |
15
- * 1 +---+---+---+ 13
16
- * v | | | |
17
- * ^ 0 +---+---+---+ 12
18
- * | 4 8
19
- * |
20
- * +----> u
21
- * ```
22
- *
23
- * The class implements a `unmapPoint()` method to transform a 2D UV coordinate
24
- * into the worldspace position on the patch surface.
25
- *
26
- * The `toHiccup()` impl is only suitable for 2D patches.
27
- *
28
- * Ported from toxiclibs.
29
- *
30
- */
31
- export class BPatch extends APC {
32
- constructor(points, attribs) {
33
- super(points, attribs);
34
- __ensureNumVerts(this.points.length, 16);
35
- }
36
- get type() {
37
- return "bpatch";
38
- }
39
- copy() {
40
- return __copyShape(BPatch, this);
41
- }
42
- withAttribs(attribs) {
43
- return new BPatch(this.points, attribs);
44
- }
45
- edges() {
46
- const p = this.points;
47
- return [
48
- [0, 1],
49
- [1, 2],
50
- [2, 3],
51
- [0, 4],
52
- [1, 5],
53
- [2, 6],
54
- [3, 7],
55
- [4, 5],
56
- [5, 6],
57
- [6, 7],
58
- [4, 8],
59
- [5, 9],
60
- [6, 10],
61
- [7, 11],
62
- [8, 9],
63
- [9, 10],
64
- [10, 11],
65
- [8, 12],
66
- [9, 13],
67
- [10, 14],
68
- [11, 15],
69
- [12, 13],
70
- [13, 14],
71
- [14, 15],
72
- ].map(([a, b]) => [p[a], p[b]]);
73
- }
74
- unmapPoint(uv, out) {
75
- const cp = this.points;
76
- const [u, v] = uv;
77
- return mixCubic(out || null, mixCubic([], cp[0], cp[4], cp[8], cp[12], v), mixCubic([], cp[1], cp[5], cp[9], cp[13], v), mixCubic([], cp[2], cp[6], cp[10], cp[14], v), mixCubic([], cp[3], cp[7], cp[11], cp[15], v), u);
78
- }
79
- toHiccup() {
80
- const attribs = this.attribs;
81
- const acc = ["g", { fill: "none", ...attribs }];
82
- if (attribs && attribs.res) {
83
- const res = attribs.res - 1;
84
- const delta = 1 / res;
85
- for (let u = 0; u <= res; u++) {
86
- const col = [];
87
- const row = [];
88
- const uu = u * delta;
89
- for (let v = 0; v <= res; v++) {
90
- const p = [uu, v * delta];
91
- col.push(this.unmapPoint(p));
92
- row.push(this.unmapPoint([p[1], p[0]]));
93
- }
94
- acc.push(["polyline", {}, col]);
95
- acc.push(["polyline", {}, row]);
96
- }
97
- }
98
- else {
99
- this.edges().forEach((l) => acc.push(["line", {}, ...l]));
5
+ class BPatch extends APC {
6
+ constructor(points, attribs) {
7
+ super(points, attribs);
8
+ __ensureNumVerts(this.points.length, 16);
9
+ }
10
+ get type() {
11
+ return "bpatch";
12
+ }
13
+ copy() {
14
+ return __copyShape(BPatch, this);
15
+ }
16
+ withAttribs(attribs) {
17
+ return new BPatch(this.points, attribs);
18
+ }
19
+ edges() {
20
+ const p = this.points;
21
+ return [
22
+ [0, 1],
23
+ [1, 2],
24
+ [2, 3],
25
+ [0, 4],
26
+ [1, 5],
27
+ [2, 6],
28
+ [3, 7],
29
+ [4, 5],
30
+ [5, 6],
31
+ [6, 7],
32
+ [4, 8],
33
+ [5, 9],
34
+ [6, 10],
35
+ [7, 11],
36
+ [8, 9],
37
+ [9, 10],
38
+ [10, 11],
39
+ [8, 12],
40
+ [9, 13],
41
+ [10, 14],
42
+ [11, 15],
43
+ [12, 13],
44
+ [13, 14],
45
+ [14, 15]
46
+ ].map(([a, b]) => [p[a], p[b]]);
47
+ }
48
+ unmapPoint(uv, out) {
49
+ const cp = this.points;
50
+ const [u, v] = uv;
51
+ return mixCubic(
52
+ out || null,
53
+ mixCubic([], cp[0], cp[4], cp[8], cp[12], v),
54
+ mixCubic([], cp[1], cp[5], cp[9], cp[13], v),
55
+ mixCubic([], cp[2], cp[6], cp[10], cp[14], v),
56
+ mixCubic([], cp[3], cp[7], cp[11], cp[15], v),
57
+ u
58
+ );
59
+ }
60
+ toHiccup() {
61
+ const attribs = this.attribs;
62
+ const acc = ["g", { fill: "none", ...attribs }];
63
+ if (attribs && attribs.res) {
64
+ const res = attribs.res - 1;
65
+ const delta = 1 / res;
66
+ for (let u = 0; u <= res; u++) {
67
+ const col = [];
68
+ const row = [];
69
+ const uu = u * delta;
70
+ for (let v = 0; v <= res; v++) {
71
+ const p = [uu, v * delta];
72
+ col.push(this.unmapPoint(p));
73
+ row.push(this.unmapPoint([p[1], p[0]]));
100
74
  }
101
- return acc;
75
+ acc.push(["polyline", {}, col]);
76
+ acc.push(["polyline", {}, row]);
77
+ }
78
+ } else {
79
+ this.edges().forEach((l) => acc.push(["line", {}, ...l]));
102
80
  }
81
+ return acc;
82
+ }
103
83
  }
84
+ export {
85
+ BPatch
86
+ };
package/api/circle.js CHANGED
@@ -1,24 +1,24 @@
1
1
  import { set } from "@thi.ng/vectors/set";
2
2
  import { __copyAttribs } from "../internal/copy.js";
3
- export class Circle {
4
- pos;
5
- r;
6
- attribs;
7
- constructor(pos = [0, 0], r = 1, attribs) {
8
- this.pos = pos;
9
- this.r = r;
10
- this.attribs = attribs;
11
- }
12
- get type() {
13
- return "circle";
14
- }
15
- copy() {
16
- return new Circle(set([], this.pos), this.r, __copyAttribs(this));
17
- }
18
- withAttribs(attribs) {
19
- return new Circle(this.pos, this.r, attribs);
20
- }
21
- toHiccup() {
22
- return ["circle", this.attribs, this.pos, this.r];
23
- }
3
+ class Circle {
4
+ constructor(pos = [0, 0], r = 1, attribs) {
5
+ this.pos = pos;
6
+ this.r = r;
7
+ this.attribs = attribs;
8
+ }
9
+ get type() {
10
+ return "circle";
11
+ }
12
+ copy() {
13
+ return new Circle(set([], this.pos), this.r, __copyAttribs(this));
14
+ }
15
+ withAttribs(attribs) {
16
+ return new Circle(this.pos, this.r, attribs);
17
+ }
18
+ toHiccup() {
19
+ return ["circle", this.attribs, this.pos, this.r];
20
+ }
24
21
  }
22
+ export {
23
+ Circle
24
+ };
package/api/cubic.js CHANGED
@@ -1,29 +1,32 @@
1
1
  import { __copyShape } from "../internal/copy.js";
2
2
  import { __ensureNumVerts } from "../internal/pclike.js";
3
3
  import { APC } from "./apc.js";
4
- export class Cubic extends APC {
5
- constructor(points, attribs) {
6
- super(points, attribs);
7
- __ensureNumVerts(this.points.length, 4);
8
- }
9
- get type() {
10
- return "cubic";
11
- }
12
- copy() {
13
- return __copyShape(Cubic, this);
14
- }
15
- withAttribs(attribs) {
16
- return new Cubic(this.points, attribs);
17
- }
18
- toHiccup() {
19
- return [
20
- "path",
21
- this.attribs,
22
- [["M", this.points[0]], ...this.toHiccupPathSegments()],
23
- ];
24
- }
25
- toHiccupPathSegments() {
26
- const pts = this.points;
27
- return [["C", pts[1], pts[2], pts[3]]];
28
- }
4
+ class Cubic extends APC {
5
+ constructor(points, attribs) {
6
+ super(points, attribs);
7
+ __ensureNumVerts(this.points.length, 4);
8
+ }
9
+ get type() {
10
+ return "cubic";
11
+ }
12
+ copy() {
13
+ return __copyShape(Cubic, this);
14
+ }
15
+ withAttribs(attribs) {
16
+ return new Cubic(this.points, attribs);
17
+ }
18
+ toHiccup() {
19
+ return [
20
+ "path",
21
+ this.attribs,
22
+ [["M", this.points[0]], ...this.toHiccupPathSegments()]
23
+ ];
24
+ }
25
+ toHiccupPathSegments() {
26
+ const pts = this.points;
27
+ return [["C", pts[1], pts[2], pts[3]]];
28
+ }
29
29
  }
30
+ export {
31
+ Cubic
32
+ };