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.mjs
CHANGED
|
@@ -6133,6 +6133,7 @@ let TimelineNode = class extends Node {
|
|
|
6133
6133
|
this.computedDuration = parent?.computedDuration ? Math.min(this._startTime + this.duration, parent.endTime) - this._startTime : this.duration;
|
|
6134
6134
|
this._currentTime = this.timelineCurrentTime - this._startTime;
|
|
6135
6135
|
this.emit("updateCurrentTime", this._currentTime);
|
|
6136
|
+
this.insideTimeRange = this.isInsideTimeRange();
|
|
6136
6137
|
}
|
|
6137
6138
|
}
|
|
6138
6139
|
_process(delta) {
|
|
@@ -6149,6 +6150,9 @@ __decorateClass$H([
|
|
|
6149
6150
|
__decorateClass$H([
|
|
6150
6151
|
property({ default: false })
|
|
6151
6152
|
], TimelineNode.prototype, "paused", 2);
|
|
6153
|
+
__decorateClass$H([
|
|
6154
|
+
protectedProperty()
|
|
6155
|
+
], TimelineNode.prototype, "insideTimeRange", 2);
|
|
6152
6156
|
TimelineNode = __decorateClass$H([
|
|
6153
6157
|
customNode("TimelineNode")
|
|
6154
6158
|
], TimelineNode);
|
|
@@ -8034,6 +8038,7 @@ let CanvasItem = class extends TimelineNode {
|
|
|
8034
8038
|
this._updateGlobalOpacity();
|
|
8035
8039
|
break;
|
|
8036
8040
|
case "visible":
|
|
8041
|
+
case "insideTimeRange":
|
|
8037
8042
|
this._updateGlobalVisible();
|
|
8038
8043
|
break;
|
|
8039
8044
|
}
|
|
@@ -8064,7 +8069,7 @@ let CanvasItem = class extends TimelineNode {
|
|
|
8064
8069
|
}
|
|
8065
8070
|
_updateGlobalVisible() {
|
|
8066
8071
|
this._parentGlobalVisible = this.getParent()?.globalVisible;
|
|
8067
|
-
this._globalVisible = this.
|
|
8072
|
+
this._globalVisible = (this._parentGlobalVisible ?? true) && this.visible && this.insideTimeRange;
|
|
8068
8073
|
}
|
|
8069
8074
|
_updateGlobalOpacity() {
|
|
8070
8075
|
this._parentGlobalOpacity = this.getParent()?.opacity;
|
|
@@ -13109,8 +13114,9 @@ class Engine extends SceneTree {
|
|
|
13109
13114
|
nextTick() {
|
|
13110
13115
|
return nextTick();
|
|
13111
13116
|
}
|
|
13112
|
-
waitUntilLoad() {
|
|
13113
|
-
|
|
13117
|
+
async waitUntilLoad() {
|
|
13118
|
+
await assets.waitUntilLoad();
|
|
13119
|
+
await this.nextTick();
|
|
13114
13120
|
}
|
|
13115
13121
|
render(delta = 0) {
|
|
13116
13122
|
return this._render(this.renderer, delta);
|
|
@@ -13135,25 +13141,25 @@ class Engine extends SceneTree {
|
|
|
13135
13141
|
}
|
|
13136
13142
|
toCanvas2D() {
|
|
13137
13143
|
const imageData = this.toImageData();
|
|
13138
|
-
const
|
|
13139
|
-
|
|
13140
|
-
|
|
13141
|
-
|
|
13142
|
-
const
|
|
13143
|
-
|
|
13144
|
-
|
|
13145
|
-
|
|
13146
|
-
|
|
13144
|
+
const canvas1 = document.createElement("canvas");
|
|
13145
|
+
canvas1.width = imageData.width;
|
|
13146
|
+
canvas1.height = imageData.height;
|
|
13147
|
+
canvas1.getContext("2d")?.putImageData(imageData, 0, 0);
|
|
13148
|
+
const canvas2 = document.createElement("canvas");
|
|
13149
|
+
canvas2.width = this.width;
|
|
13150
|
+
canvas2.height = this.height;
|
|
13151
|
+
canvas2.getContext("2d")?.drawImage(
|
|
13152
|
+
canvas1,
|
|
13147
13153
|
0,
|
|
13148
13154
|
0,
|
|
13149
|
-
|
|
13150
|
-
|
|
13155
|
+
canvas1.width,
|
|
13156
|
+
canvas1.height,
|
|
13151
13157
|
0,
|
|
13152
13158
|
0,
|
|
13153
|
-
|
|
13154
|
-
|
|
13159
|
+
canvas2.width,
|
|
13160
|
+
canvas2.height
|
|
13155
13161
|
);
|
|
13156
|
-
return
|
|
13162
|
+
return canvas2;
|
|
13157
13163
|
}
|
|
13158
13164
|
}
|
|
13159
13165
|
|
|
@@ -13188,6 +13194,7 @@ async function performRender(options) {
|
|
|
13188
13194
|
}
|
|
13189
13195
|
});
|
|
13190
13196
|
await engine.waitUntilLoad();
|
|
13197
|
+
await options.onBeforeRender?.(engine);
|
|
13191
13198
|
return engine.toCanvas2D();
|
|
13192
13199
|
}
|
|
13193
13200
|
async function render(options) {
|