modern-canvas 0.9.3 → 0.9.5
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 +20 -10
- package/dist/index.d.cts +5 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +12 -12
- package/dist/index.mjs +20 -10
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4470,7 +4470,7 @@ class VertexAttribute extends Resource {
|
|
|
4470
4470
|
}
|
|
4471
4471
|
}
|
|
4472
4472
|
__decorateClass$W([
|
|
4473
|
-
property({
|
|
4473
|
+
property({ internal: true })
|
|
4474
4474
|
], VertexAttribute.prototype, "buffer");
|
|
4475
4475
|
__decorateClass$W([
|
|
4476
4476
|
property({ fallback: 0 })
|
|
@@ -4864,7 +4864,7 @@ class Texture2D extends Resource {
|
|
|
4864
4864
|
}
|
|
4865
4865
|
}
|
|
4866
4866
|
__decorateClass$V([
|
|
4867
|
-
property({
|
|
4867
|
+
property({ internal: true })
|
|
4868
4868
|
], Texture2D.prototype, "source");
|
|
4869
4869
|
__decorateClass$V([
|
|
4870
4870
|
property({ fallback: 0 })
|
|
@@ -6198,7 +6198,7 @@ __decorateClass$S([
|
|
|
6198
6198
|
property({ internal: true, fallback: "default" })
|
|
6199
6199
|
], Node.prototype, "internalMode", 2);
|
|
6200
6200
|
__decorateClass$S([
|
|
6201
|
-
property({
|
|
6201
|
+
property({ internal: true })
|
|
6202
6202
|
], Node.prototype, "mask", 2);
|
|
6203
6203
|
Node = __decorateClass$S([
|
|
6204
6204
|
customNode("Node")
|
|
@@ -6882,7 +6882,7 @@ let Effect = class extends TimelineNode {
|
|
|
6882
6882
|
}
|
|
6883
6883
|
};
|
|
6884
6884
|
__decorateClass$O([
|
|
6885
|
-
property({
|
|
6885
|
+
property({ internal: true })
|
|
6886
6886
|
], Effect.prototype, "material", 2);
|
|
6887
6887
|
__decorateClass$O([
|
|
6888
6888
|
property()
|
|
@@ -7016,6 +7016,7 @@ var __decorateClass$L = (decorators, target, key, kind) => {
|
|
|
7016
7016
|
return result;
|
|
7017
7017
|
};
|
|
7018
7018
|
class SceneTree extends MainLoop {
|
|
7019
|
+
fonts;
|
|
7019
7020
|
input = new Input();
|
|
7020
7021
|
renderStack = new RenderStack();
|
|
7021
7022
|
root = new Window(true).setTree(this);
|
|
@@ -8899,7 +8900,7 @@ void main(void) {
|
|
|
8899
8900
|
}`
|
|
8900
8901
|
}));
|
|
8901
8902
|
__decorateClass$w([
|
|
8902
|
-
property({
|
|
8903
|
+
property({ internal: true })
|
|
8903
8904
|
], MaskEffect.prototype, "texture", 2);
|
|
8904
8905
|
__decorateClass$w([
|
|
8905
8906
|
property({ fallback: "" })
|
|
@@ -9701,9 +9702,10 @@ class BaseElement2DText extends CoreObject {
|
|
|
9701
9702
|
constructor(parent) {
|
|
9702
9703
|
super();
|
|
9703
9704
|
this.parent = parent;
|
|
9705
|
+
this.base = new Text();
|
|
9704
9706
|
this.base.setPropertyAccessor(this);
|
|
9705
9707
|
}
|
|
9706
|
-
base
|
|
9708
|
+
base;
|
|
9707
9709
|
measureResult;
|
|
9708
9710
|
_textureMap = /* @__PURE__ */ new Map();
|
|
9709
9711
|
setProperties(properties) {
|
|
@@ -9727,8 +9729,12 @@ class BaseElement2DText extends CoreObject {
|
|
|
9727
9729
|
break;
|
|
9728
9730
|
}
|
|
9729
9731
|
}
|
|
9730
|
-
|
|
9732
|
+
_updateBase() {
|
|
9733
|
+
this.base.fonts = this.base.fonts ?? this.parent.tree?.fonts;
|
|
9731
9734
|
this.base.update();
|
|
9735
|
+
}
|
|
9736
|
+
_updateTextureMap() {
|
|
9737
|
+
this._updateBase();
|
|
9732
9738
|
this._textureMap.clear();
|
|
9733
9739
|
const pGlyphBoxs = [];
|
|
9734
9740
|
this.base.paragraphs.forEach((p, pIndex) => {
|
|
@@ -9784,6 +9790,7 @@ class BaseElement2DText extends CoreObject {
|
|
|
9784
9790
|
this.content = normalizeTextContent(content);
|
|
9785
9791
|
}
|
|
9786
9792
|
measure() {
|
|
9793
|
+
this._updateBase();
|
|
9787
9794
|
return this.base.measure();
|
|
9788
9795
|
}
|
|
9789
9796
|
updateMeasure() {
|
|
@@ -9806,7 +9813,7 @@ class BaseElement2DText extends CoreObject {
|
|
|
9806
9813
|
}
|
|
9807
9814
|
draw() {
|
|
9808
9815
|
const ctx = this.parent.context;
|
|
9809
|
-
this.
|
|
9816
|
+
this._updateBase();
|
|
9810
9817
|
this.base.pathSets.forEach((pathSet) => {
|
|
9811
9818
|
pathSet.paths.forEach((path) => {
|
|
9812
9819
|
const meta = path.getMeta();
|
|
@@ -10929,7 +10936,7 @@ let Image2D = class extends Element2D {
|
|
|
10929
10936
|
}
|
|
10930
10937
|
};
|
|
10931
10938
|
__decorateClass$i([
|
|
10932
|
-
property({
|
|
10939
|
+
property({ internal: true })
|
|
10933
10940
|
], Image2D.prototype, "texture", 2);
|
|
10934
10941
|
__decorateClass$i([
|
|
10935
10942
|
property({ fallback: "" })
|
|
@@ -14168,6 +14175,7 @@ class Engine extends SceneTree {
|
|
|
14168
14175
|
height,
|
|
14169
14176
|
pixelRatio = DEVICE_PIXEL_RATIO,
|
|
14170
14177
|
backgroundColor = 0,
|
|
14178
|
+
fonts,
|
|
14171
14179
|
autoResize,
|
|
14172
14180
|
autoStart,
|
|
14173
14181
|
timeline,
|
|
@@ -14182,6 +14190,7 @@ class Engine extends SceneTree {
|
|
|
14182
14190
|
this._setupInput();
|
|
14183
14191
|
this.pixelRatio = pixelRatio;
|
|
14184
14192
|
this.backgroundColor = backgroundColor;
|
|
14193
|
+
this.fonts = fonts;
|
|
14185
14194
|
if (autoResize) {
|
|
14186
14195
|
if (!view && this.renderer.view) {
|
|
14187
14196
|
this.renderer.view.style.width = "100%";
|
|
@@ -14332,13 +14341,14 @@ async function start(sleep = 100) {
|
|
|
14332
14341
|
starting = false;
|
|
14333
14342
|
}
|
|
14334
14343
|
async function task(options) {
|
|
14335
|
-
const {
|
|
14344
|
+
const { debug = false, fonts, width, height, time = 0, data } = options;
|
|
14336
14345
|
engine ??= new Engine({
|
|
14337
14346
|
width: 1,
|
|
14338
14347
|
height: 1,
|
|
14339
14348
|
preserveDrawingBuffer: true
|
|
14340
14349
|
});
|
|
14341
14350
|
engine.debug = debug;
|
|
14351
|
+
engine.fonts = fonts;
|
|
14342
14352
|
engine.root.removeChildren();
|
|
14343
14353
|
engine.timeline.currentTime = time;
|
|
14344
14354
|
engine.resize(width, height, true);
|