modern-canvas 0.4.5 → 0.4.6

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
@@ -6139,6 +6139,7 @@ exports.TimelineNode = class TimelineNode extends exports.Node {
6139
6139
  this.computedDuration = parent?.computedDuration ? Math.min(this._startTime + this.duration, parent.endTime) - this._startTime : this.duration;
6140
6140
  this._currentTime = this.timelineCurrentTime - this._startTime;
6141
6141
  this.emit("updateCurrentTime", this._currentTime);
6142
+ this.insideTimeRange = this.isInsideTimeRange();
6142
6143
  }
6143
6144
  }
6144
6145
  _process(delta) {
@@ -6155,6 +6156,9 @@ __decorateClass$H([
6155
6156
  __decorateClass$H([
6156
6157
  property({ default: false })
6157
6158
  ], exports.TimelineNode.prototype, "paused", 2);
6159
+ __decorateClass$H([
6160
+ protectedProperty()
6161
+ ], exports.TimelineNode.prototype, "insideTimeRange", 2);
6158
6162
  exports.TimelineNode = __decorateClass$H([
6159
6163
  customNode("TimelineNode")
6160
6164
  ], exports.TimelineNode);
@@ -8040,6 +8044,7 @@ exports.CanvasItem = class CanvasItem extends exports.TimelineNode {
8040
8044
  this._updateGlobalOpacity();
8041
8045
  break;
8042
8046
  case "visible":
8047
+ case "insideTimeRange":
8043
8048
  this._updateGlobalVisible();
8044
8049
  break;
8045
8050
  }
@@ -8070,7 +8075,7 @@ exports.CanvasItem = class CanvasItem extends exports.TimelineNode {
8070
8075
  }
8071
8076
  _updateGlobalVisible() {
8072
8077
  this._parentGlobalVisible = this.getParent()?.globalVisible;
8073
- this._globalVisible = this.visible && (this._parentGlobalVisible ?? true);
8078
+ this._globalVisible = (this._parentGlobalVisible ?? true) && this.visible && this.insideTimeRange;
8074
8079
  }
8075
8080
  _updateGlobalOpacity() {
8076
8081
  this._parentGlobalOpacity = this.getParent()?.opacity;
@@ -13142,25 +13147,25 @@ class Engine extends SceneTree {
13142
13147
  }
13143
13148
  toCanvas2D() {
13144
13149
  const imageData = this.toImageData();
13145
- const canvas0 = document.createElement("canvas");
13146
- canvas0.width = imageData.width;
13147
- canvas0.height = imageData.height;
13148
- canvas0.getContext("2d")?.putImageData(imageData, 0, 0);
13149
- const canvas = document.createElement("canvas");
13150
- canvas.width = this.width;
13151
- canvas.height = this.height;
13152
- canvas.getContext("2d")?.drawImage(
13153
- canvas0,
13150
+ const canvas1 = document.createElement("canvas");
13151
+ canvas1.width = imageData.width;
13152
+ canvas1.height = imageData.height;
13153
+ canvas1.getContext("2d")?.putImageData(imageData, 0, 0);
13154
+ const canvas2 = document.createElement("canvas");
13155
+ canvas2.width = this.width;
13156
+ canvas2.height = this.height;
13157
+ canvas2.getContext("2d")?.drawImage(
13158
+ canvas1,
13154
13159
  0,
13155
13160
  0,
13156
- canvas0.width,
13157
- canvas0.height,
13161
+ canvas1.width,
13162
+ canvas1.height,
13158
13163
  0,
13159
13164
  0,
13160
- canvas.width,
13161
- canvas.height
13165
+ canvas2.width,
13166
+ canvas2.height
13162
13167
  );
13163
- return canvas;
13168
+ return canvas2;
13164
13169
  }
13165
13170
  }
13166
13171
 
@@ -13195,6 +13200,7 @@ async function performRender(options) {
13195
13200
  }
13196
13201
  });
13197
13202
  await engine.waitUntilLoad();
13203
+ await options.onBeforeRender?.(engine);
13198
13204
  return engine.toCanvas2D();
13199
13205
  }
13200
13206
  async function render(options) {
package/dist/index.d.cts CHANGED
@@ -1723,6 +1723,7 @@ declare class TimelineNode extends Node {
1723
1723
  delay: number;
1724
1724
  duration: number;
1725
1725
  paused: boolean;
1726
+ insideTimeRange: boolean;
1726
1727
  constructor(properties?: Partial<TimelineNodeProperties>, nodes?: Node[]);
1727
1728
  /** Timeline */
1728
1729
  computedDuration: number;
@@ -3041,6 +3042,7 @@ interface RenderOptions {
3041
3042
  data: Record<string, any> | Node | (Node | Record<string, any>)[];
3042
3043
  width: number;
3043
3044
  height: number;
3045
+ onBeforeRender?: (engine: Engine) => void | Promise<void>;
3044
3046
  }
3045
3047
  declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
3046
3048
 
package/dist/index.d.mts CHANGED
@@ -1723,6 +1723,7 @@ declare class TimelineNode extends Node {
1723
1723
  delay: number;
1724
1724
  duration: number;
1725
1725
  paused: boolean;
1726
+ insideTimeRange: boolean;
1726
1727
  constructor(properties?: Partial<TimelineNodeProperties>, nodes?: Node[]);
1727
1728
  /** Timeline */
1728
1729
  computedDuration: number;
@@ -3041,6 +3042,7 @@ interface RenderOptions {
3041
3042
  data: Record<string, any> | Node | (Node | Record<string, any>)[];
3042
3043
  width: number;
3043
3044
  height: number;
3045
+ onBeforeRender?: (engine: Engine) => void | Promise<void>;
3044
3046
  }
3045
3047
  declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
3046
3048
 
package/dist/index.d.ts CHANGED
@@ -1723,6 +1723,7 @@ declare class TimelineNode extends Node {
1723
1723
  delay: number;
1724
1724
  duration: number;
1725
1725
  paused: boolean;
1726
+ insideTimeRange: boolean;
1726
1727
  constructor(properties?: Partial<TimelineNodeProperties>, nodes?: Node[]);
1727
1728
  /** Timeline */
1728
1729
  computedDuration: number;
@@ -3041,6 +3042,7 @@ interface RenderOptions {
3041
3042
  data: Record<string, any> | Node | (Node | Record<string, any>)[];
3042
3043
  width: number;
3043
3044
  height: number;
3045
+ onBeforeRender?: (engine: Engine) => void | Promise<void>;
3044
3046
  }
3045
3047
  declare function render(options: RenderOptions): Promise<HTMLCanvasElement>;
3046
3048