modern-path2d 0.1.7 → 0.1.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.
package/dist/index.mjs CHANGED
@@ -1,35 +1,35 @@
1
- class Point2D {
1
+ class Vector2 {
2
2
  constructor(x = 0, y = 0) {
3
3
  this.x = x;
4
4
  this.y = y;
5
5
  }
6
6
  static get MAX() {
7
- return new Point2D(Infinity, Infinity);
7
+ return new Vector2(Infinity, Infinity);
8
8
  }
9
9
  static get MIN() {
10
- return new Point2D(-Infinity, -Infinity);
10
+ return new Vector2(-Infinity, -Infinity);
11
11
  }
12
12
  set(x, y) {
13
13
  this.x = x;
14
14
  this.y = y;
15
15
  return this;
16
16
  }
17
- add(point) {
18
- this.x += point.x;
19
- this.y += point.y;
17
+ add(vec) {
18
+ this.x += vec.x;
19
+ this.y += vec.y;
20
20
  return this;
21
21
  }
22
- sub(point) {
23
- this.x -= point.x;
24
- this.y -= point.y;
22
+ sub(vec) {
23
+ this.x -= vec.x;
24
+ this.y -= vec.y;
25
25
  return this;
26
26
  }
27
- distanceTo(point) {
28
- return Math.sqrt(this.distanceToSquared(point));
27
+ distanceTo(vec) {
28
+ return Math.sqrt(this.distanceToSquared(vec));
29
29
  }
30
- distanceToSquared(point) {
31
- const dx = this.x - point.x;
32
- const dy = this.y - point.y;
30
+ distanceToSquared(vec) {
31
+ const dx = this.x - vec.x;
32
+ const dy = this.y - vec.y;
33
33
  return dx * dx + dy * dy;
34
34
  }
35
35
  length() {
@@ -56,8 +56,8 @@ class Point2D {
56
56
  this.y = v1.y + (v2.y - v1.y) * alpha;
57
57
  return this;
58
58
  }
59
- equals(point) {
60
- return this.x === point.x && this.y === point.y;
59
+ equals(vec) {
60
+ return this.x === vec.x && this.y === vec.y;
61
61
  }
62
62
  applyMatrix3(m) {
63
63
  const x = this.x;
@@ -67,13 +67,13 @@ class Point2D {
67
67
  this.y = e[1] * x + e[4] * y + e[7];
68
68
  return this;
69
69
  }
70
- copy(point) {
71
- this.x = point.x;
72
- this.y = point.y;
70
+ copy(vec) {
71
+ this.x = vec.x;
72
+ this.y = vec.y;
73
73
  return this;
74
74
  }
75
75
  clone() {
76
- return new Point2D(this.x, this.y);
76
+ return new Vector2(this.x, this.y);
77
77
  }
78
78
  }
79
79
 
@@ -127,7 +127,7 @@ class BoundingBox {
127
127
  return this;
128
128
  }
129
129
  getCenterPoint() {
130
- return new Point2D((this.left + this.right) / 2, (this.top + this.bottom) / 2);
130
+ return new Vector2((this.left + this.right) / 2, (this.top + this.bottom) / 2);
131
131
  }
132
132
  clone() {
133
133
  return new BoundingBox(this.left, this.top, this.width, this.height);
@@ -389,9 +389,9 @@ function getReflection(a, b) {
389
389
  return a - (b - a);
390
390
  }
391
391
  function addPathCommandsToPath2D(commands, path) {
392
- const point = new Point2D();
393
- const control = new Point2D();
394
- const firstPoint = new Point2D();
392
+ const point = new Vector2();
393
+ const control = new Vector2();
394
+ const firstPoint = new Vector2();
395
395
  let isFirstPoint = true;
396
396
  let doSetFirstPoint = false;
397
397
  for (let i = 0, l = commands.length; i < l; i++) {
@@ -918,7 +918,7 @@ class Curve {
918
918
  __publicField$5(this, "_cacheArcLengths");
919
919
  __publicField$5(this, "_needsUpdate", false);
920
920
  }
921
- getPointAt(u, output = new Point2D()) {
921
+ getPointAt(u, output = new Vector2()) {
922
922
  return this.getPoint(this.getUtoTmapping(u), output);
923
923
  }
924
924
  getPoints(divisions = 5) {
@@ -997,30 +997,28 @@ class Curve {
997
997
  const segmentFraction = (targetArcLength - lengthBefore) / segmentLength;
998
998
  return (i + segmentFraction) / (il - 1);
999
999
  }
1000
- getTangent(t, output = new Point2D()) {
1000
+ getTangent(t, output = new Vector2()) {
1001
1001
  const delta = 1e-4;
1002
- let t1 = t - delta;
1003
- let t2 = t + delta;
1004
- if (t1 < 0)
1005
- t1 = 0;
1006
- if (t2 > 1)
1007
- t2 = 1;
1008
- return output.copy(this.getPoint(t2)).sub(this.getPoint(t1)).normalize();
1009
- }
1010
- getTangentAt(u, output = new Point2D()) {
1002
+ const t1 = Math.max(0, t - delta);
1003
+ const t2 = Math.min(1, t + delta);
1004
+ return output.copy(this.getPoint(t2).sub(this.getPoint(t1)).normalize());
1005
+ }
1006
+ getTangentAt(u, output) {
1011
1007
  return this.getTangent(this.getUtoTmapping(u), output);
1012
1008
  }
1013
1009
  /** overrideable */
1014
1010
  // eslint-disable-next-line unused-imports/no-unused-vars
1011
+ transformPoint(cb) {
1012
+ return this;
1013
+ }
1015
1014
  transform(matrix) {
1015
+ this.transformPoint((point) => point.applyMatrix3(matrix));
1016
1016
  return this;
1017
1017
  }
1018
- /** overrideable */
1019
1018
  getDivisions(divisions) {
1020
1019
  return divisions;
1021
1020
  }
1022
- /** overrideable */
1023
- getMinMax(min = Point2D.MAX, max = Point2D.MIN) {
1021
+ getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
1024
1022
  this.getPoints().forEach((point) => {
1025
1023
  min.x = Math.min(min.x, point.x);
1026
1024
  min.y = Math.min(min.y, point.y);
@@ -1033,9 +1031,14 @@ class Curve {
1033
1031
  const { min, max } = this.getMinMax();
1034
1032
  return new BoundingBox(min.x, min.y, max.x - min.x, max.y - min.y);
1035
1033
  }
1036
- /** overrideable */
1037
1034
  getCommands() {
1038
- return [];
1035
+ return this.getPoints().map((point, i) => {
1036
+ if (i === 0) {
1037
+ return { type: "M", x: point.x, y: point.y };
1038
+ } else {
1039
+ return { type: "L", x: point.x, y: point.y };
1040
+ }
1041
+ });
1039
1042
  }
1040
1043
  getData() {
1041
1044
  return pathCommandsToPathData(this.getCommands());
@@ -1068,14 +1071,18 @@ class CircleCurve extends Curve {
1068
1071
  }
1069
1072
  getTangent(t) {
1070
1073
  const { x, y } = this.getNormal(t);
1071
- return new Point2D(-y, x);
1074
+ return new Vector2(-y, x);
1072
1075
  }
1073
1076
  getNormal(t) {
1074
1077
  const { start, end } = this;
1075
1078
  const _t = t * (end - start) + start - 0.5 * Math.PI;
1076
- return new Point2D(Math.cos(_t), Math.sin(_t));
1079
+ return new Vector2(Math.cos(_t), Math.sin(_t));
1080
+ }
1081
+ transformPoint(cb) {
1082
+ cb(this.center);
1083
+ return this;
1077
1084
  }
1078
- getMinMax(min = Point2D.MAX, max = Point2D.MIN) {
1085
+ getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
1079
1086
  min.x = Math.min(min.x, this.center.x - this.radius);
1080
1087
  min.y = Math.min(min.y, this.center.y - this.radius);
1081
1088
  max.x = Math.max(max.x, this.center.x + this.radius);
@@ -1123,54 +1130,54 @@ function cubicBezier(t, p0, p1, p2, p3) {
1123
1130
  }
1124
1131
 
1125
1132
  class CubicBezierCurve extends Curve {
1126
- constructor(v0 = new Point2D(), v1 = new Point2D(), v2 = new Point2D(), v3 = new Point2D()) {
1133
+ constructor(start = new Vector2(), startControl = new Vector2(), endControl = new Vector2(), end = new Vector2()) {
1127
1134
  super();
1128
- this.v0 = v0;
1129
- this.v1 = v1;
1130
- this.v2 = v2;
1131
- this.v3 = v3;
1135
+ this.start = start;
1136
+ this.startControl = startControl;
1137
+ this.endControl = endControl;
1138
+ this.end = end;
1132
1139
  }
1133
- getPoint(t, output = new Point2D()) {
1134
- const { v0, v1, v2, v3 } = this;
1140
+ getPoint(t, output = new Vector2()) {
1141
+ const { start, startControl, endControl, end } = this;
1135
1142
  output.set(
1136
- cubicBezier(t, v0.x, v1.x, v2.x, v3.x),
1137
- cubicBezier(t, v0.y, v1.y, v2.y, v3.y)
1143
+ cubicBezier(t, start.x, startControl.x, endControl.x, end.x),
1144
+ cubicBezier(t, start.y, startControl.y, endControl.y, end.y)
1138
1145
  );
1139
1146
  return output;
1140
1147
  }
1141
- transform(matrix) {
1142
- this.v0.applyMatrix3(matrix);
1143
- this.v1.applyMatrix3(matrix);
1144
- this.v2.applyMatrix3(matrix);
1145
- this.v3.applyMatrix3(matrix);
1146
- return this;
1147
- }
1148
- getMinMax(min = Point2D.MAX, max = Point2D.MIN) {
1149
- const { v0, v1, v2, v3 } = this;
1150
- min.x = Math.min(min.x, v0.x, v1.x, v2.x, v3.x);
1151
- min.y = Math.min(min.y, v0.y, v1.y, v2.y, v3.y);
1152
- max.x = Math.max(max.x, v0.x, v1.x, v2.x, v3.x);
1153
- max.y = Math.max(max.y, v0.y, v1.y, v2.y, v3.y);
1148
+ transformPoint(cb) {
1149
+ cb(this.start);
1150
+ cb(this.startControl);
1151
+ cb(this.endControl);
1152
+ cb(this.end);
1153
+ return this;
1154
+ }
1155
+ getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
1156
+ const { start, startControl, endControl, end } = this;
1157
+ min.x = Math.min(min.x, start.x, startControl.x, endControl.x, end.x);
1158
+ min.y = Math.min(min.y, start.y, startControl.y, endControl.y, end.y);
1159
+ max.x = Math.max(max.x, start.x, startControl.x, endControl.x, end.x);
1160
+ max.y = Math.max(max.y, start.y, startControl.y, endControl.y, end.y);
1154
1161
  return { min, max };
1155
1162
  }
1156
1163
  getCommands() {
1157
- const { v0, v1, v2, v3 } = this;
1164
+ const { start, startControl, endControl, end } = this;
1158
1165
  return [
1159
- { type: "M", x: v0.x, y: v0.y },
1160
- { type: "C", x1: v1.x, y1: v1.y, x2: v2.x, y2: v2.y, x: v3.x, y: v3.y }
1166
+ { type: "M", x: start.x, y: start.y },
1167
+ { type: "C", x1: startControl.x, y1: startControl.y, x2: endControl.x, y2: endControl.y, x: end.x, y: end.y }
1161
1168
  ];
1162
1169
  }
1163
1170
  drawTo(ctx) {
1164
- const { v1, v2, v3 } = this;
1165
- ctx.bezierCurveTo(v1.x, v1.y, v2.x, v2.y, v3.x, v3.y);
1171
+ const { startControl, endControl, end } = this;
1172
+ ctx.bezierCurveTo(startControl.x, startControl.y, endControl.x, endControl.y, end.x, end.y);
1166
1173
  return this;
1167
1174
  }
1168
1175
  copy(source) {
1169
1176
  super.copy(source);
1170
- this.v0.copy(source.v0);
1171
- this.v1.copy(source.v1);
1172
- this.v2.copy(source.v2);
1173
- this.v3.copy(source.v3);
1177
+ this.start.copy(source.start);
1178
+ this.startControl.copy(source.startControl);
1179
+ this.endControl.copy(source.endControl);
1180
+ this.end.copy(source.end);
1174
1181
  return this;
1175
1182
  }
1176
1183
  }
@@ -1178,12 +1185,11 @@ class CubicBezierCurve extends Curve {
1178
1185
  const tempTransform0$1 = new Matrix3();
1179
1186
  const tempTransform1$1 = new Matrix3();
1180
1187
  const tempTransform2$1 = new Matrix3();
1181
- const tempV2 = new Point2D();
1188
+ const tempV2 = new Vector2();
1182
1189
  class EllipseCurve extends Curve {
1183
- constructor(x = 0, y = 0, radiusX = 1, radiusY = 1, startAngle = 0, endAngle = Math.PI * 2, clockwise = false, rotation = 0) {
1190
+ constructor(center = new Vector2(), radiusX = 1, radiusY = 1, startAngle = 0, endAngle = Math.PI * 2, clockwise = false, rotation = 0) {
1184
1191
  super();
1185
- this.x = x;
1186
- this.y = y;
1192
+ this.center = center;
1187
1193
  this.radiusX = radiusX;
1188
1194
  this.radiusY = radiusY;
1189
1195
  this.startAngle = startAngle;
@@ -1191,7 +1197,7 @@ class EllipseCurve extends Curve {
1191
1197
  this.clockwise = clockwise;
1192
1198
  this.rotation = rotation;
1193
1199
  }
1194
- getPoint(t, output = new Point2D()) {
1200
+ getPoint(t, output = new Vector2()) {
1195
1201
  const twoPi = Math.PI * 2;
1196
1202
  let deltaAngle = this.endAngle - this.startAngle;
1197
1203
  const samePoints = Math.abs(deltaAngle) < Number.EPSILON;
@@ -1214,15 +1220,15 @@ class EllipseCurve extends Curve {
1214
1220
  }
1215
1221
  }
1216
1222
  const angle = this.startAngle + t * deltaAngle;
1217
- let _x = this.x + this.radiusX * Math.cos(angle);
1218
- let _y = this.y + this.radiusY * Math.sin(angle);
1223
+ let _x = this.center.x + this.radiusX * Math.cos(angle);
1224
+ let _y = this.center.y + this.radiusY * Math.sin(angle);
1219
1225
  if (this.rotation !== 0) {
1220
1226
  const cos = Math.cos(this.rotation);
1221
1227
  const sin = Math.sin(this.rotation);
1222
- const tx = _x - this.x;
1223
- const ty = _y - this.y;
1224
- _x = tx * cos - ty * sin + this.x;
1225
- _y = tx * sin + ty * cos + this.y;
1228
+ const tx = _x - this.center.x;
1229
+ const ty = _y - this.center.y;
1230
+ _x = tx * cos - ty * sin + this.center.x;
1231
+ _y = tx * sin + ty * cos + this.center.y;
1226
1232
  }
1227
1233
  return output.set(_x, _y);
1228
1234
  }
@@ -1230,7 +1236,8 @@ class EllipseCurve extends Curve {
1230
1236
  return divisions * 2;
1231
1237
  }
1232
1238
  getCommands() {
1233
- const { x: cx, y: cy, radiusX: rx, radiusY: ry, startAngle, endAngle, clockwise, rotation } = this;
1239
+ const { center, radiusX: rx, radiusY: ry, startAngle, endAngle, clockwise, rotation } = this;
1240
+ const { x: cx, y: cy } = center;
1234
1241
  const startX = cx + rx * Math.cos(startAngle) * Math.cos(rotation) - ry * Math.sin(startAngle) * Math.sin(rotation);
1235
1242
  const startY = cy + rx * Math.cos(startAngle) * Math.sin(rotation) + ry * Math.sin(startAngle) * Math.cos(rotation);
1236
1243
  const angleDiff = Math.abs(startAngle - endAngle);
@@ -1256,10 +1263,10 @@ class EllipseCurve extends Curve {
1256
1263
  }
1257
1264
  }
1258
1265
  drawTo(ctx) {
1259
- const { x, y, radiusX, radiusY, rotation, startAngle, endAngle, clockwise } = this;
1266
+ const { center, radiusX, radiusY, rotation, startAngle, endAngle, clockwise } = this;
1260
1267
  ctx.ellipse(
1261
- x,
1262
- y,
1268
+ center.x,
1269
+ center.y,
1263
1270
  radiusX,
1264
1271
  radiusY,
1265
1272
  rotation,
@@ -1270,10 +1277,10 @@ class EllipseCurve extends Curve {
1270
1277
  return this;
1271
1278
  }
1272
1279
  transform(matrix) {
1273
- tempV2.set(this.x, this.y);
1280
+ tempV2.set(this.center.x, this.center.y);
1274
1281
  tempV2.applyMatrix3(matrix);
1275
- this.x = tempV2.x;
1276
- this.y = tempV2.y;
1282
+ this.center.x = tempV2.x;
1283
+ this.center.y = tempV2.y;
1277
1284
  if (isTransformSkewed(matrix)) {
1278
1285
  transfEllipseGeneric(this, matrix);
1279
1286
  } else {
@@ -1281,8 +1288,13 @@ class EllipseCurve extends Curve {
1281
1288
  }
1282
1289
  return this;
1283
1290
  }
1284
- getMinMax(min = Point2D.MAX, max = Point2D.MIN) {
1285
- const { x: cx, y: cy, radiusX: rx, radiusY: ry, rotation: theta } = this;
1291
+ transformPoint(cb) {
1292
+ cb(this.center);
1293
+ return this;
1294
+ }
1295
+ getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
1296
+ const { center, radiusX: rx, radiusY: ry, rotation: theta } = this;
1297
+ const { x: cx, y: cy } = center;
1286
1298
  const cosTheta = Math.cos(theta);
1287
1299
  const sinTheta = Math.sin(theta);
1288
1300
  const halfWidth = Math.sqrt(
@@ -1299,8 +1311,8 @@ class EllipseCurve extends Curve {
1299
1311
  }
1300
1312
  copy(source) {
1301
1313
  super.copy(source);
1302
- this.x = source.x;
1303
- this.y = source.y;
1314
+ this.center.x = source.center.x;
1315
+ this.center.y = source.center.y;
1304
1316
  this.radiusX = source.radiusX;
1305
1317
  this.radiusY = source.radiusY;
1306
1318
  this.startAngle = source.startAngle;
@@ -1315,8 +1327,8 @@ function transfEllipseGeneric(curve, m) {
1315
1327
  const b = curve.radiusY;
1316
1328
  const cosTheta = Math.cos(curve.rotation);
1317
1329
  const sinTheta = Math.sin(curve.rotation);
1318
- const v1 = new Point2D(a * cosTheta, a * sinTheta);
1319
- const v2 = new Point2D(-b * sinTheta, b * cosTheta);
1330
+ const v1 = new Vector2(a * cosTheta, a * sinTheta);
1331
+ const v2 = new Vector2(-b * sinTheta, b * cosTheta);
1320
1332
  const f1 = v1.applyMatrix3(m);
1321
1333
  const f2 = v2.applyMatrix3(m);
1322
1334
  const mF = tempTransform0$1.set(
@@ -1366,7 +1378,7 @@ function transfEllipseGeneric(curve, m) {
1366
1378
  );
1367
1379
  const mDRF = mDsqrt.multiply(mRT).multiply(mF);
1368
1380
  const transformAngle = (phi) => {
1369
- const { x: cosR, y: sinR } = new Point2D(Math.cos(phi), Math.sin(phi)).applyMatrix3(mDRF);
1381
+ const { x: cosR, y: sinR } = new Vector2(Math.cos(phi), Math.sin(phi)).applyMatrix3(mDRF);
1370
1382
  return Math.atan2(sinR, cosR);
1371
1383
  };
1372
1384
  curve.startAngle = transformAngle(curve.startAngle);
@@ -1451,61 +1463,64 @@ function eigenDecomposition(A, B, C) {
1451
1463
  }
1452
1464
 
1453
1465
  class LineCurve extends Curve {
1454
- constructor(v1 = new Point2D(), v2 = new Point2D()) {
1466
+ constructor(start = new Vector2(), end = new Vector2()) {
1455
1467
  super();
1456
- this.v1 = v1;
1457
- this.v2 = v2;
1468
+ this.start = start;
1469
+ this.end = end;
1458
1470
  }
1459
- getPoint(t, output = new Point2D()) {
1471
+ getPoint(t, output = new Vector2()) {
1460
1472
  if (t === 1) {
1461
- output.copy(this.v2);
1473
+ output.copy(this.end);
1462
1474
  } else {
1463
- output.copy(this.v2).sub(this.v1);
1464
- output.multiplyScalar(t).add(this.v1);
1475
+ output.copy(this.end).sub(this.start).multiplyScalar(t).add(this.start);
1465
1476
  }
1466
1477
  return output;
1467
1478
  }
1468
- getPointAt(u, output = new Point2D()) {
1479
+ getPointAt(u, output = new Vector2()) {
1469
1480
  return this.getPoint(u, output);
1470
1481
  }
1471
- getTangent(t, output = new Point2D()) {
1472
- return output.subVectors(this.v2, this.v1).normalize();
1482
+ getTangent(_t, output = new Vector2()) {
1483
+ return output.subVectors(this.end, this.start).normalize();
1473
1484
  }
1474
- getTangentAt(u, output = new Point2D()) {
1485
+ getTangentAt(u, output = new Vector2()) {
1475
1486
  return this.getTangent(u, output);
1476
1487
  }
1477
- transform(matrix) {
1478
- this.v1.applyMatrix3(matrix);
1479
- this.v2.applyMatrix3(matrix);
1488
+ getNormal(t, output = new Vector2()) {
1489
+ const { x, y } = this.getPoint(t).sub(this.start);
1490
+ return output.set(y, -x).normalize();
1491
+ }
1492
+ transformPoint(cb) {
1493
+ cb(this.start);
1494
+ cb(this.end);
1480
1495
  return this;
1481
1496
  }
1482
1497
  getDivisions() {
1483
1498
  return 1;
1484
1499
  }
1485
- getMinMax(min = Point2D.MAX, max = Point2D.MIN) {
1486
- const { v1, v2 } = this;
1487
- min.x = Math.min(min.x, v1.x, v2.x);
1488
- min.y = Math.min(min.y, v1.y, v2.y);
1489
- max.x = Math.max(max.x, v1.x, v2.x);
1490
- max.y = Math.max(max.y, v1.y, v2.y);
1500
+ getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
1501
+ const { start, end } = this;
1502
+ min.x = Math.min(min.x, start.x, end.x);
1503
+ min.y = Math.min(min.y, start.y, end.y);
1504
+ max.x = Math.max(max.x, start.x, end.x);
1505
+ max.y = Math.max(max.y, start.y, end.y);
1491
1506
  return { min, max };
1492
1507
  }
1493
1508
  getCommands() {
1494
- const { v1, v2 } = this;
1509
+ const { start, end } = this;
1495
1510
  return [
1496
- { type: "M", x: v1.x, y: v1.y },
1497
- { type: "L", x: v2.x, y: v2.y }
1511
+ { type: "M", x: start.x, y: start.y },
1512
+ { type: "L", x: end.x, y: end.y }
1498
1513
  ];
1499
1514
  }
1500
1515
  drawTo(ctx) {
1501
- const { v2 } = this;
1502
- ctx.lineTo(v2.x, v2.y);
1516
+ const { end } = this;
1517
+ ctx.lineTo(end.x, end.y);
1503
1518
  return this;
1504
1519
  }
1505
1520
  copy(source) {
1506
1521
  super.copy(source);
1507
- this.v1.copy(source.v1);
1508
- this.v2.copy(source.v2);
1522
+ this.start.copy(source.start);
1523
+ this.end.copy(source.end);
1509
1524
  return this;
1510
1525
  }
1511
1526
  }
@@ -1523,66 +1538,68 @@ class HeartCurve extends Curve {
1523
1538
  this.size = size;
1524
1539
  this.start = start;
1525
1540
  this.end = end;
1526
- __publicField$4(this, "curves");
1527
- __publicField$4(this, "pointT", 0);
1541
+ __publicField$4(this, "curveT", 0);
1542
+ this.update();
1543
+ }
1544
+ update() {
1528
1545
  const { x, y } = this.center;
1529
- const A = new Point2D(x + 0.5 * this.size, y - 0.5 * this.size);
1530
- const t = new Point2D(x - 0.5 * this.size, y - 0.5 * this.size);
1531
- const i = new Point2D(x, y + 0.5 * this.size);
1546
+ const A = new Vector2(x + 0.5 * this.size, y - 0.5 * this.size);
1547
+ const t = new Vector2(x - 0.5 * this.size, y - 0.5 * this.size);
1548
+ const i = new Vector2(x, y + 0.5 * this.size);
1532
1549
  const curve1 = new CircleCurve(A, Math.SQRT1_2 * this.size, -0.25 * Math.PI, 0.75 * Math.PI);
1533
1550
  const curve5 = new CircleCurve(t, Math.SQRT1_2 * this.size, -0.75 * Math.PI, 0.25 * Math.PI);
1534
1551
  const curve3 = new CircleCurve(i, 0.5 * Math.SQRT1_2 * this.size, 0.75 * Math.PI, 1.25 * Math.PI);
1535
- const e = new Point2D(x, y + this.size);
1536
- const l = new Point2D(x + this.size, y);
1537
- const c = new Point2D().lerpVectors(l, e, 0.75);
1538
- const h = new Point2D(x - this.size, y);
1539
- const a = new Point2D().lerpVectors(h, e, 0.75);
1552
+ const e = new Vector2(x, y + this.size);
1553
+ const l = new Vector2(x + this.size, y);
1554
+ const c = new Vector2().lerpVectors(l, e, 0.75);
1555
+ const h = new Vector2(x - this.size, y);
1556
+ const a = new Vector2().lerpVectors(h, e, 0.75);
1540
1557
  const curve2 = new LineCurve(l, c);
1541
1558
  const curve4 = new LineCurve(a, h);
1542
1559
  this.curves = [curve1, curve2, curve3, curve4, curve5];
1560
+ return this;
1543
1561
  }
1544
- getPoint(value) {
1545
- return this.getCurrentLine(value).getPoint(this.pointT);
1562
+ getPoint(t) {
1563
+ return this.getCurve(t).getPoint(this.curveT);
1546
1564
  }
1547
- getPointAt(value) {
1548
- return this.getPoint(value);
1565
+ getPointAt(t) {
1566
+ return this.getPoint(t);
1549
1567
  }
1550
- getCurrentLine(value) {
1551
- let val = (value * (this.end - this.start) + this.start) % 1;
1568
+ getCurve(t) {
1569
+ let val = (t * (this.end - this.start) + this.start) % 1;
1552
1570
  val < 0 && (val += 1);
1553
1571
  val *= 9 * Math.PI / 8 + 1.5;
1554
1572
  let index;
1555
- const t = 0.5 * Math.PI;
1556
- if (val < t) {
1573
+ const PI_1_2 = 0.5 * Math.PI;
1574
+ if (val < PI_1_2) {
1557
1575
  index = 0;
1558
- this.pointT = val / t;
1559
- } else if (val < t + 0.75) {
1576
+ this.curveT = val / PI_1_2;
1577
+ } else if (val < PI_1_2 + 0.75) {
1560
1578
  index = 1;
1561
- this.pointT = (val - t) / 0.75;
1579
+ this.curveT = (val - PI_1_2) / 0.75;
1562
1580
  } else if (val < 5 * Math.PI / 8 + 0.75) {
1563
1581
  index = 2;
1564
- this.pointT = (val - t - 0.75) / (Math.PI / 8);
1582
+ this.curveT = (val - PI_1_2 - 0.75) / (Math.PI / 8);
1565
1583
  } else if (val < 5 * Math.PI / 8 + 1.5) {
1566
1584
  index = 3;
1567
- this.pointT = (val - 5 * Math.PI / 8 - 0.75) / 0.75;
1585
+ this.curveT = (val - 5 * Math.PI / 8 - 0.75) / 0.75;
1568
1586
  } else {
1569
1587
  index = 4;
1570
- this.pointT = (val - 5 * Math.PI / 8 - 1.5) / t;
1588
+ this.curveT = (val - 5 * Math.PI / 8 - 1.5) / PI_1_2;
1571
1589
  }
1572
1590
  return this.curves[index];
1573
1591
  }
1574
- getTangent(value) {
1575
- return this.getCurrentLine(value).getTangent(this.pointT).normalize();
1592
+ getTangent(t) {
1593
+ return this.getCurve(t).getTangent(this.curveT);
1576
1594
  }
1577
- getNormal(value) {
1578
- const line = this.getCurrentLine(value);
1579
- return new Point2D(line.v2.y - line.v1.y, -(line.v2.x - line.v1.x)).normalize();
1595
+ getNormal(t) {
1596
+ return this.getCurve(t).getNormal(this.curveT);
1580
1597
  }
1581
- transform(matrix) {
1582
- this.curves.forEach((curve) => curve.transform(matrix));
1598
+ transformPoint(cb) {
1599
+ this.curves.forEach((curve) => curve.transformPoint(cb));
1583
1600
  return this;
1584
1601
  }
1585
- getMinMax(min = Point2D.MAX, max = Point2D.MIN) {
1602
+ getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
1586
1603
  this.curves.forEach((curve) => curve.getMinMax(min, max));
1587
1604
  return { min, max };
1588
1605
  }
@@ -1602,54 +1619,59 @@ var __publicField$3 = (obj, key, value) => {
1602
1619
  return value;
1603
1620
  };
1604
1621
  class PloygonCurve extends Curve {
1605
- constructor(center, radius = 0, num = 0, start = 0, end = 1) {
1622
+ constructor(center, radius = 0, number = 0, start = 0, end = 1) {
1606
1623
  super();
1607
1624
  this.center = center;
1608
1625
  this.radius = radius;
1609
- this.num = num;
1626
+ this.number = number;
1610
1627
  this.start = start;
1611
1628
  this.end = end;
1612
1629
  __publicField$3(this, "curves", []);
1630
+ __publicField$3(this, "curveT", 0);
1613
1631
  __publicField$3(this, "points", []);
1614
- for (let i = 0; i < this.num; i++) {
1615
- let radian = i * 2 * Math.PI / this.num;
1632
+ this.update();
1633
+ }
1634
+ update() {
1635
+ for (let i = 0; i < this.number; i++) {
1636
+ let radian = i * 2 * Math.PI / this.number;
1616
1637
  radian -= 0.5 * Math.PI;
1617
- const point = new Point2D(this.radius * Math.cos(radian), this.radius * Math.sin(radian));
1618
- point.add(this.center);
1619
- this.points.push(point);
1638
+ this.points.push(
1639
+ new Vector2(
1640
+ this.radius * Math.cos(radian),
1641
+ this.radius * Math.sin(radian)
1642
+ ).add(this.center)
1643
+ );
1620
1644
  }
1621
- for (let i = 0; i < this.num; i++) {
1622
- this.curves.push(new LineCurve(this.points[i], this.points[(i + 1) % this.num]));
1645
+ for (let i = 0; i < this.number; i++) {
1646
+ this.curves.push(new LineCurve(this.points[i], this.points[(i + 1) % this.number]));
1623
1647
  }
1648
+ return this;
1624
1649
  }
1625
- getPoint(value) {
1626
- this.getCurrentLine(value);
1627
- return this.currentLine.getPoint(this.pointK);
1628
- }
1629
- getPointAt(value) {
1630
- return this.getPoint(value);
1631
- }
1632
- getCurrentLine(value) {
1633
- let pos = (value * (this.end - this.start) + this.start) % 1;
1650
+ getCurve(t) {
1651
+ let pos = (t * (this.end - this.start) + this.start) % 1;
1634
1652
  pos < 0 && (pos += 1);
1635
- const v = pos * this.num;
1653
+ const v = pos * this.number;
1636
1654
  const index = Math.floor(v);
1637
- this.pointK = v - index;
1638
- this.currentLine = this.curves[index];
1639
- return this.currentLine;
1655
+ this.curveT = v - index;
1656
+ return this.curves[index];
1640
1657
  }
1641
- getTangent(value) {
1642
- return this.getCurrentLine(value).getTangent(0).normalize();
1658
+ getPoint(t, output) {
1659
+ return this.getCurve(t).getPoint(this.curveT, output);
1643
1660
  }
1644
- getNormal(value) {
1645
- const line = this.getCurrentLine(value);
1646
- return new Point2D(line.v2.y - line.v1.y, -(line.v2.x - line.v1.x)).normalize();
1661
+ getPointAt(u, output) {
1662
+ return this.getPoint(u, output);
1647
1663
  }
1648
- transform(matrix) {
1649
- this.curves.forEach((curve) => curve.transform(matrix));
1664
+ getTangent(t, output) {
1665
+ return this.getCurve(t).getTangent(this.curveT, output);
1666
+ }
1667
+ getNormal(t, output) {
1668
+ return this.getCurve(t).getNormal(this.curveT, output);
1669
+ }
1670
+ transformPoint(cb) {
1671
+ this.curves.forEach((curve) => curve.transformPoint(cb));
1650
1672
  return this;
1651
1673
  }
1652
- getMinMax(min = Point2D.MAX, max = Point2D.MIN) {
1674
+ getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
1653
1675
  this.curves.forEach((curve) => curve.getMinMax(min, max));
1654
1676
  return { min, max };
1655
1677
  }
@@ -1663,55 +1685,55 @@ class PloygonCurve extends Curve {
1663
1685
  }
1664
1686
 
1665
1687
  class QuadraticBezierCurve extends Curve {
1666
- constructor(v0 = new Point2D(), v1 = new Point2D(), v2 = new Point2D()) {
1688
+ constructor(start = new Vector2(), control = new Vector2(), end = new Vector2()) {
1667
1689
  super();
1668
- this.v0 = v0;
1669
- this.v1 = v1;
1670
- this.v2 = v2;
1690
+ this.start = start;
1691
+ this.control = control;
1692
+ this.end = end;
1671
1693
  }
1672
- getPoint(t, output = new Point2D()) {
1673
- const { v0, v1, v2 } = this;
1694
+ getPoint(t, output = new Vector2()) {
1695
+ const { start, control, end } = this;
1674
1696
  output.set(
1675
- quadraticBezier(t, v0.x, v1.x, v2.x),
1676
- quadraticBezier(t, v0.y, v1.y, v2.y)
1697
+ quadraticBezier(t, start.x, control.x, end.x),
1698
+ quadraticBezier(t, start.y, control.y, end.y)
1677
1699
  );
1678
1700
  return output;
1679
1701
  }
1680
- transform(matrix) {
1681
- this.v0.applyMatrix3(matrix);
1682
- this.v1.applyMatrix3(matrix);
1683
- this.v2.applyMatrix3(matrix);
1684
- return this;
1685
- }
1686
- getMinMax(min = Point2D.MAX, max = Point2D.MIN) {
1687
- const { v0, v1, v2 } = this;
1688
- const x1 = 0.5 * (v0.x + v1.x);
1689
- const y1 = 0.5 * (v0.y + v1.y);
1690
- const x2 = 0.5 * (v0.x + v2.x);
1691
- const y2 = 0.5 * (v0.y + v2.y);
1692
- min.x = Math.min(min.x, v0.x, v2.x, x1, x2);
1693
- min.y = Math.min(min.y, v0.y, v2.y, y1, y2);
1694
- max.x = Math.max(max.x, v0.x, v2.x, x1, x2);
1695
- max.y = Math.max(max.y, v0.y, v2.y, y1, y2);
1702
+ transformPoint(cb) {
1703
+ cb(this.start);
1704
+ cb(this.control);
1705
+ cb(this.end);
1706
+ return this;
1707
+ }
1708
+ getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
1709
+ const { start, control, end } = this;
1710
+ const x1 = 0.5 * (start.x + control.x);
1711
+ const y1 = 0.5 * (start.y + control.y);
1712
+ const x2 = 0.5 * (start.x + end.x);
1713
+ const y2 = 0.5 * (start.y + end.y);
1714
+ min.x = Math.min(min.x, start.x, end.x, x1, x2);
1715
+ min.y = Math.min(min.y, start.y, end.y, y1, y2);
1716
+ max.x = Math.max(max.x, start.x, end.x, x1, x2);
1717
+ max.y = Math.max(max.y, start.y, end.y, y1, y2);
1696
1718
  return { min, max };
1697
1719
  }
1698
1720
  getCommands() {
1699
- const { v0, v1, v2 } = this;
1721
+ const { start, control, end } = this;
1700
1722
  return [
1701
- { type: "M", x: v0.x, y: v0.y },
1702
- { type: "Q", x1: v1.x, y1: v1.y, x: v2.x, y: v2.y }
1723
+ { type: "M", x: start.x, y: start.y },
1724
+ { type: "Q", x1: control.x, y1: control.y, x: end.x, y: end.y }
1703
1725
  ];
1704
1726
  }
1705
1727
  drawTo(ctx) {
1706
- const { v1, v2 } = this;
1707
- ctx.quadraticCurveTo(v1.x, v1.y, v2.x, v2.y);
1728
+ const { control, end } = this;
1729
+ ctx.quadraticCurveTo(control.x, control.y, end.x, end.y);
1708
1730
  return this;
1709
1731
  }
1710
1732
  copy(source) {
1711
1733
  super.copy(source);
1712
- this.v0.copy(source.v0);
1713
- this.v1.copy(source.v1);
1714
- this.v2.copy(source.v2);
1734
+ this.start.copy(source.start);
1735
+ this.control.copy(source.control);
1736
+ this.end.copy(source.end);
1715
1737
  return this;
1716
1738
  }
1717
1739
  }
@@ -1731,19 +1753,8 @@ class RectangularCurve extends Curve {
1731
1753
  this.start = start;
1732
1754
  this.end = end;
1733
1755
  __publicField$2(this, "curves", []);
1734
- __publicField$2(this, "pointT", 0);
1735
- const { x, y } = this.center;
1736
- const offsetX = this.rx;
1737
- const offsetY = this.rx / this.aspectRatio;
1738
- const points = [
1739
- new Point2D(x - offsetX, y - offsetY),
1740
- new Point2D(x + offsetX, y - offsetY),
1741
- new Point2D(x + offsetX, y + offsetY),
1742
- new Point2D(x - offsetX, y + offsetY)
1743
- ];
1744
- for (let i = 0; i < 4; i++) {
1745
- this.curves.push(new LineCurve(points[i].clone(), points[(i + 1) % 4].clone()));
1746
- }
1756
+ __publicField$2(this, "curveT", 0);
1757
+ this.update();
1747
1758
  }
1748
1759
  get x() {
1749
1760
  return this.center.x - this.rx;
@@ -1757,44 +1768,58 @@ class RectangularCurve extends Curve {
1757
1768
  get height() {
1758
1769
  return this.rx / this.aspectRatio * 2;
1759
1770
  }
1760
- getPoint(t) {
1761
- return this.getCurrentLine(t).getPoint(this.pointT);
1762
- }
1763
- getPointAt(u) {
1764
- return this.getPoint(u);
1771
+ update() {
1772
+ const { x, y } = this.center;
1773
+ const offsetX = this.rx;
1774
+ const offsetY = this.rx / this.aspectRatio;
1775
+ const points = [
1776
+ new Vector2(x - offsetX, y - offsetY),
1777
+ new Vector2(x + offsetX, y - offsetY),
1778
+ new Vector2(x + offsetX, y + offsetY),
1779
+ new Vector2(x - offsetX, y + offsetY)
1780
+ ];
1781
+ for (let i = 0; i < 4; i++) {
1782
+ this.curves.push(new LineCurve(points[i].clone(), points[(i + 1) % 4].clone()));
1783
+ }
1784
+ return this;
1765
1785
  }
1766
- getCurrentLine(t) {
1767
- let flag = (t * (this.end - this.start) + this.start) % 1;
1768
- flag < 0 && (flag += 1);
1769
- flag *= (1 + this.aspectRatio) * 2;
1786
+ getCurve(t) {
1787
+ let current = (t * (this.end - this.start) + this.start) % 1;
1788
+ current < 0 && (current += 1);
1789
+ current *= (1 + this.aspectRatio) * 2;
1770
1790
  let i;
1771
- if (flag < this.aspectRatio) {
1791
+ if (current < this.aspectRatio) {
1772
1792
  i = 0;
1773
- this.pointT = flag / this.aspectRatio;
1774
- } else if (flag < this.aspectRatio + 1) {
1793
+ this.curveT = current / this.aspectRatio;
1794
+ } else if (current < this.aspectRatio + 1) {
1775
1795
  i = 1;
1776
- this.pointT = (flag - this.aspectRatio) / 1;
1777
- } else if (flag < 2 * this.aspectRatio + 1) {
1796
+ this.curveT = (current - this.aspectRatio) / 1;
1797
+ } else if (current < 2 * this.aspectRatio + 1) {
1778
1798
  i = 2;
1779
- this.pointT = (flag - this.aspectRatio - 1) / this.aspectRatio;
1799
+ this.curveT = (current - this.aspectRatio - 1) / this.aspectRatio;
1780
1800
  } else {
1781
1801
  i = 3;
1782
- this.pointT = (flag - 2 * this.aspectRatio - 1) / 1;
1802
+ this.curveT = (current - 2 * this.aspectRatio - 1) / 1;
1783
1803
  }
1784
1804
  return this.curves[i];
1785
1805
  }
1786
- getTangent(t) {
1787
- return this.getCurrentLine(t).getTangent(0).normalize();
1806
+ getPoint(t, output) {
1807
+ return this.getCurve(t).getPoint(this.curveT, output);
1788
1808
  }
1789
- getNormal(value) {
1790
- const { v1, v2 } = this.getCurrentLine(value);
1791
- return new Point2D(v2.y - v1.y, -(v2.x - v1.x)).normalize();
1809
+ getPointAt(u, output) {
1810
+ return this.getPoint(u, output);
1792
1811
  }
1793
- transform(matrix) {
1794
- this.curves.forEach((curve) => curve.transform(matrix));
1812
+ getTangent(t, output) {
1813
+ return this.getCurve(t).getTangent(this.curveT, output);
1814
+ }
1815
+ getNormal(t, output) {
1816
+ return this.getCurve(t).getNormal(this.curveT, output);
1817
+ }
1818
+ transformPoint(cb) {
1819
+ this.curves.forEach((curve) => curve.transformPoint(cb));
1795
1820
  return this;
1796
1821
  }
1797
- getMinMax(min = Point2D.MAX, max = Point2D.MIN) {
1822
+ getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
1798
1823
  this.curves.forEach((curve) => curve.getMinMax(min, max));
1799
1824
  return { min, max };
1800
1825
  }
@@ -1815,7 +1840,7 @@ class SplineCurve extends Curve {
1815
1840
  getDivisions(divisions = 12) {
1816
1841
  return divisions * this.points.length;
1817
1842
  }
1818
- getPoint(t, output = new Point2D()) {
1843
+ getPoint(t, output = new Vector2()) {
1819
1844
  const { points } = this;
1820
1845
  const p = (points.length - 1) * t;
1821
1846
  const _p = Math.floor(p);
@@ -1830,6 +1855,10 @@ class SplineCurve extends Curve {
1830
1855
  );
1831
1856
  return output;
1832
1857
  }
1858
+ transformPoint(cb) {
1859
+ this.points.forEach((point) => cb(point));
1860
+ return this;
1861
+ }
1833
1862
  copy(source) {
1834
1863
  super.copy(source);
1835
1864
  this.points = [];
@@ -1850,7 +1879,7 @@ class CurvePath extends Curve {
1850
1879
  constructor(points) {
1851
1880
  super();
1852
1881
  __publicField$1(this, "curves", []);
1853
- __publicField$1(this, "currentPoint", new Point2D());
1882
+ __publicField$1(this, "currentPoint", new Vector2());
1854
1883
  __publicField$1(this, "autoClose", false);
1855
1884
  __publicField$1(this, "_cacheLengths", []);
1856
1885
  if (points) {
@@ -1869,7 +1898,7 @@ class CurvePath extends Curve {
1869
1898
  }
1870
1899
  return this;
1871
1900
  }
1872
- getPoint(position, output = new Point2D()) {
1901
+ getPoint(position, output = new Vector2()) {
1873
1902
  const d = position * this.getLength();
1874
1903
  const curveLengths = this.getCurveLengths();
1875
1904
  let i = 0;
@@ -1921,10 +1950,10 @@ class CurvePath extends Curve {
1921
1950
  let last;
1922
1951
  for (let i = 0, curves = this.curves; i < curves.length; i++) {
1923
1952
  const curve = curves[i];
1924
- const pts = curve.getPoints(curve.getDivisions(divisions));
1925
- for (let i2 = 0; i2 < pts.length; i2++) {
1926
- const point = pts[i2];
1927
- if (last && last.equals(point))
1953
+ const curvePoints = curve.getPoints(curve.getDivisions(divisions));
1954
+ for (let i2 = 0; i2 < curvePoints.length; i2++) {
1955
+ const point = curvePoints[i2];
1956
+ if (last?.equals(point))
1928
1957
  continue;
1929
1958
  points.push(point);
1930
1959
  last = point;
@@ -1946,9 +1975,9 @@ class CurvePath extends Curve {
1946
1975
  this.curves.push(
1947
1976
  new CubicBezierCurve(
1948
1977
  this.currentPoint.clone(),
1949
- new Point2D(cp1x, cp1y),
1950
- new Point2D(cp2x, cp2y),
1951
- new Point2D(x, y)
1978
+ new Vector2(cp1x, cp1y),
1979
+ new Vector2(cp2x, cp2y),
1980
+ new Vector2(x, y)
1952
1981
  )
1953
1982
  );
1954
1983
  this.currentPoint.set(x, y);
@@ -1958,7 +1987,7 @@ class CurvePath extends Curve {
1958
1987
  this.curves.push(
1959
1988
  new LineCurve(
1960
1989
  this.currentPoint.clone(),
1961
- new Point2D(x, y)
1990
+ new Vector2(x, y)
1962
1991
  )
1963
1992
  );
1964
1993
  this.currentPoint.set(x, y);
@@ -1972,8 +2001,8 @@ class CurvePath extends Curve {
1972
2001
  this.curves.push(
1973
2002
  new QuadraticBezierCurve(
1974
2003
  this.currentPoint.clone(),
1975
- new Point2D(cpx, cpy),
1976
- new Point2D(x, y)
2004
+ new Vector2(cpx, cpy),
2005
+ new Vector2(x, y)
1977
2006
  )
1978
2007
  );
1979
2008
  this.currentPoint.set(x, y);
@@ -1982,7 +2011,7 @@ class CurvePath extends Curve {
1982
2011
  rect(x, y, w, h) {
1983
2012
  this.curves.push(
1984
2013
  new RectangularCurve(
1985
- new Point2D(x + w / 2, y + h / 2),
2014
+ new Vector2(x + w / 2, y + h / 2),
1986
2015
  w / 2,
1987
2016
  w / h
1988
2017
  )
@@ -2011,11 +2040,19 @@ class CurvePath extends Curve {
2011
2040
  return this;
2012
2041
  }
2013
2042
  absellipse(x, y, radiusX, radiusY, startAngle, endAngle, clockwise = false, rotation = 0) {
2014
- const curve = new EllipseCurve(x, y, radiusX, radiusY, startAngle, endAngle, clockwise, rotation);
2043
+ const curve = new EllipseCurve(
2044
+ new Vector2(x, y),
2045
+ radiusX,
2046
+ radiusY,
2047
+ startAngle,
2048
+ endAngle,
2049
+ clockwise,
2050
+ rotation
2051
+ );
2015
2052
  if (this.curves.length > 0) {
2016
- const firstPoint = curve.getPoint(0);
2017
- if (!firstPoint.equals(this.currentPoint)) {
2018
- this.lineTo(firstPoint.x, firstPoint.y);
2053
+ const first = curve.getPoint(0);
2054
+ if (!first.equals(this.currentPoint)) {
2055
+ this.lineTo(first.x, first.y);
2019
2056
  }
2020
2057
  }
2021
2058
  this.curves.push(curve);
@@ -2025,7 +2062,7 @@ class CurvePath extends Curve {
2025
2062
  getCommands() {
2026
2063
  return this.curves.flatMap((curve) => curve.getCommands());
2027
2064
  }
2028
- getMinMax(min = Point2D.MAX, max = Point2D.MIN) {
2065
+ getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
2029
2066
  this.curves.forEach((curve) => curve.getMinMax(min, max));
2030
2067
  return { min, max };
2031
2068
  }
@@ -2143,11 +2180,15 @@ class Path2D {
2143
2180
  this.paths.forEach((path) => path.curves.forEach((curve) => cb(curve)));
2144
2181
  return this;
2145
2182
  }
2183
+ transformPoint(cb) {
2184
+ this.forEachCurve((curve) => curve.transformPoint(cb));
2185
+ return this;
2186
+ }
2146
2187
  transform(matrix) {
2147
2188
  this.forEachCurve((curve) => curve.transform(matrix));
2148
2189
  return this;
2149
2190
  }
2150
- getMinMax(min = Point2D.MAX, max = Point2D.MIN) {
2191
+ getMinMax(min = Vector2.MAX, max = Vector2.MIN) {
2151
2192
  this.forEachCurve((curve) => curve.getMinMax(min, max));
2152
2193
  return { min, max };
2153
2194
  }
@@ -2733,4 +2774,4 @@ function parseSvg(svg) {
2733
2774
  });
2734
2775
  }
2735
2776
 
2736
- export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, Point2D, QuadraticBezierCurve, RectangularCurve, SplineCurve, parseSvg, parseSvgToDom };
2777
+ export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, QuadraticBezierCurve, RectangularCurve, SplineCurve, Vector2, parseSvg, parseSvgToDom };