@ntf/math 1.3.0 → 1.3.1

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,16 +1,19 @@
1
- class MathFunction {
2
- }
1
+ // source/algebra/function.ts
2
+ var MathFunction = class {
3
+ };
3
4
 
5
+ // source/common/sign.ts
4
6
  function sign_char(num) {
5
7
  if (num == 0)
6
- return undefined;
8
+ return void 0;
7
9
  if (num < 0)
8
10
  return "-";
9
11
  if (num > 0)
10
12
  return "+";
11
- return undefined;
13
+ return void 0;
12
14
  }
13
15
 
16
+ // source/common/types.ts
14
17
  function check_number(obj) {
15
18
  return obj != null && typeof obj == "number" && !isNaN(obj) && isFinite(obj);
16
19
  }
@@ -74,15 +77,17 @@ function has_property(obj, name, type) {
74
77
  return obj != null && typeof obj == "object" && name in obj && typeof obj[name] == type;
75
78
  }
76
79
 
77
- class ResolveError extends Error {
80
+ // source/common/error.ts
81
+ var ResolveError = class extends Error {
78
82
  constructor(target, value) {
79
83
  super(`can't resolve ${value} to ${target}`);
80
84
  this.target = target;
81
85
  this.value = value;
82
86
  }
83
- }
87
+ };
84
88
 
85
- class Size {
89
+ // source/geometry/size.ts
90
+ var Size = class _Size {
86
91
  width;
87
92
  height;
88
93
  get aspectRatio() {
@@ -102,7 +107,7 @@ class Size {
102
107
  }
103
108
  static cast(a) {
104
109
  if (a == null || typeof a == "undefined")
105
- return undefined;
110
+ return void 0;
106
111
  if (check_number_array(a, 2))
107
112
  return new this(a[0], a[1]);
108
113
  if (has_property(a, "width", "number") && has_property(a, "height", "number"))
@@ -114,7 +119,7 @@ class Size {
114
119
  }
115
120
  if (check_number(a))
116
121
  return new this(a, a);
117
- return undefined;
122
+ return void 0;
118
123
  }
119
124
  static is(a) {
120
125
  return typeof this.cast(a) != "undefined";
@@ -140,17 +145,18 @@ class Size {
140
145
  };
141
146
  }
142
147
  clone() {
143
- return new Size(this.width, this.height);
148
+ return new _Size(this.width, this.height);
144
149
  }
145
150
  equals(square) {
146
- const s = Size.resolve(square);
151
+ const s = _Size.resolve(square);
147
152
  return this.width == s.width && this.height == s.height;
148
153
  }
149
154
  toVec2() {
150
155
  return [this.width, this.height];
151
156
  }
152
- }
157
+ };
153
158
 
159
+ // source/utils.ts
154
160
  function clamp(value, min, max) {
155
161
  if (value <= min)
156
162
  return min;
@@ -170,9 +176,10 @@ function log_hypot(a, b) {
170
176
  const _a = a / 2, _b = b / 2;
171
177
  return 0.5 * Math.log(_a * _a + _b * _b) + Math.LN2;
172
178
  }
173
- const EPSILON = 1e-16;
179
+ var EPSILON = 1e-16;
174
180
 
175
- class Vec3 {
181
+ // source/vectors/vec3.ts
182
+ var Vec3 = class _Vec3 {
176
183
  x;
177
184
  y;
178
185
  z;
@@ -185,22 +192,22 @@ class Vec3 {
185
192
  }
186
193
  static cast(a) {
187
194
  if (a == null || typeof a == "undefined")
188
- return undefined;
195
+ return void 0;
189
196
  if (check_number_array(a, 3) || check_number_array(a, 4))
190
- return new this(a[0], a[1], a[2], check_number(a[3]) ? a[3] : undefined);
197
+ return new this(a[0], a[1], a[2], check_number(a[3]) ? a[3] : void 0);
191
198
  if (has_property(a, "x", "number") && has_property(a, "y", "number") && has_property(a, "z", "number"))
192
- return new this(a.x, a.y, a.z, has_property(a, "w", "number") ? a.w : undefined);
199
+ return new this(a.x, a.y, a.z, has_property(a, "w", "number") ? a.w : void 0);
193
200
  if (check_string(a)) {
194
201
  const [sxyz, sw] = a.split(";");
195
202
  if (check_string(sxyz)) {
196
203
  const parts = sxyz.split(",");
197
204
  if (check_string_array(parts, 3))
198
- return new this(parseFloat(parts[0]), parseFloat(parts[1]), parseFloat(parts[2]), check_string(sw) ? parseFloat(sw) : undefined);
205
+ return new this(parseFloat(parts[0]), parseFloat(parts[1]), parseFloat(parts[2]), check_string(sw) ? parseFloat(sw) : void 0);
199
206
  }
200
207
  }
201
208
  if (check_number(a))
202
209
  return new this(a, a, a);
203
- return undefined;
210
+ return void 0;
204
211
  }
205
212
  static resolveArgs(args) {
206
213
  if (check_number_array(args, 3))
@@ -231,7 +238,7 @@ class Vec3 {
231
238
  t = (-plane_d - ad) / (bd - ad);
232
239
  const lineStartToEnd = this.resolve(lineEnd).subtract(lineStart);
233
240
  const linetoIntersect = lineStartToEnd.multiply(t);
234
- return Vec3.resolve(lineStart).add(linetoIntersect);
241
+ return _Vec3.resolve(lineStart).add(linetoIntersect);
235
242
  }
236
243
  constructor(x = 0, y = 0, z = 0, w = 1) {
237
244
  if (!check_number(x))
@@ -265,10 +272,10 @@ class Vec3 {
265
272
  return [this.x, this.y, this.w];
266
273
  }
267
274
  clone() {
268
- return new Vec3(this.x, this.y, this.z, this.w);
275
+ return new _Vec3(this.x, this.y, this.z, this.w);
269
276
  }
270
277
  equals(vec) {
271
- const a = Vec3.resolve(vec);
278
+ const a = _Vec3.resolve(vec);
272
279
  return this.x == a.x && this.y == a.y && this.z == a.z;
273
280
  }
274
281
  setX(x) {
@@ -284,42 +291,42 @@ class Vec3 {
284
291
  return this;
285
292
  }
286
293
  set(...args) {
287
- const vec = Vec3.resolveArgs(args);
294
+ const vec = _Vec3.resolveArgs(args);
288
295
  return this.setX(vec.x).setY(vec.y).setZ(vec.z);
289
296
  }
290
297
  add(...args) {
291
- const vec = Vec3.resolveArgs(args);
292
- return new Vec3(
298
+ const vec = _Vec3.resolveArgs(args);
299
+ return new _Vec3(
293
300
  this.x + vec.x,
294
301
  this.y + vec.y,
295
302
  this.z + vec.z
296
303
  );
297
304
  }
298
305
  offset(...args) {
299
- const vec = Vec3.resolveArgs(args);
306
+ const vec = _Vec3.resolveArgs(args);
300
307
  this.x += vec.x;
301
308
  this.y += vec.y;
302
309
  this.z += vec.z;
303
310
  return this;
304
311
  }
305
312
  subtract(...args) {
306
- const vec = Vec3.resolveArgs(args);
307
- return new Vec3(
313
+ const vec = _Vec3.resolveArgs(args);
314
+ return new _Vec3(
308
315
  this.x - vec.x,
309
316
  this.y - vec.y,
310
317
  this.z - vec.z
311
318
  );
312
319
  }
313
320
  multiply(scalar) {
314
- return new Vec3(
321
+ return new _Vec3(
315
322
  this.x * scalar,
316
323
  this.y * scalar,
317
324
  this.z * scalar
318
325
  );
319
326
  }
320
327
  naiveMultiply(...args) {
321
- const vec = Vec3.resolveArgs(args);
322
- return new Vec3(
328
+ const vec = _Vec3.resolveArgs(args);
329
+ return new _Vec3(
323
330
  this.x * vec.x,
324
331
  this.y * vec.y,
325
332
  this.z * vec.z
@@ -327,36 +334,36 @@ class Vec3 {
327
334
  }
328
335
  divide(...args) {
329
336
  if (check_number_array(args, 1))
330
- return new Vec3(
337
+ return new _Vec3(
331
338
  this.x / args[0],
332
339
  this.y / args[0],
333
340
  this.z / args[0]
334
341
  );
335
- const vec = Vec3.resolveArgs(args);
336
- return new Vec3(
342
+ const vec = _Vec3.resolveArgs(args);
343
+ return new _Vec3(
337
344
  this.x / vec.x,
338
345
  this.y / vec.y,
339
346
  this.z / vec.z
340
347
  );
341
348
  }
342
349
  dot(...args) {
343
- const vec = Vec3.resolveArgs(args);
350
+ const vec = _Vec3.resolveArgs(args);
344
351
  return this.x * vec.x + this.y * vec.y + this.z * vec.z;
345
352
  }
346
353
  cross(...args) {
347
- const vec = Vec3.resolveArgs(args);
348
- return new Vec3(
354
+ const vec = _Vec3.resolveArgs(args);
355
+ return new _Vec3(
349
356
  this.y * vec.z - this.z * vec.y,
350
357
  this.z * vec.x - this.x * vec.z,
351
358
  this.x * vec.y - this.y * vec.x
352
359
  );
353
360
  }
354
361
  distance(...args) {
355
- const vec = Vec3.resolveArgs(args);
362
+ const vec = _Vec3.resolveArgs(args);
356
363
  return Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2) + Math.pow(vec.z - this.z, 2);
357
364
  }
358
365
  distanceSquare(...args) {
359
- const vec = Vec3.resolveArgs(args);
366
+ const vec = _Vec3.resolveArgs(args);
360
367
  return Math.sqrt(Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2) + Math.pow(vec.z - this.z, 2));
361
368
  }
362
369
  length() {
@@ -364,8 +371,8 @@ class Vec3 {
364
371
  }
365
372
  normalize() {
366
373
  const length = this.length();
367
- if (length == 0) return new Vec3();
368
- return new Vec3(
374
+ if (length == 0) return new _Vec3();
375
+ return new _Vec3(
369
376
  this.x / length,
370
377
  this.y / length,
371
378
  this.z / length
@@ -375,11 +382,12 @@ class Vec3 {
375
382
  return this.multiply(-1);
376
383
  }
377
384
  round() {
378
- return new Vec3(Math.round(this.x), Math.round(this.y), Math.round(this.z), Math.round(this.w));
385
+ return new _Vec3(Math.round(this.x), Math.round(this.y), Math.round(this.z), Math.round(this.w));
379
386
  }
380
- }
387
+ };
381
388
 
382
- class Vec2 {
389
+ // source/vectors/vec2.ts
390
+ var Vec2 = class _Vec2 {
383
391
  x;
384
392
  y;
385
393
  w;
@@ -391,22 +399,22 @@ class Vec2 {
391
399
  }
392
400
  static cast(a) {
393
401
  if (a == null || typeof a == "undefined")
394
- return undefined;
402
+ return void 0;
395
403
  if (check_number_array(a, 2) || check_number_array(a, 3))
396
- return new this(a[0], a[1], check_number(a[2]) ? a[2] : undefined);
404
+ return new this(a[0], a[1], check_number(a[2]) ? a[2] : void 0);
397
405
  if (has_property(a, "x", "number") && has_property(a, "y", "number"))
398
- return new this(a.x, a.y, has_property(a, "w", "number") ? a.w : undefined);
406
+ return new this(a.x, a.y, has_property(a, "w", "number") ? a.w : void 0);
399
407
  if (check_string(a)) {
400
408
  const [sxy, sw] = a.split(";");
401
409
  if (check_string(sxy)) {
402
410
  const parts = sxy.split(",");
403
411
  if (check_string_array(parts, 2))
404
- return new this(parseFloat(parts[0]), parseFloat(parts[1]), check_string(sw) ? parseFloat(sw) : undefined);
412
+ return new this(parseFloat(parts[0]), parseFloat(parts[1]), check_string(sw) ? parseFloat(sw) : void 0);
405
413
  }
406
414
  }
407
415
  if (check_number(a))
408
416
  return new this(a, a);
409
- return undefined;
417
+ return void 0;
410
418
  }
411
419
  static resolveArgs(args) {
412
420
  if (check_number_array(args, 2))
@@ -459,10 +467,10 @@ class Vec2 {
459
467
  return new Vec3(this.x, this.y, z, this.w);
460
468
  }
461
469
  clone() {
462
- return new Vec2(this.x, this.y, this.w);
470
+ return new _Vec2(this.x, this.y, this.w);
463
471
  }
464
472
  equals(vec) {
465
- const a = Vec2.resolve(vec);
473
+ const a = _Vec2.resolve(vec);
466
474
  return this.x == a.x && this.y == a.y;
467
475
  }
468
476
  setX(x) {
@@ -478,85 +486,85 @@ class Vec2 {
478
486
  return this;
479
487
  }
480
488
  set(...args) {
481
- const vec = Vec2.resolveArgs(args);
489
+ const vec = _Vec2.resolveArgs(args);
482
490
  return this.setX(vec.x).setY(vec.y);
483
491
  }
484
492
  add(...args) {
485
- const vec = Vec2.resolveArgs(args);
486
- return new Vec2(
493
+ const vec = _Vec2.resolveArgs(args);
494
+ return new _Vec2(
487
495
  this.x + vec.x,
488
496
  this.y + vec.y
489
497
  );
490
498
  }
491
499
  offset(...args) {
492
- const vec = Vec2.resolveArgs(args);
500
+ const vec = _Vec2.resolveArgs(args);
493
501
  this.x += vec.x;
494
502
  this.y += vec.y;
495
503
  return this;
496
504
  }
497
505
  subtract(...args) {
498
- const vec = Vec2.resolveArgs(args);
499
- return new Vec2(
506
+ const vec = _Vec2.resolveArgs(args);
507
+ return new _Vec2(
500
508
  this.x - vec.x,
501
509
  this.y - vec.y
502
510
  );
503
511
  }
504
512
  multiply(scalar) {
505
- return new Vec2(
513
+ return new _Vec2(
506
514
  this.x * scalar,
507
515
  this.y * scalar
508
516
  );
509
517
  }
510
518
  naiveMultiply(...args) {
511
- const vec = Vec2.resolveArgs(args);
512
- return new Vec2(
519
+ const vec = _Vec2.resolveArgs(args);
520
+ return new _Vec2(
513
521
  this.x * vec.x,
514
522
  this.y * vec.y
515
523
  );
516
524
  }
517
525
  divide(...args) {
518
526
  if (check_number_array(args, 1))
519
- return new Vec2(
527
+ return new _Vec2(
520
528
  this.x / args[0],
521
529
  this.y / args[0]
522
530
  );
523
- const vec = Vec2.resolveArgs(args);
524
- return new Vec2(
531
+ const vec = _Vec2.resolveArgs(args);
532
+ return new _Vec2(
525
533
  this.x / vec.x,
526
534
  this.y / vec.y
527
535
  );
528
536
  }
529
537
  dot(...args) {
530
- const vec = Vec2.resolveArgs(args);
538
+ const vec = _Vec2.resolveArgs(args);
531
539
  return this.x * vec.x + this.y * vec.y;
532
540
  }
533
541
  distance(...args) {
534
- const vec = Vec2.resolveArgs(args);
542
+ const vec = _Vec2.resolveArgs(args);
535
543
  return Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2);
536
544
  }
537
545
  distanceSquare(...args) {
538
- const vec = Vec2.resolveArgs(args);
546
+ const vec = _Vec2.resolveArgs(args);
539
547
  return Math.sqrt(Math.pow(vec.x - this.x, 2) + Math.pow(vec.y - this.y, 2));
540
548
  }
541
549
  length() {
542
550
  return Math.sqrt(this.x * this.x + this.y * this.y);
543
551
  }
544
552
  cartesianify() {
545
- return new Vec2(
553
+ return new _Vec2(
546
554
  this.x * Math.cos(this.y),
547
555
  this.x * Math.sin(this.y)
548
556
  );
549
557
  }
550
558
  polarify() {
551
- return new Vec2(
559
+ return new _Vec2(
552
560
  Math.sqrt(this.x * this.x + this.y * this.y),
553
561
  Math.atan(this.y / this.x)
554
562
  );
555
563
  }
556
564
  normalize() {
557
565
  const length = this.length();
558
- if (length == 0) return new Vec2();
559
- return new Vec2(
566
+ if (length == 0) return new _Vec2();
567
+ return new _Vec2(
560
568
  this.x / length,
561
569
  this.y / length
562
570
  );
@@ -565,11 +573,12 @@ class Vec2 {
565
573
  return this.multiply(-1);
566
574
  }
567
575
  round() {
568
- return new Vec2(Math.round(this.x), Math.round(this.y), Math.round(this.w));
576
+ return new _Vec2(Math.round(this.x), Math.round(this.y), Math.round(this.w));
569
577
  }
570
- }
578
+ };
571
579
 
572
- class LinearFunction extends MathFunction {
580
+ // source/algebra/linear.ts
581
+ var LinearFunction = class extends MathFunction {
573
582
  /**
574
583
  * The factor of the linear function
575
584
  */
@@ -622,9 +631,10 @@ class LinearFunction extends MathFunction {
622
631
  return `f(x) = ${this.m} * x ${bsign} ${Math.abs(this.b)}`;
623
632
  return `f(x) = ${this.m} * x`;
624
633
  }
625
- }
634
+ };
626
635
 
627
- class QuadFunction extends MathFunction {
636
+ // source/algebra/quad.ts
637
+ var QuadFunction = class extends MathFunction {
628
638
  a;
629
639
  b;
630
640
  c;
@@ -675,13 +685,15 @@ class QuadFunction extends MathFunction {
675
685
  }
676
686
  }
677
687
  }
678
- }
688
+ };
679
689
 
690
+ // source/common/string.ts
680
691
  function stringify(value) {
681
692
  return value != null && typeof value == "object" && "toString" in value && typeof value.toString == "function" ? value.toString() : String(value);
682
693
  }
683
694
 
684
- const DJB2_OFFSET = 5381n;
695
+ // source/crypto/hash.ts
696
+ var DJB2_OFFSET = 5381n;
685
697
  function djb2(value) {
686
698
  const string = stringify(value);
687
699
  let hash = DJB2_OFFSET;
@@ -690,8 +702,8 @@ function djb2(value) {
690
702
  }
691
703
  return hash;
692
704
  }
693
- const FNV1_OFFSET = 14695981039346656037n;
694
- const FNV1_PRIME = 1099511628211n;
705
+ var FNV1_OFFSET = 14695981039346656037n;
706
+ var FNV1_PRIME = 1099511628211n;
695
707
  function fnv1(value) {
696
708
  const string = stringify(value);
697
709
  let hash = FNV1_OFFSET;
@@ -710,13 +722,326 @@ function sdbm(value) {
710
722
  return hash;
711
723
  }
712
724
 
713
- const MAX_ANGLE_DEGREE = 360;
714
- const cap_angle_degree = (angle) => angle % MAX_ANGLE_DEGREE;
715
- const cap_angle_radian = (angle) => cap_angle_degree(degree_to_radian(angle));
716
- const radian_to_degree = (angle) => angle * (180 / Math.PI);
717
- const degree_to_radian = (angle) => angle * (Math.PI / 180);
725
+ // source/crypto/md2.ts
726
+ var STABLE = [
727
+ 41,
728
+ 46,
729
+ 67,
730
+ 201,
731
+ 162,
732
+ 216,
733
+ 124,
734
+ 1,
735
+ 61,
736
+ 54,
737
+ 84,
738
+ 161,
739
+ 236,
740
+ 240,
741
+ 6,
742
+ 19,
743
+ 98,
744
+ 167,
745
+ 5,
746
+ 243,
747
+ 192,
748
+ 199,
749
+ 115,
750
+ 140,
751
+ 152,
752
+ 147,
753
+ 43,
754
+ 217,
755
+ 188,
756
+ 76,
757
+ 130,
758
+ 202,
759
+ 30,
760
+ 155,
761
+ 87,
762
+ 60,
763
+ 253,
764
+ 212,
765
+ 224,
766
+ 22,
767
+ 103,
768
+ 66,
769
+ 111,
770
+ 24,
771
+ 138,
772
+ 23,
773
+ 229,
774
+ 18,
775
+ 190,
776
+ 78,
777
+ 196,
778
+ 214,
779
+ 218,
780
+ 158,
781
+ 222,
782
+ 73,
783
+ 160,
784
+ 251,
785
+ 245,
786
+ 142,
787
+ 187,
788
+ 47,
789
+ 238,
790
+ 122,
791
+ 169,
792
+ 104,
793
+ 121,
794
+ 145,
795
+ 21,
796
+ 178,
797
+ 7,
798
+ 63,
799
+ 148,
800
+ 194,
801
+ 16,
802
+ 137,
803
+ 11,
804
+ 34,
805
+ 95,
806
+ 33,
807
+ 128,
808
+ 127,
809
+ 93,
810
+ 154,
811
+ 90,
812
+ 144,
813
+ 50,
814
+ 39,
815
+ 53,
816
+ 62,
817
+ 204,
818
+ 231,
819
+ 191,
820
+ 247,
821
+ 151,
822
+ 3,
823
+ 255,
824
+ 25,
825
+ 48,
826
+ 179,
827
+ 72,
828
+ 165,
829
+ 181,
830
+ 209,
831
+ 215,
832
+ 94,
833
+ 146,
834
+ 42,
835
+ 172,
836
+ 86,
837
+ 170,
838
+ 198,
839
+ 79,
840
+ 184,
841
+ 56,
842
+ 210,
843
+ 150,
844
+ 164,
845
+ 125,
846
+ 182,
847
+ 118,
848
+ 252,
849
+ 107,
850
+ 226,
851
+ 156,
852
+ 116,
853
+ 4,
854
+ 241,
855
+ 69,
856
+ 157,
857
+ 112,
858
+ 89,
859
+ 100,
860
+ 113,
861
+ 135,
862
+ 32,
863
+ 134,
864
+ 91,
865
+ 207,
866
+ 101,
867
+ 230,
868
+ 45,
869
+ 168,
870
+ 2,
871
+ 27,
872
+ 96,
873
+ 37,
874
+ 173,
875
+ 174,
876
+ 176,
877
+ 185,
878
+ 246,
879
+ 28,
880
+ 70,
881
+ 97,
882
+ 105,
883
+ 52,
884
+ 64,
885
+ 126,
886
+ 15,
887
+ 85,
888
+ 71,
889
+ 163,
890
+ 35,
891
+ 221,
892
+ 81,
893
+ 175,
894
+ 58,
895
+ 195,
896
+ 92,
897
+ 249,
898
+ 206,
899
+ 186,
900
+ 197,
901
+ 234,
902
+ 38,
903
+ 44,
904
+ 83,
905
+ 13,
906
+ 110,
907
+ 133,
908
+ 40,
909
+ 132,
910
+ 9,
911
+ 211,
912
+ 223,
913
+ 205,
914
+ 244,
915
+ 65,
916
+ 129,
917
+ 77,
918
+ 82,
919
+ 106,
920
+ 220,
921
+ 55,
922
+ 200,
923
+ 108,
924
+ 193,
925
+ 171,
926
+ 250,
927
+ 36,
928
+ 225,
929
+ 123,
930
+ 8,
931
+ 12,
932
+ 189,
933
+ 177,
934
+ 74,
935
+ 120,
936
+ 136,
937
+ 149,
938
+ 139,
939
+ 227,
940
+ 99,
941
+ 232,
942
+ 109,
943
+ 233,
944
+ 203,
945
+ 213,
946
+ 254,
947
+ 59,
948
+ 0,
949
+ 29,
950
+ 57,
951
+ 242,
952
+ 239,
953
+ 183,
954
+ 14,
955
+ 102,
956
+ 88,
957
+ 208,
958
+ 228,
959
+ 166,
960
+ 119,
961
+ 114,
962
+ 248,
963
+ 235,
964
+ 117,
965
+ 75,
966
+ 10,
967
+ 49,
968
+ 68,
969
+ 80,
970
+ 180,
971
+ 143,
972
+ 237,
973
+ 31,
974
+ 26,
975
+ 219,
976
+ 153,
977
+ 141,
978
+ 51,
979
+ 159,
980
+ 17,
981
+ 131,
982
+ 20
983
+ ];
984
+ var MD2 = class _MD2 {
985
+ static BLOCK_SIZE = 16;
986
+ _data = new Uint8Array(16);
987
+ _state = new Uint8Array(48);
988
+ _checksum = new Uint8Array(16);
989
+ _length = 0;
990
+ constructor() {
991
+ for (let i = 0; i < this._state.length; i++)
992
+ this._state[i] = 0;
993
+ for (let i = 0; i < this._checksum.length; i++)
994
+ this._checksum[i] = 0;
995
+ }
996
+ update(input) {
997
+ for (let i = 0; i < input.length; i++) {
998
+ this._data[this._length] = input[i];
999
+ this._length++;
1000
+ if (this._length == _MD2.BLOCK_SIZE) {
1001
+ this._transform(input);
1002
+ this._length = 0;
1003
+ }
1004
+ }
1005
+ return this;
1006
+ }
1007
+ _transform(data) {
1008
+ for (let i = 0; i < 16; ++i) {
1009
+ this._state[i + 16] = this._data[i];
1010
+ this._state[i + 32] = this._state[i + 16] ^ this._state[i];
1011
+ }
1012
+ let t = 0;
1013
+ for (let i = 0; i < 18; ++i) {
1014
+ for (let j = 0; j < 48; ++j) {
1015
+ this._state[j] ^= STABLE[t];
1016
+ t = this._state[j];
1017
+ }
1018
+ t = t + i & 255;
1019
+ }
1020
+ t = this._checksum[15];
1021
+ for (let i = 0; i < 16; ++i) {
1022
+ this._checksum[i] ^= STABLE[this._data[i] ^ t];
1023
+ t = this._checksum[i];
1024
+ }
1025
+ }
1026
+ digest() {
1027
+ const toPad = _MD2.BLOCK_SIZE - this._length;
1028
+ while (this._length < _MD2.BLOCK_SIZE)
1029
+ this._data[this._length++] = toPad;
1030
+ this._transform(this._data);
1031
+ this._transform(this._checksum);
1032
+ return this._state.slice();
1033
+ }
1034
+ };
1035
+
1036
+ // source/geometry/angle.ts
1037
+ var MAX_ANGLE_DEGREE = 360;
1038
+ var cap_angle_degree = (angle) => angle % MAX_ANGLE_DEGREE;
1039
+ var cap_angle_radian = (angle) => cap_angle_degree(degree_to_radian(angle));
1040
+ var radian_to_degree = (angle) => angle * (180 / Math.PI);
1041
+ var degree_to_radian = (angle) => angle * (Math.PI / 180);
718
1042
 
719
- class Circle {
1043
+ // source/geometry/circle.ts
1044
+ var Circle = class _Circle {
720
1045
  radius;
721
1046
  get perimeter() {
722
1047
  return this.radius * Math.PI * 2;
@@ -751,7 +1076,7 @@ class Circle {
751
1076
  }
752
1077
  static cast(a) {
753
1078
  if (a == null || typeof a == "undefined")
754
- return undefined;
1079
+ return void 0;
755
1080
  if (check_number_array(a, 3))
756
1081
  return new this([a[0], a[1]], a[2]);
757
1082
  if (check_number_array(a, 4)) {
@@ -765,12 +1090,12 @@ class Circle {
765
1090
  const [spos, sradius] = a.split("|");
766
1091
  const pos = Vec2.cast(spos);
767
1092
  if (typeof pos == "undefined")
768
- return undefined;
1093
+ return void 0;
769
1094
  const radius = parseFloat(sradius);
770
1095
  if (!isNaN(radius))
771
1096
  return new this(pos, radius);
772
1097
  }
773
- return undefined;
1098
+ return void 0;
774
1099
  }
775
1100
  static is(a) {
776
1101
  return typeof this.cast(a) != "undefined";
@@ -794,14 +1119,14 @@ class Circle {
794
1119
  return `${this.position.toString()}|${this.radius}`;
795
1120
  }
796
1121
  clone() {
797
- return new Circle(this.position.clone(), this.radius);
1122
+ return new _Circle(this.position.clone(), this.radius);
798
1123
  }
799
1124
  equals(circle) {
800
- const c = Circle.resolve(circle);
1125
+ const c = _Circle.resolve(circle);
801
1126
  return c.position.equals(c.position) && this.radius == c.radius;
802
1127
  }
803
1128
  inside(a) {
804
- const circle = Circle.resolve(a);
1129
+ const circle = _Circle.resolve(a);
805
1130
  const distX = circle.x - this.x;
806
1131
  const distY = circle.y - this.y;
807
1132
  const dist = Math.sqrt(distX * distX + (distY + distY));
@@ -810,9 +1135,10 @@ class Circle {
810
1135
  insidePoint(a) {
811
1136
  return this.position.distance(a) <= this.radius;
812
1137
  }
813
- }
1138
+ };
814
1139
 
815
- class Rectangle {
1140
+ // source/geometry/rectangle.ts
1141
+ var Rectangle = class _Rectangle {
816
1142
  position;
817
1143
  size;
818
1144
  get area() {
@@ -859,7 +1185,7 @@ class Rectangle {
859
1185
  }
860
1186
  static cast(a) {
861
1187
  if (a == null || typeof a == "undefined")
862
- return undefined;
1188
+ return void 0;
863
1189
  if (check_number_array(a, 4))
864
1190
  return new this(a[0], a[1], a[2], a[3]);
865
1191
  if (check_number_array(a, 5)) {
@@ -872,7 +1198,7 @@ class Rectangle {
872
1198
  const pos = Vec2.cast(spos);
873
1199
  const size = Size.cast(ssize);
874
1200
  if (typeof pos == "undefined" || typeof size == "undefined")
875
- return undefined;
1201
+ return void 0;
876
1202
  const rect = new this(pos.x, pos.y, size.width, size.height);
877
1203
  rect.w = pos.w;
878
1204
  return rect;
@@ -883,14 +1209,14 @@ class Rectangle {
883
1209
  rect.w = a.w;
884
1210
  return rect;
885
1211
  }
886
- return undefined;
1212
+ return void 0;
887
1213
  }
888
1214
  static is(a) {
889
1215
  return typeof this.cast(a) != "undefined";
890
1216
  }
891
1217
  constructor(a, b, c, d) {
892
- const vec = Vec2.is(a) ? Vec2.resolve(a) : undefined;
893
- const size = Size.is(b) ? Size.resolve(b) : undefined;
1218
+ const vec = Vec2.is(a) ? Vec2.resolve(a) : void 0;
1219
+ const size = Size.is(b) ? Size.resolve(b) : void 0;
894
1220
  const x = typeof a == "number" ? a : vec?.x;
895
1221
  if (!check_number(x))
896
1222
  throw new TypeError("expected number for x position");
@@ -919,15 +1245,16 @@ class Rectangle {
919
1245
  return [this.x, this.x + this.width, this.y, this.y + this.height];
920
1246
  }
921
1247
  clone() {
922
- return new Rectangle(this.position.clone(), this.size.clone());
1248
+ return new _Rectangle(this.position.clone(), this.size.clone());
923
1249
  }
924
1250
  equals(rectangle) {
925
- const rect = Rectangle.resolve(rectangle);
1251
+ const rect = _Rectangle.resolve(rectangle);
926
1252
  return this.position.equals(rect.position) && this.size.equals(rect.size);
927
1253
  }
928
- }
1254
+ };
929
1255
 
930
- class BoundingBox {
1256
+ // source/geometry/bbox.ts
1257
+ var BoundingBox = class _BoundingBox {
931
1258
  left;
932
1259
  right;
933
1260
  top;
@@ -952,7 +1279,7 @@ class BoundingBox {
952
1279
  }
953
1280
  static cast(a) {
954
1281
  if (a == null || typeof a == "undefined")
955
- return undefined;
1282
+ return void 0;
956
1283
  if (check_number_array(a, 4))
957
1284
  return new this(a[0], a[1], a[2], a[3]);
958
1285
  if (has_property(a, "left", "number") && has_property(a, "right", "number") && has_property(a, "top", "number") && has_property(a, "bottom", "number"))
@@ -962,7 +1289,7 @@ class BoundingBox {
962
1289
  if (check_string_array(parts, 4))
963
1290
  return this.cast(parts.map((v) => parseFloat(v)));
964
1291
  }
965
- return undefined;
1292
+ return void 0;
966
1293
  }
967
1294
  static is(a) {
968
1295
  return typeof this.cast(a) != "undefined";
@@ -996,10 +1323,10 @@ class BoundingBox {
996
1323
  };
997
1324
  }
998
1325
  clone() {
999
- return new BoundingBox(this.left, this.right, this.top, this.bottom);
1326
+ return new _BoundingBox(this.left, this.right, this.top, this.bottom);
1000
1327
  }
1001
1328
  equals(bbox) {
1002
- const b = BoundingBox.resolve(bbox);
1329
+ const b = _BoundingBox.resolve(bbox);
1003
1330
  return this.left == b.left && this.right == b.right && this.top == b.top && this.bottom == b.bottom;
1004
1331
  }
1005
1332
  toSquare() {
@@ -1009,12 +1336,12 @@ class BoundingBox {
1009
1336
  return new Rectangle(this.left, this.top, this.width, this.height);
1010
1337
  }
1011
1338
  inside(a) {
1012
- const bbox = BoundingBox.resolve(a);
1339
+ const bbox = _BoundingBox.resolve(a);
1013
1340
  return this.right >= bbox.left && bbox.right >= this.left && this.bottom >= bbox.top && bbox.bottom >= this.top;
1014
1341
  }
1015
1342
  insidePoint(a) {
1016
1343
  const point = Vec2.resolve(a);
1017
- return this.left <= point.x && this.right >= point.x && this.top >= point.y && this.bottom <= point.y;
1344
+ return this.left <= point.x && this.right >= point.x && this.top <= point.y && this.bottom >= point.y;
1018
1345
  }
1019
1346
  insideCircle(a) {
1020
1347
  const circle = Circle.resolve(a);
@@ -1027,9 +1354,10 @@ class BoundingBox {
1027
1354
  diff = closest.subtract(center);
1028
1355
  return diff.length() < circle.radius;
1029
1356
  }
1030
- }
1357
+ };
1031
1358
 
1032
- class ATriangle {
1359
+ // source/geometry/triangle.ts
1360
+ var ATriangle = class {
1033
1361
  constructor(A, B, C) {
1034
1362
  this.A = A;
1035
1363
  this.B = B;
@@ -1059,8 +1387,8 @@ class ATriangle {
1059
1387
  get height() {
1060
1388
  return 2 * (this.area / this.base);
1061
1389
  }
1062
- }
1063
- class Triangle2D extends ATriangle {
1390
+ };
1391
+ var Triangle2D = class extends ATriangle {
1064
1392
  get a() {
1065
1393
  return Vec2.fromPoints(this.B, this.C).length();
1066
1394
  }
@@ -1070,8 +1398,8 @@ class Triangle2D extends ATriangle {
1070
1398
  get c() {
1071
1399
  return Vec2.fromPoints(this.A, this.B).length();
1072
1400
  }
1073
- }
1074
- class Triangle3D extends ATriangle {
1401
+ };
1402
+ var Triangle3D = class extends ATriangle {
1075
1403
  get a() {
1076
1404
  return Vec3.fromPoints(this.B, this.C).length();
1077
1405
  }
@@ -1081,9 +1409,10 @@ class Triangle3D extends ATriangle {
1081
1409
  get c() {
1082
1410
  return Vec3.fromPoints(this.A, this.B).length();
1083
1411
  }
1084
- }
1412
+ };
1085
1413
 
1086
- class Mat3 {
1414
+ // source/matrices/mat3.ts
1415
+ var Mat3 = class _Mat3 {
1087
1416
  _raw;
1088
1417
  get m00() {
1089
1418
  return this._raw[0];
@@ -1147,11 +1476,11 @@ class Mat3 {
1147
1476
  }
1148
1477
  static cast(a) {
1149
1478
  if (a == null || typeof a == "undefined")
1150
- return undefined;
1479
+ return void 0;
1151
1480
  if (check_number_array(a, 9)) {
1152
1481
  return new this(a);
1153
1482
  }
1154
- if (check_array(a, undefined, 3)) {
1483
+ if (check_array(a, void 0, 3)) {
1155
1484
  const row0 = a[0], row1 = a[1], row2 = a[2];
1156
1485
  if (check_number_array(row0, 3) && check_number_array(row1, 3) && check_number_array(row2, 3))
1157
1486
  return new this([
@@ -1186,7 +1515,7 @@ class Mat3 {
1186
1515
  if (check_number(a)) {
1187
1516
  return new this([a, a, a, a, a, a, a, a, a]);
1188
1517
  }
1189
- return undefined;
1518
+ return void 0;
1190
1519
  }
1191
1520
  static is(a) {
1192
1521
  return typeof this.cast(a) != "undefined";
@@ -1246,7 +1575,7 @@ class Mat3 {
1246
1575
  return `${this.m00},${this.m01},${this.m02},${this.m10},${this.m11},${this.m12},${this.m20},${this.m21},${this.m22}`;
1247
1576
  }
1248
1577
  clone() {
1249
- return new Mat3([
1578
+ return new _Mat3([
1250
1579
  this.m00,
1251
1580
  this.m01,
1252
1581
  this.m02,
@@ -1259,29 +1588,29 @@ class Mat3 {
1259
1588
  ]);
1260
1589
  }
1261
1590
  equals(mat) {
1262
- const m = Mat3.resolve(mat);
1591
+ const m = _Mat3.resolve(mat);
1263
1592
  for (let index = 0; index < this._raw.length; index++)
1264
1593
  if (this._raw[index] != m._raw[index])
1265
1594
  return false;
1266
1595
  return true;
1267
1596
  }
1268
1597
  add(mat) {
1269
- const b = Mat3.resolve(mat);
1270
- const m = new Mat3();
1598
+ const b = _Mat3.resolve(mat);
1599
+ const m = new _Mat3();
1271
1600
  for (let index = 0; index < this._raw.length; index++)
1272
1601
  m._raw[index] = this._raw[index] + b._raw[index];
1273
- return this;
1602
+ return m;
1274
1603
  }
1275
1604
  subtract(mat) {
1276
- const b = Mat3.resolve(mat);
1277
- const m = new Mat3();
1605
+ const b = _Mat3.resolve(mat);
1606
+ const m = new _Mat3();
1278
1607
  for (let index = 0; index < this._raw.length; index++)
1279
1608
  m._raw[index] = this._raw[index] - b._raw[index];
1280
- return this;
1609
+ return m;
1281
1610
  }
1282
1611
  multiply(a) {
1283
1612
  if (check_number(a))
1284
- return new Mat3([
1613
+ return new _Mat3([
1285
1614
  this.m00 * a,
1286
1615
  this.m01 * a,
1287
1616
  this.m02 * a,
@@ -1292,8 +1621,8 @@ class Mat3 {
1292
1621
  this.m21 * a,
1293
1622
  this.m22 * a
1294
1623
  ]);
1295
- const b = Mat3.resolve(a);
1296
- return new Mat3([
1624
+ const b = _Mat3.resolve(a);
1625
+ return new _Mat3([
1297
1626
  b.m00 * this.m00 + b.m01 * this.m10 + b.m02 * this.m20,
1298
1627
  b.m00 * this.m01 + b.m01 * this.m11 + b.m02 * this.m21,
1299
1628
  b.m00 * this.m02 + b.m01 * this.m12 + b.m02 * this.m22,
@@ -1353,7 +1682,7 @@ class Mat3 {
1353
1682
  }
1354
1683
  inverse() {
1355
1684
  const det = this.determinant();
1356
- return new Mat3([
1685
+ return new _Mat3([
1357
1686
  (this.m11 * this.m22 - this.m21 * this.m12) * det,
1358
1687
  (this.m02 * this.m21 - this.m01 * this.m22) * det,
1359
1688
  (this.m01 * this.m12 - this.m02 * this.m11) * det,
@@ -1385,9 +1714,10 @@ class Mat3 {
1385
1714
  1
1386
1715
  ];
1387
1716
  }
1388
- }
1717
+ };
1389
1718
 
1390
- class Mat4 {
1719
+ // source/matrices/mat4.ts
1720
+ var Mat4 = class _Mat4 {
1391
1721
  _raw;
1392
1722
  get m00() {
1393
1723
  return this._raw[0];
@@ -1493,11 +1823,11 @@ class Mat4 {
1493
1823
  }
1494
1824
  static cast(a) {
1495
1825
  if (a == null || typeof a == "undefined")
1496
- return undefined;
1826
+ return void 0;
1497
1827
  if (check_number_array(a, 16)) {
1498
1828
  return new this(a);
1499
1829
  }
1500
- if (check_array(a, undefined, 4)) {
1830
+ if (check_array(a, void 0, 4)) {
1501
1831
  const row0 = a[0], row1 = a[1], row2 = a[2], row3 = a[3];
1502
1832
  if (check_number_array(row0, 4) && check_number_array(row1, 4) && check_number_array(row2, 4) && check_number_array(row3, 4))
1503
1833
  return new this([
@@ -1546,7 +1876,7 @@ class Mat4 {
1546
1876
  if (check_number(a)) {
1547
1877
  return new this([a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a]);
1548
1878
  }
1549
- return undefined;
1879
+ return void 0;
1550
1880
  }
1551
1881
  static is(a) {
1552
1882
  return typeof this.cast(a) != "undefined";
@@ -1675,7 +2005,7 @@ class Mat4 {
1675
2005
  return `${this.m00},${this.m01},${this.m02},${this.m03},${this.m10},${this.m11},${this.m12},${this.m13},${this.m20},${this.m21},${this.m22},${this.m23},${this.m30},${this.m31},${this.m32},${this.m33}`;
1676
2006
  }
1677
2007
  clone() {
1678
- return new Mat4([
2008
+ return new _Mat4([
1679
2009
  this.m00,
1680
2010
  this.m01,
1681
2011
  this.m02,
@@ -1695,29 +2025,29 @@ class Mat4 {
1695
2025
  ]);
1696
2026
  }
1697
2027
  equals(mat) {
1698
- const m = Mat4.resolve(mat);
2028
+ const m = _Mat4.resolve(mat);
1699
2029
  for (let index = 0; index < this._raw.length; index++)
1700
2030
  if (this._raw[index] != m._raw[index])
1701
2031
  return false;
1702
2032
  return true;
1703
2033
  }
1704
2034
  add(mat) {
1705
- const b = Mat4.resolve(mat);
1706
- const m = new Mat4();
2035
+ const b = _Mat4.resolve(mat);
2036
+ const m = new _Mat4();
1707
2037
  for (let index = 0; index < this._raw.length; index++)
1708
2038
  m._raw[index] = this._raw[index] + b._raw[index];
1709
2039
  return m;
1710
2040
  }
1711
2041
  subtract(mat) {
1712
- const b = Mat4.resolve(mat);
1713
- const m = new Mat4();
2042
+ const b = _Mat4.resolve(mat);
2043
+ const m = new _Mat4();
1714
2044
  for (let index = 0; index < this._raw.length; index++)
1715
2045
  m._raw[index] = this._raw[index] - b._raw[index];
1716
2046
  return m;
1717
2047
  }
1718
2048
  multiply(a) {
1719
2049
  if (check_number(a)) {
1720
- return new Mat4([
2050
+ return new _Mat4([
1721
2051
  this.m00 * a,
1722
2052
  this.m01 * a,
1723
2053
  this.m02 * a,
@@ -1736,9 +2066,9 @@ class Mat4 {
1736
2066
  this.m33 * a
1737
2067
  ]);
1738
2068
  }
1739
- if (Mat4.is(a)) {
1740
- const b = Mat4.resolve(a);
1741
- return new Mat4([
2069
+ if (_Mat4.is(a)) {
2070
+ const b = _Mat4.resolve(a);
2071
+ return new _Mat4([
1742
2072
  b.m00 * this.m00 + b.m01 * this.m10 + b.m02 * this.m20 + b.m03 * this.m30,
1743
2073
  b.m00 * this.m01 + b.m01 * this.m11 + b.m02 * this.m21 + b.m03 * this.m31,
1744
2074
  b.m00 * this.m02 + b.m01 * this.m12 + b.m02 * this.m22 + b.m03 * this.m32,
@@ -1884,7 +2214,7 @@ class Mat4 {
1884
2214
  ]);
1885
2215
  }
1886
2216
  inverse() {
1887
- return new Mat4([
2217
+ return new _Mat4([
1888
2218
  this.m00,
1889
2219
  this.m10,
1890
2220
  this.m20,
@@ -1916,11 +2246,12 @@ class Mat4 {
1916
2246
  this.m33
1917
2247
  ];
1918
2248
  }
1919
- }
2249
+ };
1920
2250
 
2251
+ // source/color.ts
1921
2252
  function _hex_to_array(hex) {
1922
2253
  if (!check_hex(hex))
1923
- return undefined;
2254
+ return void 0;
1924
2255
  const part = get_hex_part(hex);
1925
2256
  const a = parseInt(part.substring(0, 2), 16) / 255;
1926
2257
  const b = parseInt(part.substring(2, 4), 16) / 255;
@@ -1944,7 +2275,7 @@ function _number_to_rgba(number) {
1944
2275
  function _fix_integer(number) {
1945
2276
  return number * 255 | 0;
1946
2277
  }
1947
- class RGBAColor {
2278
+ var RGBAColor = class _RGBAColor {
1948
2279
  _red;
1949
2280
  get red() {
1950
2281
  return this._red;
@@ -1981,11 +2312,11 @@ class RGBAColor {
1981
2312
  }
1982
2313
  static cast(a) {
1983
2314
  if (a == null || typeof a == "undefined")
1984
- return undefined;
2315
+ return void 0;
1985
2316
  if (check_number_array(a, 3) || check_number_array(a, 4))
1986
2317
  return new this(a[0], a[1], a[2], a[3]);
1987
2318
  if (has_property(a, "red", "number") && has_property(a, "green", "number") && has_property(a, "blue", "number"))
1988
- return new this(a.red, a.green, a.blue, has_property(a, "alpha", "number") ? a.alpha : undefined);
2319
+ return new this(a.red, a.green, a.blue, has_property(a, "alpha", "number") ? a.alpha : void 0);
1989
2320
  if (check_number(a)) {
1990
2321
  const hex = a.toString(16);
1991
2322
  const convert = hex.length <= 6 ? _number_to_rgb : _number_to_rgba;
@@ -2001,7 +2332,7 @@ class RGBAColor {
2001
2332
  }
2002
2333
  return this.cast(_hex_to_array(a));
2003
2334
  }
2004
- return undefined;
2335
+ return void 0;
2005
2336
  }
2006
2337
  static is(a) {
2007
2338
  return typeof this.cast(a) != "undefined";
@@ -2031,7 +2362,7 @@ class RGBAColor {
2031
2362
  const min = Math.min(red, green, blue), max = Math.max(red, green, blue);
2032
2363
  const luminace = (min + max) / 2;
2033
2364
  if (min == max)
2034
- return new HSLColor(0, 0, luminace, withAlpha ? this.alpha : undefined);
2365
+ return new HSLColor(0, 0, luminace, withAlpha ? this.alpha : void 0);
2035
2366
  const d = max - min;
2036
2367
  const saturation = luminace > 0.5 ? d / (2 - max - min) : d / (max + min);
2037
2368
  if (max == red)
@@ -2040,18 +2371,18 @@ class RGBAColor {
2040
2371
  return new HSLColor(((blue - red) / d + 2) / 6, saturation, luminace);
2041
2372
  if (max == blue)
2042
2373
  return new HSLColor(((red - green) / d + 4) / 6, saturation, luminace);
2043
- return new HSLColor(0, saturation, luminace, withAlpha ? this.alpha : undefined);
2374
+ return new HSLColor(0, saturation, luminace, withAlpha ? this.alpha : void 0);
2044
2375
  }
2045
2376
  invert(withAlpha = false) {
2046
- return new RGBAColor(
2377
+ return new _RGBAColor(
2047
2378
  1 - this.red,
2048
2379
  1 - this.green,
2049
2380
  1 - this.blue,
2050
2381
  withAlpha ? 1 - this.alpha : this.alpha
2051
2382
  );
2052
2383
  }
2053
- }
2054
- class HSLColor {
2384
+ };
2385
+ var HSLColor = class _HSLColor {
2055
2386
  _hue;
2056
2387
  get hue() {
2057
2388
  return this._hue;
@@ -2088,11 +2419,11 @@ class HSLColor {
2088
2419
  }
2089
2420
  static cast(a) {
2090
2421
  if (a == null || typeof a == "undefined")
2091
- return undefined;
2422
+ return void 0;
2092
2423
  if (check_number_array(a, 3) || check_number_array(a, 4))
2093
2424
  return new this(a[0], a[1], a[2], a[3]);
2094
2425
  if (has_property(a, "hue", "number") && has_property(a, "saturation", "number") && has_property(a, "luminace", "number"))
2095
- return new this(a.hue, a.saturation, a.luminace, has_property(a, "alpha", "number") ? a.alpha : undefined);
2426
+ return new this(a.hue, a.saturation, a.luminace, has_property(a, "alpha", "number") ? a.alpha : void 0);
2096
2427
  if (check_number(a)) {
2097
2428
  const hex = a.toString(16);
2098
2429
  const convert = hex.length <= 6 ? _number_to_rgb : _number_to_rgba;
@@ -2108,7 +2439,7 @@ class HSLColor {
2108
2439
  }
2109
2440
  return this.cast(_hex_to_array(a));
2110
2441
  }
2111
- return undefined;
2442
+ return void 0;
2112
2443
  }
2113
2444
  static is(a) {
2114
2445
  return typeof this.cast(a) != "undefined";
@@ -2143,7 +2474,7 @@ class HSLColor {
2143
2474
  }
2144
2475
  toRGB(withAlpha = true) {
2145
2476
  if (this.saturation == 0)
2146
- return new RGBAColor(this.luminace * 255, this.luminace * 255, this.luminace * 255, withAlpha ? this.alpha : undefined);
2477
+ return new RGBAColor(this.luminace * 255, this.luminace * 255, this.luminace * 255, withAlpha ? this.alpha : void 0);
2147
2478
  const q = this.luminace < 0.5 ? this.luminace * (1 + this.saturation) : this.luminace + this.saturation - this.luminace * this.saturation;
2148
2479
  const p = 2 * this.luminace - q;
2149
2480
  function _hue_2_rgb(t) {
@@ -2160,17 +2491,17 @@ class HSLColor {
2160
2491
  return p + (q - p) * (2 / 3 - _t) * 6;
2161
2492
  return p;
2162
2493
  }
2163
- return new RGBAColor(_hue_2_rgb(this.hue + 1 / 3) * 255, _hue_2_rgb(this.hue) * 255, _hue_2_rgb(this.hue - 1 / 3) * 255, withAlpha ? this.alpha : undefined);
2494
+ return new RGBAColor(_hue_2_rgb(this.hue + 1 / 3) * 255, _hue_2_rgb(this.hue) * 255, _hue_2_rgb(this.hue - 1 / 3) * 255, withAlpha ? this.alpha : void 0);
2164
2495
  }
2165
2496
  invert(withAlpha = false) {
2166
- return new HSLColor(
2497
+ return new _HSLColor(
2167
2498
  1 - this.hue,
2168
2499
  1 - this.saturation,
2169
2500
  1 - this.luminace,
2170
2501
  withAlpha ? 1 - this.alpha : this.alpha
2171
2502
  );
2172
2503
  }
2173
- }
2504
+ };
2174
2505
  function resolveColor(a, preferHSL = false) {
2175
2506
  const value = castColor(a, preferHSL);
2176
2507
  if (typeof value != "undefined")
@@ -2196,10 +2527,11 @@ function castColor(a, preferHSL = false) {
2196
2527
  const secondItem = results[offset + 1];
2197
2528
  if (secondItem)
2198
2529
  return secondItem;
2199
- return undefined;
2530
+ return void 0;
2200
2531
  }
2201
2532
 
2202
- class Quaternion {
2533
+ // source/quaternion.ts
2534
+ var Quaternion = class _Quaternion {
2203
2535
  w;
2204
2536
  x;
2205
2537
  y;
@@ -2215,7 +2547,7 @@ class Quaternion {
2215
2547
  }
2216
2548
  static cast(a) {
2217
2549
  if (a == null || typeof a == "undefined")
2218
- return undefined;
2550
+ return void 0;
2219
2551
  if (check_number_array(a, 4))
2220
2552
  return new this(a[0], a[1], a[2], a[3]);
2221
2553
  if (has_property(a, "w", "number") && has_property(a, "x", "number") && has_property(a, "y", "number") && has_property(a, "z", "number"))
@@ -2233,7 +2565,7 @@ class Quaternion {
2233
2565
  ]);
2234
2566
  }
2235
2567
  }
2236
- return undefined;
2568
+ return void 0;
2237
2569
  }
2238
2570
  static fromAxisAngle(axis, angle) {
2239
2571
  const vec = Vec3.resolve(axis);
@@ -2248,7 +2580,7 @@ class Quaternion {
2248
2580
  const x2 = vec.x * 0.5, y2 = vec.y * 0.5, z2 = vec.z * 0.5;
2249
2581
  const cx = Math.cos(x2), cy = Math.cos(y2), cz = Math.cos(z2);
2250
2582
  const sx = Math.sin(x2), sy = Math.sin(y2), sz = Math.sin(z2);
2251
- return new Quaternion(
2583
+ return new _Quaternion(
2252
2584
  cx * cy * cz - sx * sy * sz,
2253
2585
  sx * cy * cz - sy * sz * cx,
2254
2586
  sy * cx * cz - sx * sz * cy,
@@ -2284,11 +2616,11 @@ class Quaternion {
2284
2616
  };
2285
2617
  }
2286
2618
  clone() {
2287
- return new Quaternion(this.w, this.x, this.y, this.z);
2619
+ return new _Quaternion(this.w, this.x, this.y, this.z);
2288
2620
  }
2289
2621
  add(a) {
2290
- const quat = Quaternion.resolve(a);
2291
- return new Quaternion(
2622
+ const quat = _Quaternion.resolve(a);
2623
+ return new _Quaternion(
2292
2624
  this.w + quat.w,
2293
2625
  this.x + quat.x,
2294
2626
  this.y + quat.y,
@@ -2296,7 +2628,7 @@ class Quaternion {
2296
2628
  );
2297
2629
  }
2298
2630
  offset(a) {
2299
- const quat = Quaternion.resolve(a);
2631
+ const quat = _Quaternion.resolve(a);
2300
2632
  this.w += quat.w;
2301
2633
  this.x += quat.x;
2302
2634
  this.y += quat.y;
@@ -2304,8 +2636,8 @@ class Quaternion {
2304
2636
  return this;
2305
2637
  }
2306
2638
  subtract(a) {
2307
- const quat = Quaternion.resolve(a);
2308
- return new Quaternion(
2639
+ const quat = _Quaternion.resolve(a);
2640
+ return new _Quaternion(
2309
2641
  this.w - quat.w,
2310
2642
  this.x - quat.x,
2311
2643
  this.y - quat.y,
@@ -2313,7 +2645,7 @@ class Quaternion {
2313
2645
  );
2314
2646
  }
2315
2647
  negative() {
2316
- return new Quaternion(-this.w, -this.x, -this.y, -this.z);
2648
+ return new _Quaternion(-this.w, -this.x, -this.y, -this.z);
2317
2649
  }
2318
2650
  length(sqrt = true) {
2319
2651
  const value = this.w * this.w + this.x * this.x + this.y * this.y + this.z * this.z;
@@ -2322,13 +2654,13 @@ class Quaternion {
2322
2654
  normalize() {
2323
2655
  let length = this.length();
2324
2656
  if (length < EPSILON)
2325
- return new Quaternion();
2657
+ return new _Quaternion();
2326
2658
  length = 1 / length;
2327
- return new Quaternion(this.w * length, this.x * length, this.y * length, this.z * length);
2659
+ return new _Quaternion(this.w * length, this.x * length, this.y * length, this.z * length);
2328
2660
  }
2329
2661
  multiply(a) {
2330
- const quat = Quaternion.resolve(a);
2331
- return new Quaternion(
2662
+ const quat = _Quaternion.resolve(a);
2663
+ return new _Quaternion(
2332
2664
  this.w * quat.w - this.x * quat.x - this.y * quat.y - this.z * quat.z,
2333
2665
  this.w * quat.x + this.x * quat.w + this.y * quat.z - this.z * quat.y,
2334
2666
  this.w * quat.y + this.y * quat.w + this.z * quat.x - this.x * quat.z,
@@ -2348,25 +2680,25 @@ class Quaternion {
2348
2680
  );
2349
2681
  }
2350
2682
  scale(scalar) {
2351
- return new Quaternion(this.w * scalar, this.x * scalar, this.y * scalar, this.z * scalar);
2683
+ return new _Quaternion(this.w * scalar, this.x * scalar, this.y * scalar, this.z * scalar);
2352
2684
  }
2353
2685
  dot(a) {
2354
- const quat = Quaternion.resolve(a);
2686
+ const quat = _Quaternion.resolve(a);
2355
2687
  return this.w * quat.w + this.x * quat.x + this.y * quat.y + this.z * quat.z;
2356
2688
  }
2357
2689
  inverse() {
2358
2690
  let length = this.length(false);
2359
2691
  if (length == 0)
2360
- return new Quaternion();
2692
+ return new _Quaternion();
2361
2693
  length = 1 / length;
2362
- return new Quaternion(this.w * length, -this.x * length, -this.y * length, -this.z * length);
2694
+ return new _Quaternion(this.w * length, -this.x * length, -this.y * length, -this.z * length);
2363
2695
  }
2364
2696
  divide(a) {
2365
- const quat = Quaternion.resolve(a);
2697
+ const quat = _Quaternion.resolve(a);
2366
2698
  let length = quat.length(false);
2367
- if (length == 0) return new Quaternion();
2699
+ if (length == 0) return new _Quaternion();
2368
2700
  length = 1 / length;
2369
- return new Quaternion(
2701
+ return new _Quaternion(
2370
2702
  (this.w * quat.w + this.x * quat.x + this.y * quat.y + this.z * quat.z) * length,
2371
2703
  (this.x * quat.w - this.w * quat.x - this.y * quat.z + this.z * quat.y) * length,
2372
2704
  (this.y * quat.w - this.w * quat.y - this.z * quat.x + this.x * quat.z) * length,
@@ -2374,15 +2706,15 @@ class Quaternion {
2374
2706
  );
2375
2707
  }
2376
2708
  conjugate() {
2377
- return new Quaternion(this.w, -this.x, -this.y, -this.z);
2709
+ return new _Quaternion(this.w, -this.x, -this.y, -this.z);
2378
2710
  }
2379
2711
  exp() {
2380
2712
  const length = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
2381
2713
  const exp = Math.exp(this.w);
2382
2714
  const scale = exp * Math.sin(length) / length;
2383
2715
  if (length == 0)
2384
- return new Quaternion(exp);
2385
- return new Quaternion(
2716
+ return new _Quaternion(exp);
2717
+ return new _Quaternion(
2386
2718
  exp * Math.cos(length),
2387
2719
  this.x * scale,
2388
2720
  this.y * scale,
@@ -2391,11 +2723,11 @@ class Quaternion {
2391
2723
  }
2392
2724
  log() {
2393
2725
  if (this.x == 0 && this.z == 0)
2394
- return new Quaternion(log_hypot(this.w, this.x), Math.atan2(this.x, this.w));
2726
+ return new _Quaternion(log_hypot(this.w, this.x), Math.atan2(this.x, this.w));
2395
2727
  const length = this.length(false);
2396
2728
  const length2 = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
2397
2729
  const scale = Math.atan2(length2, this.w) / length;
2398
- return new Quaternion(Math.log(length) * 0.5, this.x * scale, this.y * scale, this.z * scale);
2730
+ return new _Quaternion(Math.log(length) * 0.5, this.x * scale, this.y * scale, this.z * scale);
2399
2731
  }
2400
2732
  toVector() {
2401
2733
  return new Vec3(this.x, this.y, this.z, this.w);
@@ -2451,9 +2783,10 @@ class Quaternion {
2451
2783
  1
2452
2784
  ]);
2453
2785
  }
2454
- }
2786
+ };
2455
2787
 
2456
- class Transform {
2788
+ // source/transform.ts
2789
+ var Transform = class {
2457
2790
  /**
2458
2791
  * The position of the object
2459
2792
  */
@@ -2484,6 +2817,53 @@ class Transform {
2484
2817
  toMat4() {
2485
2818
  return new Mat4().translate(this.position).multiply(this.rotation.toMat4()).scale(this.scale);
2486
2819
  }
2487
- }
2488
-
2489
- export { ATriangle, BoundingBox, Circle, DJB2_OFFSET, EPSILON, FNV1_OFFSET, FNV1_PRIME, HSLColor, LinearFunction, MAX_ANGLE_DEGREE, Mat3, Mat4, MathFunction, QuadFunction, Quaternion, RGBAColor, Rectangle, ResolveError, Size, Transform, Triangle2D, Triangle3D, Vec2, Vec3, cap_angle_degree, cap_angle_radian, castColor, check_array, check_hex, check_hex_digit, check_number, check_number_array, check_string, check_string_array, clamp, degree_to_radian, djb2, fnv1, get_hex_part, has_property, log_hypot, radian_to_degree, resolveColor, sdbm, sign_char, stringify };
2820
+ };
2821
+ export {
2822
+ ATriangle,
2823
+ BoundingBox,
2824
+ Circle,
2825
+ DJB2_OFFSET,
2826
+ EPSILON,
2827
+ FNV1_OFFSET,
2828
+ FNV1_PRIME,
2829
+ HSLColor,
2830
+ LinearFunction,
2831
+ MAX_ANGLE_DEGREE,
2832
+ MD2,
2833
+ Mat3,
2834
+ Mat4,
2835
+ MathFunction,
2836
+ QuadFunction,
2837
+ Quaternion,
2838
+ RGBAColor,
2839
+ Rectangle,
2840
+ ResolveError,
2841
+ Size,
2842
+ Transform,
2843
+ Triangle2D,
2844
+ Triangle3D,
2845
+ Vec2,
2846
+ Vec3,
2847
+ cap_angle_degree,
2848
+ cap_angle_radian,
2849
+ castColor,
2850
+ check_array,
2851
+ check_hex,
2852
+ check_hex_digit,
2853
+ check_number,
2854
+ check_number_array,
2855
+ check_string,
2856
+ check_string_array,
2857
+ clamp,
2858
+ degree_to_radian,
2859
+ djb2,
2860
+ fnv1,
2861
+ get_hex_part,
2862
+ has_property,
2863
+ log_hypot,
2864
+ radian_to_degree,
2865
+ resolveColor,
2866
+ sdbm,
2867
+ sign_char,
2868
+ stringify
2869
+ };