modern-canvas 0.2.0 → 0.2.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
@@ -1924,6 +1924,12 @@ class Rect2 {
1924
1924
  get top() {
1925
1925
  return this.position.y;
1926
1926
  }
1927
+ get right() {
1928
+ return this.x + this.width;
1929
+ }
1930
+ get bottom() {
1931
+ return this.y + this.height;
1932
+ }
1927
1933
  get width() {
1928
1934
  return this.size.x;
1929
1935
  }
@@ -1964,6 +1970,9 @@ class Rect2 {
1964
1970
  );
1965
1971
  return this;
1966
1972
  }
1973
+ toArray() {
1974
+ return [this.x, this.y, this.width, this.height];
1975
+ }
1967
1976
  }
1968
1977
 
1969
1978
  class Transform2D extends Matrix3 {
@@ -5269,10 +5278,10 @@ class CanvasTexture extends Texture2D {
5269
5278
  _updateProperty(key, value, oldValue, declaration) {
5270
5279
  switch (key) {
5271
5280
  case "width":
5272
- this.source.width = value * this.pixelRatio;
5281
+ this.source.width = Math.max(1, Math.ceil(value * this.pixelRatio));
5273
5282
  break;
5274
5283
  case "height":
5275
- this.source.height = value * this.pixelRatio;
5284
+ this.source.height = Math.max(1, Math.ceil(value * this.pixelRatio));
5276
5285
  break;
5277
5286
  }
5278
5287
  super._updateProperty(key, value, oldValue, declaration);
@@ -5966,9 +5975,6 @@ exports.Node = class Node extends CoreObject {
5966
5975
  }
5967
5976
  /** Children */
5968
5977
  _children = [];
5969
- get children() {
5970
- return this.getChildren();
5971
- }
5972
5978
  get siblingIndex() {
5973
5979
  return this.getIndex();
5974
5980
  }
@@ -6233,17 +6239,17 @@ exports.Node = class Node extends CoreObject {
6233
6239
  return this;
6234
6240
  }
6235
6241
  removeChildren() {
6236
- this.children.forEach((child) => this.removeChild(child));
6242
+ this.getChildren().forEach((child) => this.removeChild(child));
6237
6243
  }
6238
6244
  remove() {
6239
6245
  this._parent?.removeChild(this);
6240
6246
  }
6241
6247
  forEach(fn) {
6242
- this.children.forEach(fn);
6248
+ this.getChildren().forEach(fn);
6243
6249
  return this;
6244
6250
  }
6245
6251
  deepForEach(fn) {
6246
- this.children.forEach((child) => {
6252
+ this.getChildren().forEach((child) => {
6247
6253
  fn(child);
6248
6254
  child.deepForEach(fn);
6249
6255
  });
@@ -6280,7 +6286,7 @@ exports.Node = class Node extends CoreObject {
6280
6286
  return {
6281
6287
  tag: this.tag,
6282
6288
  props: super.toJSON(),
6283
- children: this.children.map((child) => child.toJSON())
6289
+ children: this.getChildren().map((child) => child.toJSON())
6284
6290
  };
6285
6291
  }
6286
6292
  static parse(JSON) {
@@ -6417,7 +6423,6 @@ exports.CanvasItem = class CanvasItem extends exports.TimelineNode {
6417
6423
  }
6418
6424
  /** @internal */
6419
6425
  opacity = 1;
6420
- size = { width: 0, height: 0 };
6421
6426
  _parentOpacity;
6422
6427
  _modulate = new Color(4294967295);
6423
6428
  _backgroundImage;
@@ -6481,19 +6486,6 @@ exports.CanvasItem = class CanvasItem extends exports.TimelineNode {
6481
6486
  case "visibility":
6482
6487
  this.visible = value === "visible";
6483
6488
  break;
6484
- case "width":
6485
- case "height":
6486
- this._updateSize();
6487
- break;
6488
- }
6489
- }
6490
- _updateSize() {
6491
- if (this.inheritSize) {
6492
- this.size.width = this.style.width || this._parent?.size?.width || this._parent?.width;
6493
- this.size.height = this.style.height || this._parent?.size?.height || this._parent?.height;
6494
- } else {
6495
- this.size.width = this.style.width;
6496
- this.size.height = this.style.height;
6497
6489
  }
6498
6490
  }
6499
6491
  _updateBackgroundColor() {
@@ -6509,14 +6501,10 @@ exports.CanvasItem = class CanvasItem extends exports.TimelineNode {
6509
6501
  this.requestRedraw();
6510
6502
  }
6511
6503
  _updateOpacity() {
6512
- const parentOpacity = this._parent?.opacity;
6513
- if (parentOpacity !== this._parentOpacity) {
6514
- this._parentOpacity = parentOpacity;
6515
- const opacity = this.style.getComputedOpacity() * (this._parent?.opacity ?? 1);
6516
- if (this.opacity !== opacity) {
6517
- this.opacity = opacity;
6518
- this.requestRepaint();
6519
- }
6504
+ const opacity = this.style.getComputedOpacity() * (this._parent?.opacity ?? 1);
6505
+ if (this.opacity !== opacity) {
6506
+ this.opacity = opacity;
6507
+ this.requestRepaint();
6520
6508
  }
6521
6509
  }
6522
6510
  _updateVisible() {
@@ -6549,9 +6537,10 @@ exports.CanvasItem = class CanvasItem extends exports.TimelineNode {
6549
6537
  }
6550
6538
  _process(delta) {
6551
6539
  this._updateVisible();
6552
- this._updateOpacity();
6553
- if (this.inheritSize && (!this.size.width || !this.size.height || this.size.width !== this.style.width || this.size.height !== this.style.height)) {
6554
- this._updateSize();
6540
+ const parentOpacity = this._parent?.opacity;
6541
+ if (parentOpacity !== this._parentOpacity) {
6542
+ this._parentOpacity = parentOpacity;
6543
+ this._updateOpacity();
6555
6544
  }
6556
6545
  super._process(delta);
6557
6546
  }
@@ -6590,8 +6579,7 @@ exports.CanvasItem = class CanvasItem extends exports.TimelineNode {
6590
6579
  }
6591
6580
  }
6592
6581
  _drawBoundingRect() {
6593
- const { borderRadius } = this.style;
6594
- const { width, height } = this.size;
6582
+ const { borderRadius, width, height } = this.style;
6595
6583
  if (width && height) {
6596
6584
  if (borderRadius) {
6597
6585
  this.context.roundRect(0, 0, width, height, borderRadius);
@@ -6679,9 +6667,6 @@ __decorateClass$y([
6679
6667
  __decorateClass$y([
6680
6668
  property()
6681
6669
  ], exports.CanvasItem.prototype, "blendMode", 2);
6682
- __decorateClass$y([
6683
- property()
6684
- ], exports.CanvasItem.prototype, "inheritSize", 2);
6685
6670
  exports.CanvasItem = __decorateClass$y([
6686
6671
  customNode("CanvasItem")
6687
6672
  ], exports.CanvasItem);
@@ -6843,11 +6828,13 @@ exports.Viewport = class Viewport extends exports.Node {
6843
6828
  case "y":
6844
6829
  this.requestUpload();
6845
6830
  this._projection.translate(this.x, this.y);
6831
+ this.emit("updateRect");
6846
6832
  break;
6847
6833
  case "width":
6848
6834
  case "height":
6849
6835
  this.requestUpload();
6850
6836
  this._projection.resize(this.width, this.height);
6837
+ this.emit("updateRect");
6851
6838
  break;
6852
6839
  }
6853
6840
  }
@@ -6916,6 +6903,9 @@ exports.Viewport = class Viewport extends exports.Node {
6916
6903
  this._tree?.setCurrentViewport(undefined);
6917
6904
  }
6918
6905
  }
6906
+ getRect() {
6907
+ return new Rect2(this.x, this.y, this.width, this.height);
6908
+ }
6919
6909
  toProjectionArray(transpose = false) {
6920
6910
  return this._projection.toArray(transpose);
6921
6911
  }
@@ -7660,7 +7650,7 @@ exports.Text2D = class Text2D extends TextureRect2D {
7660
7650
  }
7661
7651
  _drawContent() {
7662
7652
  if (!this.split) {
7663
- const onText2DRender = this.children?.find((child) => "onText2DRender" in child)?.onText2DRender;
7653
+ const onText2DRender = this.getChildren()?.find((child) => "onText2DRender" in child)?.onText2DRender;
7664
7654
  if (onText2DRender) {
7665
7655
  onText2DRender();
7666
7656
  } else {
@@ -7850,7 +7840,7 @@ exports.Animation = class Animation extends exports.TimelineNode {
7850
7840
  _updateProperty(key, value, oldValue, declaration) {
7851
7841
  super._updateProperty(key, value, oldValue, declaration);
7852
7842
  switch (key) {
7853
- case "mode":
7843
+ case "animationMode":
7854
7844
  case "keyframes":
7855
7845
  this._updateKeyframes();
7856
7846
  break;
@@ -9508,7 +9498,7 @@ exports.Effect = class Effect extends exports.TimelineNode {
9508
9498
  _parseTargetArea() {
9509
9499
  if (this._mode === "parent" && this._parent && "getRect" in this._parent) {
9510
9500
  const rect = this._parent.getRect();
9511
- if (rect instanceof Rect2) {
9501
+ if (rect) {
9512
9502
  return [
9513
9503
  rect.left / this.viewport1.width,
9514
9504
  rect.top / this.viewport1.height,
@@ -11363,13 +11353,40 @@ var __decorateClass$3 = (decorators, target, key, kind) => {
11363
11353
  exports.Control = class Control extends exports.CanvasItem {
11364
11354
  constructor(properties, children = []) {
11365
11355
  super();
11356
+ this._parentUpdateRect = this._parentUpdateRect.bind(this);
11366
11357
  this.setProperties(properties);
11367
11358
  this.append(children);
11368
11359
  }
11360
+ _parented(parent) {
11361
+ super._parented(parent);
11362
+ parent.on("updateRect", this._parentUpdateRect);
11363
+ }
11364
+ _unparented(oldParent) {
11365
+ super._unparented(oldParent);
11366
+ oldParent.off("updateRect", this._parentUpdateRect);
11367
+ }
11368
+ _parentUpdateRect() {
11369
+ const rect = this._parent.getRect();
11370
+ this.style.left = rect.left;
11371
+ this.style.top = rect.top;
11372
+ this.style.width = rect.width;
11373
+ this.style.height = rect.height;
11374
+ }
11369
11375
  _input(event, key) {
11370
11376
  super._input(event, key);
11371
11377
  this._guiInput(event, key);
11372
11378
  }
11379
+ _updateStyleProperty(key, value, oldValue, declaration) {
11380
+ super._updateStyleProperty(key, value, oldValue, declaration);
11381
+ switch (key) {
11382
+ case "width":
11383
+ case "height":
11384
+ case "left":
11385
+ case "top":
11386
+ this.emit("updateRect");
11387
+ break;
11388
+ }
11389
+ }
11373
11390
  // eslint-disable-next-line unused-imports/no-unused-vars
11374
11391
  _guiInput(event, key) {
11375
11392
  }
@@ -11414,7 +11431,6 @@ exports.Ruler = class Ruler extends exports.Control {
11414
11431
  _updateProperty(key, value, oldValue, declaration) {
11415
11432
  super._updateProperty(key, value, oldValue, declaration);
11416
11433
  switch (key) {
11417
- case "pixelRatio":
11418
11434
  case "offsetX":
11419
11435
  case "offsetY":
11420
11436
  case "thickness":
@@ -11423,20 +11439,27 @@ exports.Ruler = class Ruler extends exports.Control {
11423
11439
  case "markBackgroundColor":
11424
11440
  case "markColor":
11425
11441
  case "gap":
11442
+ case "scale":
11426
11443
  this.requestRedraw();
11427
11444
  break;
11428
11445
  }
11429
11446
  }
11430
- _updateSize() {
11431
- super._updateSize();
11432
- this.requestRedraw();
11447
+ _updateStyleProperty(key, value, oldValue, declaration) {
11448
+ super._updateStyleProperty(key, value, oldValue, declaration);
11449
+ switch (key) {
11450
+ case "width":
11451
+ case "height":
11452
+ this.texture[key] = value;
11453
+ this.requestRedraw();
11454
+ break;
11455
+ }
11433
11456
  }
11434
11457
  _drawTexture() {
11435
- const { width, height } = this.size;
11436
- this.style.width = width;
11437
- this.style.height = height;
11438
11458
  const {
11439
- pixelRatio,
11459
+ width,
11460
+ height
11461
+ } = this.style;
11462
+ const {
11440
11463
  offsetX,
11441
11464
  offsetY,
11442
11465
  thickness,
@@ -11444,14 +11467,13 @@ exports.Ruler = class Ruler extends exports.Control {
11444
11467
  markBackgroundColor,
11445
11468
  markColor,
11446
11469
  color,
11447
- gap: _gap
11470
+ gap: _gap,
11471
+ scale: _scale
11448
11472
  } = this;
11449
- const _scale = 1;
11450
11473
  const canvas = this.texture.source;
11451
- canvas.width = Math.max(1, Math.ceil(width * pixelRatio));
11452
- canvas.height = Math.max(1, Math.ceil(height * pixelRatio));
11453
11474
  const ctx = canvas.getContext("2d");
11454
- ctx.scale(this.pixelRatio, this.pixelRatio);
11475
+ ctx.reset();
11476
+ ctx.scale(this.texture.pixelRatio, this.texture.pixelRatio);
11455
11477
  const x = Math.round(offsetX);
11456
11478
  const y = Math.round(offsetY);
11457
11479
  ctx.beginPath();
@@ -11533,7 +11555,7 @@ exports.Ruler = class Ruler extends exports.Control {
11533
11555
  ctx.stroke();
11534
11556
  this.texture.requestUpload();
11535
11557
  }
11536
- _drawContent() {
11558
+ _draw() {
11537
11559
  this._drawTexture();
11538
11560
  const texture = this.texture;
11539
11561
  if (texture?.valid) {
@@ -11542,13 +11564,11 @@ exports.Ruler = class Ruler extends exports.Control {
11542
11564
  this.style.width / texture.width,
11543
11565
  this.style.height / texture.height
11544
11566
  );
11545
- super._drawContent();
11567
+ this.context.rect(0, 0, texture.width, texture.height);
11568
+ this.context.fill();
11546
11569
  }
11547
11570
  }
11548
11571
  };
11549
- __decorateClass$2([
11550
- property({ default: 2 })
11551
- ], exports.Ruler.prototype, "pixelRatio", 2);
11552
11572
  __decorateClass$2([
11553
11573
  property({ default: 0 })
11554
11574
  ], exports.Ruler.prototype, "offsetX", 2);
@@ -11573,6 +11593,9 @@ __decorateClass$2([
11573
11593
  __decorateClass$2([
11574
11594
  property({ default: 300 })
11575
11595
  ], exports.Ruler.prototype, "gap", 2);
11596
+ __decorateClass$2([
11597
+ property({ default: 1 })
11598
+ ], exports.Ruler.prototype, "scale", 2);
11576
11599
  exports.Ruler = __decorateClass$2([
11577
11600
  customNode("Ruler")
11578
11601
  ], exports.Ruler);
@@ -11588,8 +11611,49 @@ var __decorateClass$1 = (decorators, target, key, kind) => {
11588
11611
  return result;
11589
11612
  };
11590
11613
  exports.ScrollBar = class ScrollBar extends exports.Control {
11591
- //
11614
+ constructor(properties, children = []) {
11615
+ super();
11616
+ this.setProperties(properties).append(children);
11617
+ }
11618
+ _parentUpdateRect() {
11619
+ super._parentUpdateRect();
11620
+ const rect = this._parent.getRect();
11621
+ if (rect && rect.width && rect.height) {
11622
+ if (this.direction === "vertical") {
11623
+ this.style.width = 10;
11624
+ this.style.height = rect.height - this.padding * 2;
11625
+ this.style.left = rect.right - this.style.width;
11626
+ this.style.top = this.padding;
11627
+ } else {
11628
+ this.style.height = 10;
11629
+ this.style.width = rect.width - this.padding * 2;
11630
+ this.style.left = this.padding;
11631
+ this.style.top = rect.bottom - this.style.height;
11632
+ }
11633
+ }
11634
+ this.requestRedraw();
11635
+ }
11636
+ _guiInput(event, key) {
11637
+ super._guiInput(event, key);
11638
+ }
11639
+ _draw() {
11640
+ this.context.roundRect(
11641
+ this.style.left,
11642
+ this.style.top,
11643
+ this.style.width,
11644
+ this.style.height,
11645
+ this.style.borderRadius ?? 20
11646
+ );
11647
+ this.context.fillStyle = 15;
11648
+ this.context.fill();
11649
+ }
11592
11650
  };
11651
+ __decorateClass$1([
11652
+ property({ default: "vertical" })
11653
+ ], exports.ScrollBar.prototype, "direction", 2);
11654
+ __decorateClass$1([
11655
+ property({ default: 10 })
11656
+ ], exports.ScrollBar.prototype, "padding", 2);
11593
11657
  exports.ScrollBar = __decorateClass$1([
11594
11658
  customNode("ScrollBar")
11595
11659
  ], exports.ScrollBar);
@@ -12008,7 +12072,7 @@ class Assets {
12008
12072
  }
12009
12073
  const assets = new Assets().use(new FontLoader()).use(new GifLoader()).use(new JsonLoader()).use(new LottieLoader()).use(new TextLoader()).use(new TextureLoader()).use(new VideoLoader());
12010
12074
 
12011
- class CanvasEditor extends exports.CanvasItem {
12075
+ class CanvasEditor extends exports.Control {
12012
12076
  name = "CanvasEditor";
12013
12077
  hover = new exports.Node2D({
12014
12078
  name: "hover",
@@ -12041,13 +12105,15 @@ class CanvasEditor extends exports.CanvasItem {
12041
12105
  scaler = new exports.Scaler({
12042
12106
  internalMode: "back"
12043
12107
  }).on("updateScale", (scale) => {
12044
- this.ruler.gap = scale * 300;
12108
+ this.ruler.scale = scale;
12045
12109
  });
12046
12110
  xScrollBar = new exports.ScrollBar({
12047
- internalMode: "back"
12111
+ internalMode: "back",
12112
+ direction: "horizontal"
12048
12113
  });
12049
12114
  yScrollBar = new exports.ScrollBar({
12050
- internalMode: "back"
12115
+ internalMode: "back",
12116
+ direction: "vertical"
12051
12117
  });
12052
12118
  drawboard = new exports.Node2D({
12053
12119
  name: "drawboard",
@@ -12069,8 +12135,7 @@ class CanvasEditor extends exports.CanvasItem {
12069
12135
  ruler = new exports.Ruler({
12070
12136
  name: "ruler",
12071
12137
  offsetX: 100,
12072
- offsetY: 100,
12073
- inheritSize: true
12138
+ offsetY: 100
12074
12139
  }).append(
12075
12140
  this.drawboard,
12076
12141
  this.hover,
@@ -12087,10 +12152,9 @@ class CanvasEditor extends exports.CanvasItem {
12087
12152
  this._onPointermove = this._onPointermove.bind(this);
12088
12153
  this._onPointerup = this._onPointerup.bind(this);
12089
12154
  this.append(this.ruler);
12090
- this.inheritSize = true;
12091
12155
  }
12092
- _input(event, key) {
12093
- super._input(event, key);
12156
+ _guiInput(event, key) {
12157
+ super._guiInput(event, key);
12094
12158
  switch (key) {
12095
12159
  case "pointerdown":
12096
12160
  this._onPointerdown(event);
package/dist/index.d.cts CHANGED
@@ -474,6 +474,8 @@ declare class Rect2 {
474
474
  get y(): number;
475
475
  get left(): number;
476
476
  get top(): number;
477
+ get right(): number;
478
+ get bottom(): number;
477
479
  get width(): number;
478
480
  get height(): number;
479
481
  readonly end: Vector2;
@@ -483,6 +485,7 @@ declare class Rect2 {
483
485
  constructor(position: Vector2, size: Vector2);
484
486
  constructor(x: number, y: number, width: number, height: number);
485
487
  update(): this;
488
+ toArray(): number[];
486
489
  }
487
490
 
488
491
  interface Transform2DObject {
@@ -1350,7 +1353,7 @@ declare class ImageTexture extends Texture2D<HTMLImageElement> {
1350
1353
  }
1351
1354
 
1352
1355
  declare class PixelsTexture extends Texture2D<Texture2DPixelsSource> {
1353
- constructor(pixels?: ArrayLike<number> | ArrayBufferLike | ArrayBufferView | null, width?: number, height?: number);
1356
+ constructor(pixels?: number[] | ArrayBufferLike | ArrayBufferView | null, width?: number, height?: number);
1354
1357
  protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
1355
1358
  }
1356
1359
 
@@ -1540,11 +1543,30 @@ declare class Timeline extends Node {
1540
1543
  protected _process(delta: number): void;
1541
1544
  }
1542
1545
 
1546
+ interface RectangulableEventMap {
1547
+ updateRect: () => void;
1548
+ }
1549
+ interface Rectangulable {
1550
+ on: (<K extends keyof RectangulableEventMap>(type: K, listener: RectangulableEventMap[K], options?: EventListenerOptions) => this) & ((type: string, listener: EventListenerValue, options?: EventListenerOptions) => this);
1551
+ off: (<K extends keyof RectangulableEventMap>(type: K, listener: RectangulableEventMap[K], options?: EventListenerOptions) => this) & ((type: string, listener: EventListenerValue, options?: EventListenerOptions) => this);
1552
+ emit: (<K extends keyof RectangulableEventMap>(type: K, ...args: Parameters<RectangulableEventMap[K]>) => boolean) & ((type: string, ...args: any[]) => boolean);
1553
+ }
1554
+ interface Rectangulable {
1555
+ getRect: () => Rect2;
1556
+ }
1557
+
1558
+ interface ViewportEventMap extends NodeEventMap, RectangulableEventMap {
1559
+ }
1543
1560
  interface ViewportFramebuffer {
1544
1561
  texture: ViewportTexture;
1545
1562
  needsUpload: boolean;
1546
1563
  }
1547
- declare class Viewport extends Node {
1564
+ interface Viewport {
1565
+ on: (<K extends keyof ViewportEventMap>(type: K, listener: ViewportEventMap[K], options?: EventListenerOptions) => this) & ((type: string, listener: EventListenerValue, options?: EventListenerOptions) => this);
1566
+ off: (<K extends keyof ViewportEventMap>(type: K, listener: ViewportEventMap[K], options?: EventListenerOptions) => this) & ((type: string, listener: EventListenerValue, options?: EventListenerOptions) => this);
1567
+ emit: (<K extends keyof ViewportEventMap>(type: K, ...args: Parameters<ViewportEventMap[K]>) => boolean) & ((type: string, ...args: any[]) => boolean);
1568
+ }
1569
+ declare class Viewport extends Node implements Rectangulable {
1548
1570
  flipY: boolean;
1549
1571
  x: number;
1550
1572
  y: number;
@@ -1569,6 +1591,7 @@ declare class Viewport extends Node {
1569
1591
  redraw(renderer: WebGLRenderer, cb: () => void): boolean;
1570
1592
  activateWithCopy(renderer: WebGLRenderer, target: Viewport): void;
1571
1593
  render(renderer: WebGLRenderer, next?: () => void): void;
1594
+ getRect(): Rect2;
1572
1595
  toProjectionArray(transpose?: boolean): number[];
1573
1596
  }
1574
1597
 
@@ -1663,7 +1686,6 @@ declare class Node extends CoreObject {
1663
1686
  setParent(parent: Node | undefined): this;
1664
1687
  /** Children */
1665
1688
  protected _children: Node[];
1666
- get children(): Node[];
1667
1689
  get siblingIndex(): number;
1668
1690
  set siblingIndex(toIndex: number);
1669
1691
  get previousSibling(): Node | undefined;
@@ -1758,10 +1780,9 @@ interface CanvasItemProperties extends TimelineNodeProperties {
1758
1780
  style: Partial<CanvasItemStyleProperties>;
1759
1781
  modulate: ColorValue;
1760
1782
  blendMode: WebGLBlendMode;
1761
- inheritSize: boolean;
1762
1783
  }
1763
1784
  interface CanvasItemEventMap extends TimelineNodeEventMap {
1764
- updateStyleProperty: (key: PropertyKey, newValue: any, oldValue: any, declaration?: PropertyDeclaration) => void;
1785
+ updateStyleProperty: (key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration) => void;
1765
1786
  draw: () => void;
1766
1787
  }
1767
1788
  interface CanvasItem {
@@ -1773,16 +1794,11 @@ declare class CanvasItem extends TimelineNode {
1773
1794
  visible: boolean;
1774
1795
  modulate?: ColorValue;
1775
1796
  blendMode?: WebGLBlendMode;
1776
- inheritSize?: boolean;
1777
1797
  protected _style: CanvasItemStyle;
1778
1798
  get style(): CanvasItemStyle;
1779
1799
  set style(style: CanvasItemStyle);
1780
1800
  /** @internal */
1781
1801
  opacity: number;
1782
- size: {
1783
- width: number;
1784
- height: number;
1785
- };
1786
1802
  protected _parentOpacity?: number;
1787
1803
  protected _modulate: Color;
1788
1804
  protected _backgroundImage?: Texture2D;
@@ -1799,7 +1815,6 @@ declare class CanvasItem extends TimelineNode {
1799
1815
  setProperties(properties?: Record<PropertyKey, any>): this;
1800
1816
  protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
1801
1817
  protected _updateStyleProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
1802
- protected _updateSize(): void;
1803
1818
  protected _updateBackgroundColor(): void;
1804
1819
  protected _updateBackgroundImage(): Promise<void>;
1805
1820
  protected _updateOpacity(): void;
@@ -1909,13 +1924,13 @@ declare class Image2D extends Node2D {
1909
1924
 
1910
1925
  interface TextureRect2DProperties extends Node2DProperties {
1911
1926
  }
1912
- declare class TextureRect2D<T extends Texture2D = Texture2D> extends Node2D {
1927
+ declare class TextureRect2D<T extends Texture2D = Texture2D> extends Node2D implements Rectangulable {
1913
1928
  texture?: T;
1914
1929
  getRect(): Rect2;
1915
1930
  protected _drawContent(): void;
1916
1931
  }
1917
1932
 
1918
- interface Lottie2DProperties extends Node2DProperties {
1933
+ interface Lottie2DProperties extends TextureRect2DProperties {
1919
1934
  src: string;
1920
1935
  }
1921
1936
  declare class Lottie2D extends TextureRect2D {
@@ -1929,7 +1944,7 @@ declare class Lottie2D extends TextureRect2D {
1929
1944
  protected _process(delta: number): void;
1930
1945
  }
1931
1946
 
1932
- interface Text2DProperties extends Node2DProperties, Omit<TextOptions, 'style'> {
1947
+ interface Text2DProperties extends TextureRect2DProperties, Omit<TextOptions, 'style'> {
1933
1948
  split: boolean;
1934
1949
  }
1935
1950
  /**
@@ -1962,7 +1977,7 @@ declare class Text2D extends TextureRect2D<CanvasTexture> {
1962
1977
  protected _drawContent(): void;
1963
1978
  }
1964
1979
 
1965
- interface Video2DProperties extends Node2DProperties {
1980
+ interface Video2DProperties extends TextureRect2DProperties {
1966
1981
  src: string;
1967
1982
  }
1968
1983
  declare class Video2D extends TextureRect2D<VideoTexture> {
@@ -2560,17 +2575,27 @@ declare class ZoomBlurEffect extends Effect {
2560
2575
  apply(renderer: WebGLRenderer, source: Viewport): void;
2561
2576
  }
2562
2577
 
2578
+ interface ControlEventMap extends CanvasItemEventMap, RectangulableEventMap {
2579
+ }
2563
2580
  interface ControlProperties extends CanvasItemProperties {
2564
2581
  }
2565
- declare class Control extends CanvasItem {
2582
+ interface Control {
2583
+ on: (<K extends keyof ControlEventMap>(type: K, listener: ControlEventMap[K], options?: EventListenerOptions) => this) & ((type: string, listener: EventListenerValue, options?: EventListenerOptions) => this);
2584
+ off: (<K extends keyof ControlEventMap>(type: K, listener: ControlEventMap[K], options?: EventListenerOptions) => this) & ((type: string, listener: EventListenerValue, options?: EventListenerOptions) => this);
2585
+ emit: (<K extends keyof ControlEventMap>(type: K, ...args: Parameters<ControlEventMap[K]>) => boolean) & ((type: string, ...args: any[]) => boolean);
2586
+ }
2587
+ declare class Control extends CanvasItem implements Rectangulable {
2566
2588
  constructor(properties?: Partial<ControlProperties>, children?: Node[]);
2589
+ protected _parented(parent: any): void;
2590
+ protected _unparented(oldParent: any): void;
2591
+ protected _parentUpdateRect(): void;
2567
2592
  protected _input(event: InputEvent, key: InputEventKey): void;
2593
+ protected _updateStyleProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
2568
2594
  protected _guiInput(event: InputEvent, key: InputEventKey): void;
2569
2595
  getRect(): Rect2;
2570
2596
  }
2571
2597
 
2572
2598
  interface RulerProperties extends ControlProperties {
2573
- pixelRatio: number;
2574
2599
  offsetX: number;
2575
2600
  offsetY: number;
2576
2601
  thickness: number;
@@ -2579,9 +2604,9 @@ interface RulerProperties extends ControlProperties {
2579
2604
  markBackgroundColor: string;
2580
2605
  markColor: string;
2581
2606
  gap: number;
2607
+ scale: number;
2582
2608
  }
2583
2609
  declare class Ruler extends Control {
2584
- pixelRatio: number;
2585
2610
  offsetX: number;
2586
2611
  offsetY: number;
2587
2612
  thickness: number;
@@ -2590,17 +2615,25 @@ declare class Ruler extends Control {
2590
2615
  markBackgroundColor: string;
2591
2616
  markColor: string;
2592
2617
  gap: number;
2618
+ scale: number;
2593
2619
  texture: CanvasTexture;
2594
2620
  constructor(properties?: Partial<RulerProperties>, children?: Node[]);
2595
2621
  protected _updateProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
2596
- protected _updateSize(): void;
2622
+ protected _updateStyleProperty(key: PropertyKey, value: any, oldValue: any, declaration?: PropertyDeclaration): void;
2597
2623
  protected _drawTexture(): void;
2598
- protected _drawContent(): void;
2624
+ protected _draw(): void;
2599
2625
  }
2600
2626
 
2601
2627
  interface ScrollBarProperties extends ControlProperties {
2628
+ direction: 'vertical' | 'horizontal';
2602
2629
  }
2603
2630
  declare class ScrollBar extends Control {
2631
+ direction: 'vertical' | 'horizontal';
2632
+ padding: number;
2633
+ constructor(properties: Partial<ScrollBarProperties>, children?: Node[]);
2634
+ protected _parentUpdateRect(): void;
2635
+ protected _guiInput(event: InputEvent, key: InputEventKey): void;
2636
+ protected _draw(): void;
2604
2637
  }
2605
2638
 
2606
2639
  interface ScalerEventMap extends NodeEventMap {
@@ -2686,7 +2719,7 @@ declare class Assets {
2686
2719
  }
2687
2720
  declare const assets: Assets;
2688
2721
 
2689
- declare class CanvasEditor extends CanvasItem {
2722
+ declare class CanvasEditor extends Control {
2690
2723
  name: string;
2691
2724
  hover: Node2D;
2692
2725
  selectionRect: Node2D;
@@ -2703,7 +2736,7 @@ declare class CanvasEditor extends CanvasItem {
2703
2736
  };
2704
2737
  selected?: CanvasItem;
2705
2738
  constructor();
2706
- protected _input(event: InputEvent, key: InputEventKey): void;
2739
+ protected _guiInput(event: InputEvent, key: InputEventKey): void;
2707
2740
  protected _onPointerdown(e: PointerInputEvent): void;
2708
2741
  protected _onPointermove(e: PointerInputEvent): void;
2709
2742
  protected _onPointerup(): void;
@@ -2777,4 +2810,4 @@ interface RenderOptions {
2777
2810
  }
2778
2811
  declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
2779
2812
 
2780
- export { Animation, type AnimationMode, type AnimationProperties, type AssetHandler, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, type AudioWaveformProperties, type Batchable2D, BlurEffect, type CanvasBatchable, CanvasContext, CanvasEditor, CanvasItem, type CanvasItemEventMap, type CanvasItemProperties, CanvasItemStyle, type CanvasItemStyleFilter, type CanvasItemStyleFilterKey, type CanvasItemStyleProperties, CanvasTexture, Color, ColorAdjustEffect, ColorFilterEffect, type ColorFilterEffectProperties, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, type ColorValue, Control, type ControlProperties, CoreObject, type CoreObjectEventMap, type CssFunction, type CssFunctionArg, type Cursor, DEG_TO_RAD, DEVICE_PIXEL_RATIO, type Easing, Effect, type EffectContext, EffectMaterial, type EffectMode, type EffectOptions, EmbossEffect, Engine, type EngineOptions, EventEmitter, type EventListener, type EventListenerOptions, type EventListenerValue, type FilledGraphics, FontLoader, Geometry, type GeometryOptions, GifLoader, GlitchEffect, GodrayEffect, Graphics2D, HTMLAudio, HTMLAudioContext, HTMLSound, type IAudioContext, type IAudioNode, IN_BROWSER, type IPlayOptions, Image2D, type Image2DProperties, Image2DResource, type ImageFrame, ImageTexture, type ImageTextureOptions, IndexBuffer, type IndexBufferOptions, Input, InputEvent, type InputEventKey, type InputEventMap, type InternalMode, JsonLoader, KawaseEffect, type Keyframe, LeftEraseEffect, Loader, Lottie2D, type Lottie2DProperties, LottieLoader, MainLoop, type MainLoopEventMap, type MaskColor, type MaskData, MaskEffect, type MaskEffectOptions, type MaskObject, type MaskRect, type Maskable, Material, type MaterialOptions, Matrix, Matrix2, Matrix3, Matrix4, type MatrixLike, type MatrixOperateOutput, MouseInputEvent, Node, Node2D, type Node2DProperties, type NodeEventMap, type NodeProperties, type NormalizedKeyframe, PI, PI_2, PixelateEffect, PixelsTexture, type PlatformAudio, type PlatformSound, type PointerEvents, PointerInputEvent, type ProcessMode, Projection2D, type PropertyDeclaration, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, RawWeakMap, Rect2, RefCounted, type RefCountedEventMap, type RenderMode, type RenderOptions, type Renderable, Renderer, Resource, type ResourceEventMap, Ruler, type RulerProperties, SUPPORTS_AUDIO_CONTEXT, SUPPORTS_CLICK_EVENTS, SUPPORTS_CREATE_IMAGE_BITMAP, SUPPORTS_IMAGE_BITMAP, SUPPORTS_MOUSE_EVENTS, SUPPORTS_OFFLINE_AUDIO_CONTEXT, SUPPORTS_POINTER_EVENTS, SUPPORTS_RESIZE_OBSERVER, SUPPORTS_TOUCH_EVENTS, SUPPORTS_WEBGL2, SUPPORTS_WEBKIT_AUDIO_CONTEXT, SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT, SUPPORTS_WEB_AUDIO, SUPPORTS_WHEEL_EVENTS, Scaler, type ScalerEventMap, type ScalerProperties, SceneTree, type SceneTreeEventMap, ScrollBar, type ScrollBarProperties, ShadowEffect, type StrokedGraphics, Text2D, type Text2DProperties, TextLoader, Texture2D, type Texture2DFilterMode, type Texture2DPixelsSource, type Texture2DSource, type Texture2DWrapMode, TextureLoader, TextureRect2D, type TextureRect2DProperties, Ticker, TiltShiftEffect, Timeline, type TimelineEventMap, TimelineNode, type TimelineNodeEventMap, type TimelineNodeProperties, type TimelineProperties, type TimingFunctions, Transform2D, type Transform2DObject, TwistEffect, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, type VectorLike, type VectorOperateOutput, VertexAttribute, type VertexAttributeOptions, VertexBuffer, type VertexBufferOptions, Video2D, type Video2DProperties, VideoLoader, VideoTexture, type VideoTextureOptions, type VideoTextureSource, Viewport, type ViewportFramebuffer, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, type WebGLBufferMeta, WebGLBufferModule, type WebGLBufferOptions, type WebGLBufferTarget, type WebGLBufferUsage, type WebGLDrawMode, type WebGLDrawOptions, type WebGLExtensions, type WebGLFramebufferMeta, WebGLFramebufferModule, type WebGLFramebufferOptions, WebGLMaskModule, WebGLModule, type WebGLProgramMeta, WebGLProgramModule, type WebGLProgramOptions, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, type WebGLTarget, type WebGLTextureFilterMode, type WebGLTextureLocation, type WebGLTextureMeta, WebGLTextureModule, type WebGLTextureOptions, type WebGLTextureSource, type WebGLTextureTarget, type WebGLTextureWrapMode, WebGLVertexArrayModule, type WebGLVertexArrayObjectMeta, type WebGLVertexArrayObjectOptions, type WebGLVertexAttrib, type WebGLVertexAttribType, type WebGLViewport, WebGLViewportModule, WebSound, WheelInputEvent, ZoomBlurEffect, assets, clamp, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions, defineProperty, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, getDeclarations, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCssFunctions, parseCssProperty, property, protectedProperty, render, timingFunctions, uid };
2813
+ export { Animation, type AnimationMode, type AnimationProperties, type AssetHandler, Assets, Audio, AudioPipeline, AudioProcessor, AudioSpectrum, AudioWaveform, type AudioWaveformProperties, type Batchable2D, BlurEffect, type CanvasBatchable, CanvasContext, CanvasEditor, CanvasItem, type CanvasItemEventMap, type CanvasItemProperties, CanvasItemStyle, type CanvasItemStyleFilter, type CanvasItemStyleFilterKey, type CanvasItemStyleProperties, CanvasTexture, Color, ColorAdjustEffect, ColorFilterEffect, type ColorFilterEffectProperties, ColorMatrix, ColorOverlayEffect, ColorRemoveEffect, ColorReplaceEffect, ColorTexture, type ColorValue, Control, type ControlEventMap, type ControlProperties, CoreObject, type CoreObjectEventMap, type CssFunction, type CssFunctionArg, type Cursor, DEG_TO_RAD, DEVICE_PIXEL_RATIO, type Easing, Effect, type EffectContext, EffectMaterial, type EffectMode, type EffectOptions, EmbossEffect, Engine, type EngineOptions, EventEmitter, type EventListener, type EventListenerOptions, type EventListenerValue, type FilledGraphics, FontLoader, Geometry, type GeometryOptions, GifLoader, GlitchEffect, GodrayEffect, Graphics2D, HTMLAudio, HTMLAudioContext, HTMLSound, type IAudioContext, type IAudioNode, IN_BROWSER, type IPlayOptions, Image2D, type Image2DProperties, Image2DResource, type ImageFrame, ImageTexture, type ImageTextureOptions, IndexBuffer, type IndexBufferOptions, Input, InputEvent, type InputEventKey, type InputEventMap, type InternalMode, JsonLoader, KawaseEffect, type Keyframe, LeftEraseEffect, Loader, Lottie2D, type Lottie2DProperties, LottieLoader, MainLoop, type MainLoopEventMap, type MaskColor, type MaskData, MaskEffect, type MaskEffectOptions, type MaskObject, type MaskRect, type Maskable, Material, type MaterialOptions, Matrix, Matrix2, Matrix3, Matrix4, type MatrixLike, type MatrixOperateOutput, MouseInputEvent, Node, Node2D, type Node2DProperties, type NodeEventMap, type NodeProperties, type NormalizedKeyframe, PI, PI_2, PixelateEffect, PixelsTexture, type PlatformAudio, type PlatformSound, type PointerEvents, PointerInputEvent, type ProcessMode, Projection2D, type PropertyDeclaration, QuadGeometry, QuadUvGeometry, RAD_TO_DEG, RawWeakMap, Rect2, RefCounted, type RefCountedEventMap, type RenderMode, type RenderOptions, type Renderable, Renderer, Resource, type ResourceEventMap, Ruler, type RulerProperties, SUPPORTS_AUDIO_CONTEXT, SUPPORTS_CLICK_EVENTS, SUPPORTS_CREATE_IMAGE_BITMAP, SUPPORTS_IMAGE_BITMAP, SUPPORTS_MOUSE_EVENTS, SUPPORTS_OFFLINE_AUDIO_CONTEXT, SUPPORTS_POINTER_EVENTS, SUPPORTS_RESIZE_OBSERVER, SUPPORTS_TOUCH_EVENTS, SUPPORTS_WEBGL2, SUPPORTS_WEBKIT_AUDIO_CONTEXT, SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT, SUPPORTS_WEB_AUDIO, SUPPORTS_WHEEL_EVENTS, Scaler, type ScalerEventMap, type ScalerProperties, SceneTree, type SceneTreeEventMap, ScrollBar, type ScrollBarProperties, ShadowEffect, type StrokedGraphics, Text2D, type Text2DProperties, TextLoader, Texture2D, type Texture2DFilterMode, type Texture2DPixelsSource, type Texture2DSource, type Texture2DWrapMode, TextureLoader, TextureRect2D, type TextureRect2DProperties, Ticker, TiltShiftEffect, Timeline, type TimelineEventMap, TimelineNode, type TimelineNodeEventMap, type TimelineNodeProperties, type TimelineProperties, type TimingFunctions, Transform2D, type Transform2DObject, TwistEffect, UvGeometry, UvMaterial, Vector, Vector2, Vector3, Vector4, type VectorLike, type VectorOperateOutput, VertexAttribute, type VertexAttributeOptions, VertexBuffer, type VertexBufferOptions, Video2D, type Video2DProperties, VideoLoader, VideoTexture, type VideoTextureOptions, type VideoTextureSource, Viewport, type ViewportEventMap, type ViewportFramebuffer, ViewportTexture, WebAudio, WebAudioContext, WebGLBatch2DModule, WebGLBlendMode, type WebGLBufferMeta, WebGLBufferModule, type WebGLBufferOptions, type WebGLBufferTarget, type WebGLBufferUsage, type WebGLDrawMode, type WebGLDrawOptions, type WebGLExtensions, type WebGLFramebufferMeta, WebGLFramebufferModule, type WebGLFramebufferOptions, WebGLMaskModule, WebGLModule, type WebGLProgramMeta, WebGLProgramModule, type WebGLProgramOptions, WebGLRenderer, WebGLScissorModule, WebGLState, WebGLStateModule, WebGLStencilModule, type WebGLTarget, type WebGLTextureFilterMode, type WebGLTextureLocation, type WebGLTextureMeta, WebGLTextureModule, type WebGLTextureOptions, type WebGLTextureSource, type WebGLTextureTarget, type WebGLTextureWrapMode, WebGLVertexArrayModule, type WebGLVertexArrayObjectMeta, type WebGLVertexArrayObjectOptions, type WebGLVertexAttrib, type WebGLVertexAttribType, type WebGLViewport, WebGLViewportModule, WebSound, WheelInputEvent, ZoomBlurEffect, assets, clamp, createHTMLCanvas, createNode, crossOrigin, cubicBezier, curves, customNode, customNodes, defaultOptions, defineProperty, determineCrossOrigin, ease, easeIn, easeInOut, easeOut, getDeclarations, getDefaultCssPropertyValue, isCanvasElement, isElementNode, isImageElement, isPow2, isVideoElement, isWebgl2, lerp, linear, log2, mapWebGLBlendModes, nextPow2, nextTick, parseCssFunctions, parseCssProperty, property, protectedProperty, render, timingFunctions, uid };