modern-canvas 0.4.48 → 0.4.50
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 +7 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +29 -29
- package/dist/index.mjs +7 -4
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -9170,7 +9170,7 @@ class BaseElement2DOutline extends BaseElement2DFill {
|
|
|
9170
9170
|
draw() {
|
|
9171
9171
|
const ctx = this.parent.context;
|
|
9172
9172
|
const { textureTransform, disableWrapMode } = this._getDrawOptions();
|
|
9173
|
-
ctx.lineWidth = this.width;
|
|
9173
|
+
ctx.lineWidth = this.width || 1;
|
|
9174
9174
|
ctx.textureTransform = textureTransform;
|
|
9175
9175
|
ctx.strokeStyle = this._texture ?? this.color;
|
|
9176
9176
|
ctx.stroke({ disableWrapMode });
|
|
@@ -9282,9 +9282,8 @@ class BaseElement2DShape extends CoreObject {
|
|
|
9282
9282
|
if (this.svg) {
|
|
9283
9283
|
const dom = modernPath2d.svgToDOM(this.svg);
|
|
9284
9284
|
this._path2DSet = modernPath2d.svgToPath2DSet(dom);
|
|
9285
|
-
viewBox = this._path2DSet.viewBox
|
|
9285
|
+
viewBox = this._path2DSet.viewBox;
|
|
9286
9286
|
} else {
|
|
9287
|
-
viewBox = this.viewBox;
|
|
9288
9287
|
this.paths?.forEach((path, i) => {
|
|
9289
9288
|
const { data, ...style } = path;
|
|
9290
9289
|
const path2D = new modernPath2d.Path2D();
|
|
@@ -9293,6 +9292,10 @@ class BaseElement2DShape extends CoreObject {
|
|
|
9293
9292
|
this._path2DSet.paths[i] = path2D;
|
|
9294
9293
|
});
|
|
9295
9294
|
}
|
|
9295
|
+
if (!viewBox) {
|
|
9296
|
+
const bbox = this._path2DSet.getBoundingBox();
|
|
9297
|
+
viewBox = bbox ? [bbox.x, bbox.y, bbox.width, bbox.height] : [0, 0, 1, 1];
|
|
9298
|
+
}
|
|
9296
9299
|
const [x, y, w, h] = viewBox;
|
|
9297
9300
|
this._path2DSet.paths.forEach((path) => {
|
|
9298
9301
|
path.applyTransform(new modernPath2d.Matrix3().translate(-x, -y).scale(1 / w, 1 / h));
|
|
@@ -9329,7 +9332,7 @@ __decorateClass$p([
|
|
|
9329
9332
|
property()
|
|
9330
9333
|
], BaseElement2DShape.prototype, "svg");
|
|
9331
9334
|
__decorateClass$p([
|
|
9332
|
-
property(
|
|
9335
|
+
property()
|
|
9333
9336
|
], BaseElement2DShape.prototype, "viewBox");
|
|
9334
9337
|
__decorateClass$p([
|
|
9335
9338
|
property({ default: () => [] })
|
package/dist/index.d.cts
CHANGED
|
@@ -1958,7 +1958,7 @@ declare class BaseElement2DShape extends CoreObject {
|
|
|
1958
1958
|
parent: BaseElement2D;
|
|
1959
1959
|
preset?: Required<NormalizedShape>['preset'];
|
|
1960
1960
|
svg?: Required<NormalizedShape>['svg'];
|
|
1961
|
-
viewBox
|
|
1961
|
+
viewBox?: Required<NormalizedShape>['viewBox'];
|
|
1962
1962
|
paths: Required<NormalizedShape>['paths'];
|
|
1963
1963
|
protected _path2DSet: Path2DSet;
|
|
1964
1964
|
constructor(parent: BaseElement2D);
|
package/dist/index.d.mts
CHANGED
|
@@ -1958,7 +1958,7 @@ declare class BaseElement2DShape extends CoreObject {
|
|
|
1958
1958
|
parent: BaseElement2D;
|
|
1959
1959
|
preset?: Required<NormalizedShape>['preset'];
|
|
1960
1960
|
svg?: Required<NormalizedShape>['svg'];
|
|
1961
|
-
viewBox
|
|
1961
|
+
viewBox?: Required<NormalizedShape>['viewBox'];
|
|
1962
1962
|
paths: Required<NormalizedShape>['paths'];
|
|
1963
1963
|
protected _path2DSet: Path2DSet;
|
|
1964
1964
|
constructor(parent: BaseElement2D);
|
package/dist/index.d.ts
CHANGED
|
@@ -1958,7 +1958,7 @@ declare class BaseElement2DShape extends CoreObject {
|
|
|
1958
1958
|
parent: BaseElement2D;
|
|
1959
1959
|
preset?: Required<NormalizedShape>['preset'];
|
|
1960
1960
|
svg?: Required<NormalizedShape>['svg'];
|
|
1961
|
-
viewBox
|
|
1961
|
+
viewBox?: Required<NormalizedShape>['viewBox'];
|
|
1962
1962
|
paths: Required<NormalizedShape>['paths'];
|
|
1963
1963
|
protected _path2DSet: Path2DSet;
|
|
1964
1964
|
constructor(parent: BaseElement2D);
|