modern-canvas 0.1.0 → 0.1.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.cjs CHANGED
@@ -623,13 +623,13 @@ class Geometry extends Resource {
623
623
  }
624
624
  }
625
625
 
626
- var __defProp$C = Object.defineProperty;
627
- var __decorateClass$C = (decorators, target, key, kind) => {
626
+ var __defProp$B = Object.defineProperty;
627
+ var __decorateClass$B = (decorators, target, key, kind) => {
628
628
  var result = void 0 ;
629
629
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
630
630
  if (decorator = decorators[i])
631
631
  result = (decorator(target, key, result) ) || result;
632
- if (result) __defProp$C(target, key, result);
632
+ if (result) __defProp$B(target, key, result);
633
633
  return result;
634
634
  };
635
635
  class IndexBuffer extends Resource {
@@ -673,20 +673,20 @@ class IndexBuffer extends Resource {
673
673
  return result;
674
674
  }
675
675
  }
676
- __decorateClass$C([
676
+ __decorateClass$B([
677
677
  protectedProperty({ default: null })
678
678
  ], IndexBuffer.prototype, "data");
679
- __decorateClass$C([
679
+ __decorateClass$B([
680
680
  protectedProperty({ default: false })
681
681
  ], IndexBuffer.prototype, "dynamic");
682
682
 
683
- var __defProp$B = Object.defineProperty;
684
- var __decorateClass$B = (decorators, target, key, kind) => {
683
+ var __defProp$A = Object.defineProperty;
684
+ var __decorateClass$A = (decorators, target, key, kind) => {
685
685
  var result = void 0 ;
686
686
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
687
687
  if (decorator = decorators[i])
688
688
  result = (decorator(target, key, result) ) || result;
689
- if (result) __defProp$B(target, key, result);
689
+ if (result) __defProp$A(target, key, result);
690
690
  return result;
691
691
  };
692
692
  class VertexBuffer extends Resource {
@@ -730,20 +730,20 @@ class VertexBuffer extends Resource {
730
730
  return result;
731
731
  }
732
732
  }
733
- __decorateClass$B([
733
+ __decorateClass$A([
734
734
  protectedProperty({ default: null })
735
735
  ], VertexBuffer.prototype, "data");
736
- __decorateClass$B([
736
+ __decorateClass$A([
737
737
  protectedProperty({ default: false })
738
738
  ], VertexBuffer.prototype, "dynamic");
739
739
 
740
- var __defProp$A = Object.defineProperty;
741
- var __decorateClass$A = (decorators, target, key, kind) => {
740
+ var __defProp$z = Object.defineProperty;
741
+ var __decorateClass$z = (decorators, target, key, kind) => {
742
742
  var result = void 0 ;
743
743
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
744
744
  if (decorator = decorators[i])
745
745
  result = (decorator(target, key, result) ) || result;
746
- if (result) __defProp$A(target, key, result);
746
+ if (result) __defProp$z(target, key, result);
747
747
  return result;
748
748
  };
749
749
  class VertexAttribute extends Resource {
@@ -780,25 +780,25 @@ class VertexAttribute extends Resource {
780
780
  return result;
781
781
  }
782
782
  }
783
- __decorateClass$A([
783
+ __decorateClass$z([
784
784
  protectedProperty()
785
785
  ], VertexAttribute.prototype, "buffer");
786
- __decorateClass$A([
786
+ __decorateClass$z([
787
787
  protectedProperty({ default: 0 })
788
788
  ], VertexAttribute.prototype, "size");
789
- __decorateClass$A([
789
+ __decorateClass$z([
790
790
  protectedProperty({ default: false })
791
791
  ], VertexAttribute.prototype, "normalized");
792
- __decorateClass$A([
792
+ __decorateClass$z([
793
793
  protectedProperty({ default: "float" })
794
794
  ], VertexAttribute.prototype, "type");
795
- __decorateClass$A([
795
+ __decorateClass$z([
796
796
  protectedProperty()
797
797
  ], VertexAttribute.prototype, "stride");
798
- __decorateClass$A([
798
+ __decorateClass$z([
799
799
  protectedProperty()
800
800
  ], VertexAttribute.prototype, "offset");
801
- __decorateClass$A([
801
+ __decorateClass$z([
802
802
  protectedProperty()
803
803
  ], VertexAttribute.prototype, "divisor");
804
804
 
@@ -982,13 +982,13 @@ class UvGeometry extends Geometry {
982
982
  }
983
983
  }
984
984
 
985
- var __defProp$z = Object.defineProperty;
986
- var __decorateClass$z = (decorators, target, key, kind) => {
985
+ var __defProp$y = Object.defineProperty;
986
+ var __decorateClass$y = (decorators, target, key, kind) => {
987
987
  var result = void 0 ;
988
988
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
989
989
  if (decorator = decorators[i])
990
990
  result = (decorator(target, key, result) ) || result;
991
- if (result) __defProp$z(target, key, result);
991
+ if (result) __defProp$y(target, key, result);
992
992
  return result;
993
993
  };
994
994
  class MainLoop extends _Object {
@@ -1029,10 +1029,10 @@ class MainLoop extends _Object {
1029
1029
  }
1030
1030
  }
1031
1031
  }
1032
- __decorateClass$z([
1032
+ __decorateClass$y([
1033
1033
  property({ default: 24 })
1034
1034
  ], MainLoop.prototype, "fps");
1035
- __decorateClass$z([
1035
+ __decorateClass$y([
1036
1036
  property({ default: 1 })
1037
1037
  ], MainLoop.prototype, "speed");
1038
1038
 
@@ -4005,14 +4005,14 @@ class Vector4 extends Vector {
4005
4005
  }
4006
4006
  }
4007
4007
 
4008
- var __defProp$y = Object.defineProperty;
4009
- var __getOwnPropDesc$u = Object.getOwnPropertyDescriptor;
4010
- var __decorateClass$y = (decorators, target, key, kind) => {
4011
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$u(target, key) : target;
4008
+ var __defProp$x = Object.defineProperty;
4009
+ var __getOwnPropDesc$t = Object.getOwnPropertyDescriptor;
4010
+ var __decorateClass$x = (decorators, target, key, kind) => {
4011
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$t(target, key) : target;
4012
4012
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
4013
4013
  if (decorator = decorators[i])
4014
4014
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
4015
- if (kind && result) __defProp$y(target, key, result);
4015
+ if (kind && result) __defProp$x(target, key, result);
4016
4016
  return result;
4017
4017
  };
4018
4018
  var InternalMode = /* @__PURE__ */ ((InternalMode2) => {
@@ -4410,22 +4410,22 @@ exports.Node = class Node extends Reference {
4410
4410
  return node;
4411
4411
  }
4412
4412
  };
4413
- __decorateClass$y([
4413
+ __decorateClass$x([
4414
4414
  property()
4415
4415
  ], exports.Node.prototype, "name", 2);
4416
- __decorateClass$y([
4416
+ __decorateClass$x([
4417
4417
  property()
4418
4418
  ], exports.Node.prototype, "mask", 2);
4419
- __decorateClass$y([
4419
+ __decorateClass$x([
4420
4420
  property({ default: "visible" })
4421
4421
  ], exports.Node.prototype, "visibility", 2);
4422
- __decorateClass$y([
4422
+ __decorateClass$x([
4423
4423
  property({ default: 0 })
4424
4424
  ], exports.Node.prototype, "visibleDelay", 2);
4425
- __decorateClass$y([
4425
+ __decorateClass$x([
4426
4426
  property({ default: Number.MAX_SAFE_INTEGER })
4427
4427
  ], exports.Node.prototype, "visibleDuration", 2);
4428
- exports.Node = __decorateClass$y([
4428
+ exports.Node = __decorateClass$x([
4429
4429
  customNode("Node")
4430
4430
  ], exports.Node);
4431
4431
 
@@ -4455,14 +4455,14 @@ class RenderStack {
4455
4455
  }
4456
4456
  }
4457
4457
 
4458
- var __defProp$x = Object.defineProperty;
4459
- var __getOwnPropDesc$t = Object.getOwnPropertyDescriptor;
4460
- var __decorateClass$x = (decorators, target, key, kind) => {
4461
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$t(target, key) : target;
4458
+ var __defProp$w = Object.defineProperty;
4459
+ var __getOwnPropDesc$s = Object.getOwnPropertyDescriptor;
4460
+ var __decorateClass$w = (decorators, target, key, kind) => {
4461
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$s(target, key) : target;
4462
4462
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
4463
4463
  if (decorator = decorators[i])
4464
4464
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
4465
- if (kind && result) __defProp$x(target, key, result);
4465
+ if (kind && result) __defProp$w(target, key, result);
4466
4466
  return result;
4467
4467
  };
4468
4468
  exports.Timer = class Timer extends exports.Node {
@@ -4504,29 +4504,29 @@ exports.Timer = class Timer extends exports.Node {
4504
4504
  this.addTime(delta);
4505
4505
  }
4506
4506
  };
4507
- __decorateClass$x([
4507
+ __decorateClass$w([
4508
4508
  property({ default: 0 })
4509
4509
  ], exports.Timer.prototype, "start", 2);
4510
- __decorateClass$x([
4510
+ __decorateClass$w([
4511
4511
  property({ default: 0 })
4512
4512
  ], exports.Timer.prototype, "current", 2);
4513
- __decorateClass$x([
4513
+ __decorateClass$w([
4514
4514
  property({ default: Number.MAX_SAFE_INTEGER })
4515
4515
  ], exports.Timer.prototype, "end", 2);
4516
- __decorateClass$x([
4516
+ __decorateClass$w([
4517
4517
  property({ default: false })
4518
4518
  ], exports.Timer.prototype, "loop", 2);
4519
- exports.Timer = __decorateClass$x([
4519
+ exports.Timer = __decorateClass$w([
4520
4520
  customNode("Timer")
4521
4521
  ], exports.Timer);
4522
4522
 
4523
- var __defProp$w = Object.defineProperty;
4524
- var __decorateClass$w = (decorators, target, key, kind) => {
4523
+ var __defProp$v = Object.defineProperty;
4524
+ var __decorateClass$v = (decorators, target, key, kind) => {
4525
4525
  var result = void 0 ;
4526
4526
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
4527
4527
  if (decorator = decorators[i])
4528
4528
  result = (decorator(target, key, result) ) || result;
4529
- if (result) __defProp$w(target, key, result);
4529
+ if (result) __defProp$v(target, key, result);
4530
4530
  return result;
4531
4531
  };
4532
4532
  class Texture extends Resource {
@@ -4652,22 +4652,22 @@ class Texture extends Resource {
4652
4652
  }
4653
4653
  }
4654
4654
  }
4655
- __decorateClass$w([
4655
+ __decorateClass$v([
4656
4656
  protectedProperty()
4657
4657
  ], Texture.prototype, "source");
4658
- __decorateClass$w([
4658
+ __decorateClass$v([
4659
4659
  protectedProperty({ default: 0 })
4660
4660
  ], Texture.prototype, "width");
4661
- __decorateClass$w([
4661
+ __decorateClass$v([
4662
4662
  protectedProperty({ default: 0 })
4663
4663
  ], Texture.prototype, "height");
4664
- __decorateClass$w([
4664
+ __decorateClass$v([
4665
4665
  protectedProperty({ default: "linear" })
4666
4666
  ], Texture.prototype, "filterMode");
4667
- __decorateClass$w([
4667
+ __decorateClass$v([
4668
4668
  protectedProperty({ default: "clamp_to_edge" })
4669
4669
  ], Texture.prototype, "wrapMode");
4670
- __decorateClass$w([
4670
+ __decorateClass$v([
4671
4671
  protectedProperty({ default: 1 })
4672
4672
  ], Texture.prototype, "pixelRatio");
4673
4673
 
@@ -4803,13 +4803,13 @@ class PixelsTexture extends Texture {
4803
4803
  }
4804
4804
  }
4805
4805
 
4806
- var __defProp$v = Object.defineProperty;
4807
- var __decorateClass$v = (decorators, target, key, kind) => {
4806
+ var __defProp$u = Object.defineProperty;
4807
+ var __decorateClass$u = (decorators, target, key, kind) => {
4808
4808
  var result = void 0 ;
4809
4809
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
4810
4810
  if (decorator = decorators[i])
4811
4811
  result = (decorator(target, key, result) ) || result;
4812
- if (result) __defProp$v(target, key, result);
4812
+ if (result) __defProp$u(target, key, result);
4813
4813
  return result;
4814
4814
  };
4815
4815
  function resolveOptions(options) {
@@ -5052,10 +5052,10 @@ const _VideoTexture = class _VideoTexture extends Texture {
5052
5052
  }
5053
5053
  }
5054
5054
  };
5055
- __decorateClass$v([
5055
+ __decorateClass$u([
5056
5056
  protectedProperty({ default: true })
5057
5057
  ], _VideoTexture.prototype, "autoUpdate");
5058
- __decorateClass$v([
5058
+ __decorateClass$u([
5059
5059
  protectedProperty({ default: 0 })
5060
5060
  ], _VideoTexture.prototype, "fps");
5061
5061
  let VideoTexture = _VideoTexture;
@@ -5064,14 +5064,14 @@ class ViewportTexture extends PixelsTexture {
5064
5064
  //
5065
5065
  }
5066
5066
 
5067
- var __defProp$u = Object.defineProperty;
5068
- var __getOwnPropDesc$s = Object.getOwnPropertyDescriptor;
5069
- var __decorateClass$u = (decorators, target, key, kind) => {
5070
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$s(target, key) : target;
5067
+ var __defProp$t = Object.defineProperty;
5068
+ var __getOwnPropDesc$r = Object.getOwnPropertyDescriptor;
5069
+ var __decorateClass$t = (decorators, target, key, kind) => {
5070
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$r(target, key) : target;
5071
5071
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
5072
5072
  if (decorator = decorators[i])
5073
5073
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
5074
- if (kind && result) __defProp$u(target, key, result);
5074
+ if (kind && result) __defProp$t(target, key, result);
5075
5075
  return result;
5076
5076
  };
5077
5077
  exports.Viewport = class Viewport extends exports.Node {
@@ -5192,19 +5192,19 @@ exports.Viewport = class Viewport extends exports.Node {
5192
5192
  return this._projection.toArray(transpose);
5193
5193
  }
5194
5194
  };
5195
- __decorateClass$u([
5195
+ __decorateClass$t([
5196
5196
  property({ default: 0 })
5197
5197
  ], exports.Viewport.prototype, "x", 2);
5198
- __decorateClass$u([
5198
+ __decorateClass$t([
5199
5199
  property({ default: 0 })
5200
5200
  ], exports.Viewport.prototype, "y", 2);
5201
- __decorateClass$u([
5201
+ __decorateClass$t([
5202
5202
  property({ default: 0 })
5203
5203
  ], exports.Viewport.prototype, "width", 2);
5204
- __decorateClass$u([
5204
+ __decorateClass$t([
5205
5205
  property({ default: 0 })
5206
5206
  ], exports.Viewport.prototype, "height", 2);
5207
- exports.Viewport = __decorateClass$u([
5207
+ exports.Viewport = __decorateClass$t([
5208
5208
  customNode({
5209
5209
  tag: "Viewport",
5210
5210
  renderable: true
@@ -5623,13 +5623,13 @@ class ColorTexture extends Texture {
5623
5623
  }
5624
5624
  }
5625
5625
 
5626
- var __defProp$t = Object.defineProperty;
5627
- var __decorateClass$t = (decorators, target, key, kind) => {
5626
+ var __defProp$s = Object.defineProperty;
5627
+ var __decorateClass$s = (decorators, target, key, kind) => {
5628
5628
  var result = void 0 ;
5629
5629
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
5630
5630
  if (decorator = decorators[i])
5631
5631
  result = (decorator(target, key, result) ) || result;
5632
- if (result) __defProp$t(target, key, result);
5632
+ if (result) __defProp$s(target, key, result);
5633
5633
  return result;
5634
5634
  };
5635
5635
  function proxy$1() {
@@ -5785,46 +5785,46 @@ class CanvasContext {
5785
5785
  return batchables;
5786
5786
  }
5787
5787
  }
5788
- __decorateClass$t([
5788
+ __decorateClass$s([
5789
5789
  proxy$1()
5790
5790
  ], CanvasContext.prototype, "moveTo");
5791
- __decorateClass$t([
5791
+ __decorateClass$s([
5792
5792
  proxy$1()
5793
5793
  ], CanvasContext.prototype, "lineTo");
5794
- __decorateClass$t([
5794
+ __decorateClass$s([
5795
5795
  proxy$1()
5796
5796
  ], CanvasContext.prototype, "bezierCurveTo");
5797
- __decorateClass$t([
5797
+ __decorateClass$s([
5798
5798
  proxy$1()
5799
5799
  ], CanvasContext.prototype, "quadraticCurveTo");
5800
- __decorateClass$t([
5800
+ __decorateClass$s([
5801
5801
  proxy$1()
5802
5802
  ], CanvasContext.prototype, "ellipticalArc");
5803
- __decorateClass$t([
5803
+ __decorateClass$s([
5804
5804
  proxy$1()
5805
5805
  ], CanvasContext.prototype, "rect");
5806
- __decorateClass$t([
5806
+ __decorateClass$s([
5807
5807
  proxy$1()
5808
5808
  ], CanvasContext.prototype, "roundRect");
5809
- __decorateClass$t([
5809
+ __decorateClass$s([
5810
5810
  proxy$1()
5811
5811
  ], CanvasContext.prototype, "ellipse");
5812
- __decorateClass$t([
5812
+ __decorateClass$s([
5813
5813
  proxy$1()
5814
5814
  ], CanvasContext.prototype, "arc");
5815
- __decorateClass$t([
5815
+ __decorateClass$s([
5816
5816
  proxy$1()
5817
5817
  ], CanvasContext.prototype, "poly");
5818
- __decorateClass$t([
5818
+ __decorateClass$s([
5819
5819
  proxy$1()
5820
5820
  ], CanvasContext.prototype, "addShape");
5821
- __decorateClass$t([
5821
+ __decorateClass$s([
5822
5822
  proxy$1()
5823
5823
  ], CanvasContext.prototype, "addPath");
5824
- __decorateClass$t([
5824
+ __decorateClass$s([
5825
5825
  proxy$1()
5826
5826
  ], CanvasContext.prototype, "addSvgPath");
5827
- __decorateClass$t([
5827
+ __decorateClass$s([
5828
5828
  proxy$1()
5829
5829
  ], CanvasContext.prototype, "closePath");
5830
5830
 
@@ -6192,16 +6192,13 @@ class Style2DBackgroundModule extends Style2DModule {
6192
6192
  install(Style2D) {
6193
6193
  defineProperty(Style2D, "backgroundColor");
6194
6194
  defineProperty(Style2D, "backgroundImage");
6195
- Style2D.prototype.getComputedBackground = getComputedBackground;
6195
+ Style2D.prototype.getComputedBackgroundImage = getComputedBackgroundImage;
6196
6196
  }
6197
6197
  }
6198
- async function getComputedBackground() {
6198
+ async function getComputedBackgroundImage() {
6199
6199
  if (this.backgroundImage) {
6200
6200
  return await assets.texture.load(this.backgroundImage);
6201
6201
  }
6202
- if (this.backgroundColor) {
6203
- return new ColorTexture(this.backgroundColor);
6204
- }
6205
6202
  }
6206
6203
 
6207
6204
  class Style2DFilterModule extends Style2DModule {
@@ -6449,13 +6446,13 @@ const modules = {
6449
6446
  Style2DTransformModule: Style2DTransformModule
6450
6447
  };
6451
6448
 
6452
- var __defProp$s = Object.defineProperty;
6453
- var __decorateClass$s = (decorators, target, key, kind) => {
6449
+ var __defProp$r = Object.defineProperty;
6450
+ var __decorateClass$r = (decorators, target, key, kind) => {
6454
6451
  var result = void 0 ;
6455
6452
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6456
6453
  if (decorator = decorators[i])
6457
6454
  result = (decorator(target, key, result) ) || result;
6458
- if (result) __defProp$s(target, key, result);
6455
+ if (result) __defProp$r(target, key, result);
6459
6456
  return result;
6460
6457
  };
6461
6458
  class Style2D extends _Object {
@@ -6481,39 +6478,39 @@ class Style2D extends _Object {
6481
6478
  }
6482
6479
  }
6483
6480
  }
6484
- __decorateClass$s([
6481
+ __decorateClass$r([
6485
6482
  property({ default: "#000000" })
6486
6483
  ], Style2D.prototype, "shadowColor");
6487
- __decorateClass$s([
6484
+ __decorateClass$r([
6488
6485
  property({ default: 0 })
6489
6486
  ], Style2D.prototype, "shadowOffsetX");
6490
- __decorateClass$s([
6487
+ __decorateClass$r([
6491
6488
  property({ default: 0 })
6492
6489
  ], Style2D.prototype, "shadowOffsetY");
6493
- __decorateClass$s([
6490
+ __decorateClass$r([
6494
6491
  property({ default: 0 })
6495
6492
  ], Style2D.prototype, "shadowBlur");
6496
- __decorateClass$s([
6493
+ __decorateClass$r([
6497
6494
  property({ default: 1 })
6498
6495
  ], Style2D.prototype, "opacity");
6499
- __decorateClass$s([
6496
+ __decorateClass$r([
6500
6497
  property({ default: 0 })
6501
6498
  ], Style2D.prototype, "borderRadius");
6502
- __decorateClass$s([
6499
+ __decorateClass$r([
6503
6500
  property({ default: "visible" })
6504
6501
  ], Style2D.prototype, "overflow");
6505
6502
  Object.values(modules).forEach((Module) => {
6506
6503
  new Module().install(Style2D);
6507
6504
  });
6508
6505
 
6509
- var __defProp$r = Object.defineProperty;
6510
- var __getOwnPropDesc$r = Object.getOwnPropertyDescriptor;
6511
- var __decorateClass$r = (decorators, target, key, kind) => {
6512
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$r(target, key) : target;
6506
+ var __defProp$q = Object.defineProperty;
6507
+ var __getOwnPropDesc$q = Object.getOwnPropertyDescriptor;
6508
+ var __decorateClass$q = (decorators, target, key, kind) => {
6509
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$q(target, key) : target;
6513
6510
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6514
6511
  if (decorator = decorators[i])
6515
6512
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
6516
- if (kind && result) __defProp$r(target, key, result);
6513
+ if (kind && result) __defProp$q(target, key, result);
6517
6514
  return result;
6518
6515
  };
6519
6516
  exports.CanvasItem = class CanvasItem extends exports.Node {
@@ -6532,12 +6529,13 @@ exports.CanvasItem = class CanvasItem extends exports.Node {
6532
6529
  _parentOpacity;
6533
6530
  _tint = new Color(4294967295);
6534
6531
  _backgroundColor = new Color(0);
6535
- // 2d batch render
6532
+ _backgroundImage;
6533
+ // Batch render
6536
6534
  context = new CanvasContext();
6537
6535
  _resetContext = true;
6538
- _waitingRedraw = false;
6539
- _waitingReflow = false;
6540
- _waitingRepaint = false;
6536
+ _redrawing = false;
6537
+ _reflowing = false;
6538
+ _repainting = false;
6541
6539
  _originalBatchables = [];
6542
6540
  _layoutedBatchables = [];
6543
6541
  _batchables = [];
@@ -6571,12 +6569,10 @@ exports.CanvasItem = class CanvasItem extends exports.Node {
6571
6569
  _onUpdateStyleProperty(key, newValue, oldValue, declaration) {
6572
6570
  switch (key) {
6573
6571
  case "backgroundColor":
6574
- this._backgroundColor.value = newValue || 0;
6575
- if (this._originalBatchables.length) {
6576
- this.requestRepaint();
6577
- } else if (this._backgroundColor.a > 0) {
6578
- this.requestRedraw();
6579
- }
6572
+ this._updateBackgroundColor();
6573
+ break;
6574
+ case "backgroundImage":
6575
+ this._updateBackgroundImage();
6580
6576
  break;
6581
6577
  case "opacity":
6582
6578
  this._updateOpacity();
@@ -6584,8 +6580,23 @@ exports.CanvasItem = class CanvasItem extends exports.Node {
6584
6580
  case "filter":
6585
6581
  this.requestRepaint();
6586
6582
  break;
6583
+ case "borderRadius":
6584
+ this.requestRedraw();
6585
+ break;
6586
+ }
6587
+ }
6588
+ _updateBackgroundColor() {
6589
+ this._backgroundColor.value = this.style.backgroundColor || 0;
6590
+ if (this._originalBatchables.length) {
6591
+ this.requestRepaint();
6592
+ } else if (this._backgroundColor.a > 0) {
6593
+ this.requestRedraw();
6587
6594
  }
6588
6595
  }
6596
+ async _updateBackgroundImage() {
6597
+ this._backgroundImage = await this.style.getComputedBackgroundImage();
6598
+ this.requestRedraw();
6599
+ }
6589
6600
  _updateOpacity() {
6590
6601
  const opacity = clamp(0, this.style.opacity, 1) * (this._parent?.opacity ?? 1);
6591
6602
  if (this.opacity !== opacity) {
@@ -6597,13 +6608,13 @@ exports.CanvasItem = class CanvasItem extends exports.Node {
6597
6608
  return this.opacity > 0 && super.isVisible();
6598
6609
  }
6599
6610
  requestRedraw() {
6600
- this._waitingRedraw = true;
6611
+ this._redrawing = true;
6601
6612
  }
6602
6613
  requestReflow() {
6603
- this._waitingReflow = true;
6614
+ this._reflowing = true;
6604
6615
  }
6605
6616
  requestRepaint() {
6606
- this._waitingRepaint = true;
6617
+ this._repainting = true;
6607
6618
  }
6608
6619
  _process(delta) {
6609
6620
  const parentOpacity = this._parent?.opacity;
@@ -6614,6 +6625,30 @@ exports.CanvasItem = class CanvasItem extends exports.Node {
6614
6625
  super._process(delta);
6615
6626
  }
6616
6627
  _draw() {
6628
+ this._drawBackground();
6629
+ this._drawContent();
6630
+ }
6631
+ _drawBackground() {
6632
+ const texture = this._backgroundImage;
6633
+ if (texture?.valid) {
6634
+ this.context.fillStyle = texture;
6635
+ this.context.textureTransform = new Transform2D().scale(
6636
+ this.style.width / texture.width,
6637
+ this.style.height / texture.height
6638
+ );
6639
+ this._fill();
6640
+ }
6641
+ }
6642
+ _drawContent() {
6643
+ this._fill();
6644
+ }
6645
+ _fill() {
6646
+ if (this.style.borderRadius) {
6647
+ this.context.roundRect(0, 0, this.style.width, this.style.height, this.style.borderRadius);
6648
+ } else {
6649
+ this.context.rect(0, 0, this.style.width, this.style.height);
6650
+ }
6651
+ this.context.fill();
6617
6652
  }
6618
6653
  _relayout(batchables) {
6619
6654
  return this._reflow(batchables);
@@ -6636,7 +6671,7 @@ exports.CanvasItem = class CanvasItem extends exports.Node {
6636
6671
  }
6637
6672
  _render(renderer) {
6638
6673
  let batchables;
6639
- if (this._waitingRedraw) {
6674
+ if (this._redrawing) {
6640
6675
  this._draw();
6641
6676
  this._originalBatchables = this.context.toBatchables();
6642
6677
  this._layoutedBatchables = this._relayout(this._originalBatchables);
@@ -6644,17 +6679,17 @@ exports.CanvasItem = class CanvasItem extends exports.Node {
6644
6679
  if (this._resetContext) {
6645
6680
  this.context.reset();
6646
6681
  }
6647
- } else if (this._waitingReflow) {
6682
+ } else if (this._reflowing) {
6648
6683
  this._layoutedBatchables = this._reflow(this._originalBatchables);
6649
6684
  batchables = this._layoutedBatchables;
6650
- } else if (this._waitingRepaint) {
6685
+ } else if (this._repainting) {
6651
6686
  batchables = this._repaint(this._layoutedBatchables);
6652
6687
  }
6653
6688
  if (batchables) {
6654
6689
  this._batchables = batchables;
6655
- this._waitingRedraw = false;
6656
- this._waitingReflow = false;
6657
- this._waitingRepaint = false;
6690
+ this._redrawing = false;
6691
+ this._reflowing = false;
6692
+ this._repainting = false;
6658
6693
  }
6659
6694
  this._batchables.forEach((batchable) => {
6660
6695
  batchable.texture?.upload(renderer);
@@ -6676,24 +6711,24 @@ exports.CanvasItem = class CanvasItem extends exports.Node {
6676
6711
  };
6677
6712
  }
6678
6713
  };
6679
- __decorateClass$r([
6714
+ __decorateClass$q([
6680
6715
  property()
6681
6716
  ], exports.CanvasItem.prototype, "tint", 2);
6682
- __decorateClass$r([
6717
+ __decorateClass$q([
6683
6718
  property()
6684
6719
  ], exports.CanvasItem.prototype, "blendMode", 2);
6685
- exports.CanvasItem = __decorateClass$r([
6720
+ exports.CanvasItem = __decorateClass$q([
6686
6721
  customNode("CanvasItem")
6687
6722
  ], exports.CanvasItem);
6688
6723
 
6689
- var __defProp$q = Object.defineProperty;
6690
- var __getOwnPropDesc$q = Object.getOwnPropertyDescriptor;
6691
- var __decorateClass$q = (decorators, target, key, kind) => {
6692
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$q(target, key) : target;
6724
+ var __defProp$p = Object.defineProperty;
6725
+ var __getOwnPropDesc$p = Object.getOwnPropertyDescriptor;
6726
+ var __decorateClass$p = (decorators, target, key, kind) => {
6727
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$p(target, key) : target;
6693
6728
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
6694
6729
  if (decorator = decorators[i])
6695
6730
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
6696
- if (kind && result) __defProp$q(target, key, result);
6731
+ if (kind && result) __defProp$p(target, key, result);
6697
6732
  return result;
6698
6733
  };
6699
6734
  const linear = (amount) => amount;
@@ -6760,8 +6795,8 @@ exports.Animation2D = class Animation2D extends exports.Node {
6760
6795
  _startProps = /* @__PURE__ */ new WeakMap();
6761
6796
  constructor(options) {
6762
6797
  super();
6763
- this.setProperties(options);
6764
6798
  this._onUpdateTime = this._onUpdateTime.bind(this);
6799
+ this.setProperties(options);
6765
6800
  }
6766
6801
  _enterTree() {
6767
6802
  this._tree?.timeline.on("update", this._onUpdateTime);
@@ -6980,36 +7015,36 @@ exports.Animation2D = class Animation2D extends exports.Node {
6980
7015
  });
6981
7016
  }
6982
7017
  };
6983
- __decorateClass$q([
7018
+ __decorateClass$p([
6984
7019
  property({ default: "parent" })
6985
7020
  ], exports.Animation2D.prototype, "mode", 2);
6986
- __decorateClass$q([
7021
+ __decorateClass$p([
6987
7022
  property({ default: false })
6988
7023
  ], exports.Animation2D.prototype, "loop", 2);
6989
- __decorateClass$q([
7024
+ __decorateClass$p([
6990
7025
  property({ default: [] })
6991
7026
  ], exports.Animation2D.prototype, "keyframes", 2);
6992
- __decorateClass$q([
7027
+ __decorateClass$p([
6993
7028
  property()
6994
7029
  ], exports.Animation2D.prototype, "easing", 2);
6995
- __decorateClass$q([
7030
+ __decorateClass$p([
6996
7031
  property({ alias: "visibleDelay", default: 0 })
6997
7032
  ], exports.Animation2D.prototype, "delay", 2);
6998
- __decorateClass$q([
7033
+ __decorateClass$p([
6999
7034
  property({ alias: "visibleDuration", default: 2e3 })
7000
7035
  ], exports.Animation2D.prototype, "duration", 2);
7001
- exports.Animation2D = __decorateClass$q([
7036
+ exports.Animation2D = __decorateClass$p([
7002
7037
  customNode("Animation2D")
7003
7038
  ], exports.Animation2D);
7004
7039
 
7005
- var __defProp$p = Object.defineProperty;
7006
- var __getOwnPropDesc$p = Object.getOwnPropertyDescriptor;
7007
- var __decorateClass$p = (decorators, target, key, kind) => {
7008
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$p(target, key) : target;
7040
+ var __defProp$o = Object.defineProperty;
7041
+ var __getOwnPropDesc$o = Object.getOwnPropertyDescriptor;
7042
+ var __decorateClass$o = (decorators, target, key, kind) => {
7043
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$o(target, key) : target;
7009
7044
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
7010
7045
  if (decorator = decorators[i])
7011
7046
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
7012
- if (kind && result) __defProp$p(target, key, result);
7047
+ if (kind && result) __defProp$o(target, key, result);
7013
7048
  return result;
7014
7049
  };
7015
7050
  exports.Node2D = class Node2D extends exports.CanvasItem {
@@ -7055,6 +7090,9 @@ exports.Node2D = class Node2D extends exports.CanvasItem {
7055
7090
  case "transformOrigin":
7056
7091
  this._updateTransform();
7057
7092
  break;
7093
+ case "overflow":
7094
+ this._updateOverflow();
7095
+ break;
7058
7096
  }
7059
7097
  }
7060
7098
  _updateTransform() {
@@ -7080,8 +7118,24 @@ exports.Node2D = class Node2D extends exports.CanvasItem {
7080
7118
  transform = t3dT2d;
7081
7119
  }
7082
7120
  this._transform.set(transform);
7121
+ this._updateOverflow();
7083
7122
  this.requestReflow();
7084
7123
  }
7124
+ _updateOverflow() {
7125
+ if (this.style.overflow === "hidden") {
7126
+ const [a, c, tx, b, d, ty] = this._transform.toArray();
7127
+ const width = this.style.width;
7128
+ const height = this.style.height;
7129
+ this.mask = {
7130
+ x: tx,
7131
+ y: ty,
7132
+ width: a * width + c * height,
7133
+ height: b * width + d * height
7134
+ };
7135
+ } else {
7136
+ this.mask = void 0;
7137
+ }
7138
+ }
7085
7139
  _transformVertices(vertices) {
7086
7140
  const [a, c, tx, b, d, ty] = this._transform.toArray();
7087
7141
  const newVertices = vertices.slice();
@@ -7124,101 +7178,12 @@ exports.Node2D = class Node2D extends exports.CanvasItem {
7124
7178
  }
7125
7179
  }
7126
7180
  };
7127
- exports.Node2D = __decorateClass$p([
7128
- customNode("Node2D")
7129
- ], exports.Node2D);
7130
-
7131
- var __defProp$o = Object.defineProperty;
7132
- var __getOwnPropDesc$o = Object.getOwnPropertyDescriptor;
7133
- var __decorateClass$o = (decorators, target, key, kind) => {
7134
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$o(target, key) : target;
7135
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
7136
- if (decorator = decorators[i])
7137
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
7138
- if (kind && result) __defProp$o(target, key, result);
7139
- return result;
7140
- };
7141
- exports.Element2D = class Element2D extends exports.Node2D {
7142
- draggable;
7143
- _background;
7144
- constructor(options) {
7145
- super();
7146
- this.setProperties(options);
7147
- }
7148
- _onUpdateStyleProperty(key, value, oldValue) {
7149
- super._onUpdateStyleProperty(key, value, oldValue);
7150
- switch (key) {
7151
- case "backgroundImage":
7152
- this._updateBackground();
7153
- break;
7154
- case "borderRadius":
7155
- this.requestRedraw();
7156
- break;
7157
- case "overflow":
7158
- this._updateOverflow();
7159
- break;
7160
- }
7161
- }
7162
- async _updateBackground() {
7163
- this._background = await this.style.getComputedBackground();
7164
- this.requestRedraw();
7165
- }
7166
- _updateTransform() {
7167
- super._updateTransform();
7168
- this._updateOverflow();
7169
- }
7170
- _updateOverflow() {
7171
- if (this.style.overflow === "hidden") {
7172
- const [a, c, tx, b, d, ty] = this._transform.toArray();
7173
- const width = this.style.width;
7174
- const height = this.style.height;
7175
- this.mask = {
7176
- x: tx,
7177
- y: ty,
7178
- width: a * width + c * height,
7179
- height: b * width + d * height
7180
- };
7181
- } else {
7182
- this.mask = void 0;
7183
- }
7184
- }
7185
- _draw() {
7186
- super._draw();
7187
- this._drawBackground();
7188
- this._drawContent();
7189
- }
7190
- _drawBackground() {
7191
- const texture = this._background;
7192
- if (!texture?.valid)
7193
- return;
7194
- this.context.fillStyle = texture;
7195
- this.context.textureTransform = new Transform2D().scale(
7196
- this.style.width / texture.width,
7197
- this.style.height / texture.height
7198
- );
7199
- this._drawRect();
7200
- }
7201
- _drawContent() {
7202
- this._drawRect();
7203
- }
7204
- _drawRect() {
7205
- if (this.style.borderRadius) {
7206
- this.context.roundRect(0, 0, this.style.width, this.style.height, this.style.borderRadius);
7207
- } else {
7208
- this.context.rect(0, 0, this.style.width, this.style.height);
7209
- }
7210
- this.context.fill();
7211
- }
7212
- };
7213
- __decorateClass$o([
7214
- property()
7215
- ], exports.Element2D.prototype, "draggable", 2);
7216
- exports.Element2D = __decorateClass$o([
7181
+ exports.Node2D = __decorateClass$o([
7217
7182
  customNode({
7218
- tag: "Element2D",
7183
+ tag: "Node2D",
7219
7184
  renderable: true
7220
7185
  })
7221
- ], exports.Element2D);
7186
+ ], exports.Node2D);
7222
7187
 
7223
7188
  var __defProp$n = Object.defineProperty;
7224
7189
  var __getOwnPropDesc$n = Object.getOwnPropertyDescriptor;
@@ -7327,10 +7292,7 @@ __decorateClass$n([
7327
7292
  proxy({ method: true, redraw: true })
7328
7293
  ], exports.Graphics2D.prototype, "stroke", 2);
7329
7294
  exports.Graphics2D = __decorateClass$n([
7330
- customNode({
7331
- tag: "Graphics2D",
7332
- renderable: true
7333
- })
7295
+ customNode("Graphics2D")
7334
7296
  ], exports.Graphics2D);
7335
7297
 
7336
7298
  class Image2DResource extends Resource {
@@ -7369,7 +7331,7 @@ var __decorateClass$m = (decorators, target, key, kind) => {
7369
7331
  if (kind && result) __defProp$m(target, key, result);
7370
7332
  return result;
7371
7333
  };
7372
- exports.Image2D = class Image2D extends exports.Element2D {
7334
+ exports.Image2D = class Image2D extends exports.Node2D {
7373
7335
  resource;
7374
7336
  get currentTexture() {
7375
7337
  return this.resource?.frames[this._frameIndex]?.texture;
@@ -7488,7 +7450,7 @@ exports.Image2D = class Image2D extends exports.Element2D {
7488
7450
  const texture = this.currentTexture;
7489
7451
  return super._repaint(
7490
7452
  batchables.map((batchable, i) => {
7491
- if ((this._background ? i === 1 : i === 0) && batchable.type === "fill") {
7453
+ if ((this._backgroundImage ? i === 1 : i === 0) && batchable.type === "fill") {
7492
7454
  return {
7493
7455
  ...batchable,
7494
7456
  texture: texture?.valid ? texture : void 0
@@ -7522,7 +7484,7 @@ var __decorateClass$l = (decorators, target, key, kind) => {
7522
7484
  if (kind && result) __defProp$l(target, key, result);
7523
7485
  return result;
7524
7486
  };
7525
- exports.Lottie2D = class Lottie2D extends exports.Element2D {
7487
+ exports.Lottie2D = class Lottie2D extends exports.Node2D {
7526
7488
  duration = 0;
7527
7489
  texture = new Texture(document.createElement("canvas"));
7528
7490
  animation;
@@ -7594,7 +7556,7 @@ var __decorateClass$k = (decorators, target, key, kind) => {
7594
7556
  return result;
7595
7557
  };
7596
7558
  const textStyles = new Set(Object.keys(modernText.textDefaultStyle));
7597
- exports.Text2D = class Text2D extends exports.Element2D {
7559
+ exports.Text2D = class Text2D extends exports.Node2D {
7598
7560
  effects;
7599
7561
  texture = new Texture(document.createElement("canvas"));
7600
7562
  _subTextsCount = 0;
@@ -7754,7 +7716,7 @@ var __decorateClass$j = (decorators, target, key, kind) => {
7754
7716
  if (kind && result) __defProp$j(target, key, result);
7755
7717
  return result;
7756
7718
  };
7757
- exports.Video2D = class Video2D extends exports.Element2D {
7719
+ exports.Video2D = class Video2D extends exports.Node2D {
7758
7720
  texture;
7759
7721
  get duration() {
7760
7722
  return (this.texture?.duration ?? 0) * 1e3;
@@ -8920,7 +8882,7 @@ exports.Audio = __decorateClass$i([
8920
8882
  customNode("Audio")
8921
8883
  ], exports.Audio);
8922
8884
 
8923
- class AudioSpectrum extends exports.Element2D {
8885
+ class AudioSpectrum extends exports.Node2D {
8924
8886
  //
8925
8887
  }
8926
8888
 
@@ -8934,7 +8896,7 @@ var __decorateClass$h = (decorators, target, key, kind) => {
8934
8896
  if (kind && result) __defProp$h(target, key, result);
8935
8897
  return result;
8936
8898
  };
8937
- exports.AudioWaveform = class AudioWaveform extends exports.Element2D {
8899
+ exports.AudioWaveform = class AudioWaveform extends exports.Node2D {
8938
8900
  src;
8939
8901
  gap = 0;
8940
8902
  color = "#000000";