modern-canvas 0.4.50 → 0.4.51
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 +8 -19
- package/dist/index.js +35 -35
- package/dist/index.mjs +8 -19
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -9158,7 +9158,7 @@ class BaseElement2DOutline extends BaseElement2DFill {
|
|
|
9158
9158
|
}
|
|
9159
9159
|
canDraw() {
|
|
9160
9160
|
return Boolean(
|
|
9161
|
-
this.width || super.canDraw()
|
|
9161
|
+
this.width || this.color || super.canDraw()
|
|
9162
9162
|
);
|
|
9163
9163
|
}
|
|
9164
9164
|
draw() {
|
|
@@ -9405,13 +9405,6 @@ class BaseElement2DText extends CoreObject {
|
|
|
9405
9405
|
}
|
|
9406
9406
|
updateMeasure() {
|
|
9407
9407
|
this.measureResult = this.measure();
|
|
9408
|
-
const textWidth = this.measureResult.boundingBox.width;
|
|
9409
|
-
const textHeight = this.measureResult.boundingBox.height;
|
|
9410
|
-
const { left, top, width, height = textHeight } = this.parent.style;
|
|
9411
|
-
this.parent.position.x = left + Math.min(0, ((width || textWidth) - textWidth) / 2);
|
|
9412
|
-
this.parent.position.y = top + Math.min(0, ((height || textHeight) - textHeight) / 2);
|
|
9413
|
-
this.parent.size.width = textWidth;
|
|
9414
|
-
this.parent.size.height = textHeight;
|
|
9415
9408
|
return this;
|
|
9416
9409
|
}
|
|
9417
9410
|
canDraw() {
|
|
@@ -9426,9 +9419,10 @@ class BaseElement2DText extends CoreObject {
|
|
|
9426
9419
|
view: this.texture.source
|
|
9427
9420
|
});
|
|
9428
9421
|
this.texture.requestUpload();
|
|
9429
|
-
const
|
|
9422
|
+
const textWidth = this.measureResult?.boundingBox.width ?? this.parent.size.width;
|
|
9423
|
+
const textHeight = this.measureResult?.boundingBox.height ?? this.parent.size.height;
|
|
9430
9424
|
ctx.fillStyle = this.texture;
|
|
9431
|
-
ctx.textureTransform = new Transform2D().scale(1 /
|
|
9425
|
+
ctx.textureTransform = new Transform2D().scale(1 / textWidth, 1 / textHeight);
|
|
9432
9426
|
ctx.fill();
|
|
9433
9427
|
}
|
|
9434
9428
|
}
|
|
@@ -10779,15 +10773,10 @@ let Text2D = class extends TextureRect2D {
|
|
|
10779
10773
|
}
|
|
10780
10774
|
_drawContent() {
|
|
10781
10775
|
if (!this.split) {
|
|
10782
|
-
|
|
10783
|
-
|
|
10784
|
-
|
|
10785
|
-
}
|
|
10786
|
-
this.base.render({
|
|
10787
|
-
pixelRatio: this.texture.pixelRatio,
|
|
10788
|
-
view: this.texture.source
|
|
10789
|
-
});
|
|
10790
|
-
}
|
|
10776
|
+
this.base.render({
|
|
10777
|
+
pixelRatio: this.texture.pixelRatio,
|
|
10778
|
+
view: this.texture.source
|
|
10779
|
+
});
|
|
10791
10780
|
this.texture.requestUpload();
|
|
10792
10781
|
super._drawContent();
|
|
10793
10782
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modern-canvas",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.51",
|
|
5
5
|
"packageManager": "pnpm@9.15.1",
|
|
6
6
|
"description": "A JavaScript WebGL rendering engine.",
|
|
7
7
|
"author": "wxm",
|
|
@@ -71,17 +71,17 @@
|
|
|
71
71
|
"earcut": "^3.0.1",
|
|
72
72
|
"modern-font": "^0.4.1",
|
|
73
73
|
"modern-idoc": "^0.6.9",
|
|
74
|
-
"modern-path2d": "^1.3.
|
|
74
|
+
"modern-path2d": "^1.3.3",
|
|
75
75
|
"modern-text": "^1.4.2",
|
|
76
76
|
"yoga-layout": "^3.2.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@antfu/eslint-config": "^4.13.2",
|
|
80
80
|
"@types/earcut": "^3.0.0",
|
|
81
|
-
"@types/node": "^22.15.
|
|
81
|
+
"@types/node": "^22.15.29",
|
|
82
82
|
"bumpp": "^10.1.1",
|
|
83
83
|
"conventional-changelog-cli": "^5.0.0",
|
|
84
|
-
"eslint": "^9.
|
|
84
|
+
"eslint": "^9.28.0",
|
|
85
85
|
"lint-staged": "^16.1.0",
|
|
86
86
|
"lottie-web": "^5.13.0",
|
|
87
87
|
"modern-gif": "^2.0.4",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"typescript": "^5.8.3",
|
|
90
90
|
"unbuild": "^3.5.0",
|
|
91
91
|
"vite": "^6.3.5",
|
|
92
|
-
"vitest": "^3.
|
|
92
|
+
"vitest": "^3.2.0"
|
|
93
93
|
},
|
|
94
94
|
"simple-git-hooks": {
|
|
95
95
|
"pre-commit": "pnpm lint-staged"
|