modern-canvas 0.4.4 → 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 +24 -17
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +22 -22
- package/dist/index.mjs +24 -17
- package/package.json +1 -1
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.
|
|
8078
|
+
this._globalVisible = (this._parentGlobalVisible ?? true) && this.visible && this.insideTimeRange;
|
|
8074
8079
|
}
|
|
8075
8080
|
_updateGlobalOpacity() {
|
|
8076
8081
|
this._parentGlobalOpacity = this.getParent()?.opacity;
|
|
@@ -13115,8 +13120,9 @@ class Engine extends SceneTree {
|
|
|
13115
13120
|
nextTick() {
|
|
13116
13121
|
return nextTick();
|
|
13117
13122
|
}
|
|
13118
|
-
waitUntilLoad() {
|
|
13119
|
-
|
|
13123
|
+
async waitUntilLoad() {
|
|
13124
|
+
await assets.waitUntilLoad();
|
|
13125
|
+
await this.nextTick();
|
|
13120
13126
|
}
|
|
13121
13127
|
render(delta = 0) {
|
|
13122
13128
|
return this._render(this.renderer, delta);
|
|
@@ -13141,25 +13147,25 @@ class Engine extends SceneTree {
|
|
|
13141
13147
|
}
|
|
13142
13148
|
toCanvas2D() {
|
|
13143
13149
|
const imageData = this.toImageData();
|
|
13144
|
-
const
|
|
13145
|
-
|
|
13146
|
-
|
|
13147
|
-
|
|
13148
|
-
const
|
|
13149
|
-
|
|
13150
|
-
|
|
13151
|
-
|
|
13152
|
-
|
|
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,
|
|
13153
13159
|
0,
|
|
13154
13160
|
0,
|
|
13155
|
-
|
|
13156
|
-
|
|
13161
|
+
canvas1.width,
|
|
13162
|
+
canvas1.height,
|
|
13157
13163
|
0,
|
|
13158
13164
|
0,
|
|
13159
|
-
|
|
13160
|
-
|
|
13165
|
+
canvas2.width,
|
|
13166
|
+
canvas2.height
|
|
13161
13167
|
);
|
|
13162
|
-
return
|
|
13168
|
+
return canvas2;
|
|
13163
13169
|
}
|
|
13164
13170
|
}
|
|
13165
13171
|
|
|
@@ -13194,6 +13200,7 @@ async function performRender(options) {
|
|
|
13194
13200
|
}
|
|
13195
13201
|
});
|
|
13196
13202
|
await engine.waitUntilLoad();
|
|
13203
|
+
await options.onBeforeRender?.(engine);
|
|
13197
13204
|
return engine.toCanvas2D();
|
|
13198
13205
|
}
|
|
13199
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
|
|