modern-canvas 0.7.4 → 0.7.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 +16 -12
- package/dist/index.d.cts +7 -5
- package/dist/index.d.mts +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +19 -19
- package/dist/index.mjs +17 -13
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineProperty, EventEmitter, getDeclarations, parseColor, property, RawWeakMap as RawWeakMap$1, isGradient, isColorFillObject, clearUndef, idGenerator, normalizeFill, isNone, normalizeBackground, normalizeForeground, normalizeOutline, normalizeShadow, normalizeShape, getDefaultStyle, normalizeText } from 'modern-idoc';
|
|
1
|
+
import { defineProperty, EventEmitter, getDeclarations, parseColor, property, RawWeakMap as RawWeakMap$1, isGradient, isColorFillObject, clearUndef, idGenerator, normalizeFill, isNone, normalizeBackground, normalizeForeground, normalizeOutline, normalizeShadow, normalizeShape, getDefaultStyle, normalizeText, normalizeTextContent } from 'modern-idoc';
|
|
2
2
|
import { extend } from 'colord';
|
|
3
3
|
import namesPlugin from 'colord/plugins/names';
|
|
4
4
|
import { Path2D, Path2DSet, svgToDom, svgToPath2DSet, Matrix3 as Matrix3$1 } from 'modern-path2d';
|
|
@@ -746,10 +746,11 @@ class Input extends EventEmitter {
|
|
|
746
746
|
mapPositionToPoint(point, x, y) {
|
|
747
747
|
if (!this.target)
|
|
748
748
|
return;
|
|
749
|
-
const
|
|
750
|
-
const height = Number(this.target.getAttribute("height")) || 0;
|
|
749
|
+
const clientRect = this.target.isConnected ? this.target.getBoundingClientRect() : void 0;
|
|
751
750
|
const pixelRatio = Number(this.target.getAttribute("data-pixel-ratio")) || 1;
|
|
752
|
-
const
|
|
751
|
+
const width = Number(this.target.getAttribute("width")) || (clientRect ? clientRect.width * pixelRatio : 0);
|
|
752
|
+
const height = Number(this.target.getAttribute("height")) || (clientRect ? clientRect.height * pixelRatio : 0);
|
|
753
|
+
const rect = clientRect ?? { width, height, left: 0, top: 0 };
|
|
753
754
|
const multiplier = 1 / pixelRatio;
|
|
754
755
|
point.x = (x - rect.left) * (width / rect.width) * multiplier;
|
|
755
756
|
point.y = (y - rect.top) * (height / rect.height) * multiplier;
|
|
@@ -5448,7 +5449,7 @@ class CanvasContext extends Path2D {
|
|
|
5448
5449
|
miterLimit: this.miterLimit ?? 10
|
|
5449
5450
|
}
|
|
5450
5451
|
});
|
|
5451
|
-
|
|
5452
|
+
this.reset();
|
|
5452
5453
|
}
|
|
5453
5454
|
fillRect(x, y, width, height) {
|
|
5454
5455
|
this.rect(x, y, width, height).fill();
|
|
@@ -5481,7 +5482,7 @@ class CanvasContext extends Path2D {
|
|
|
5481
5482
|
uvTransform: this.uvTransform,
|
|
5482
5483
|
vertTransform: this.vertTransform
|
|
5483
5484
|
});
|
|
5484
|
-
|
|
5485
|
+
this.resetStatus();
|
|
5485
5486
|
}
|
|
5486
5487
|
copy(source) {
|
|
5487
5488
|
super.copy(source);
|
|
@@ -5496,7 +5497,7 @@ class CanvasContext extends Path2D {
|
|
|
5496
5497
|
this._draws = source._draws.slice();
|
|
5497
5498
|
return this;
|
|
5498
5499
|
}
|
|
5499
|
-
|
|
5500
|
+
resetStatus() {
|
|
5500
5501
|
super.reset();
|
|
5501
5502
|
this.strokeStyle = void 0;
|
|
5502
5503
|
this.fillStyle = void 0;
|
|
@@ -5506,6 +5507,9 @@ class CanvasContext extends Path2D {
|
|
|
5506
5507
|
this.lineJoin = void 0;
|
|
5507
5508
|
this.lineWidth = void 0;
|
|
5508
5509
|
this.miterLimit = void 0;
|
|
5510
|
+
}
|
|
5511
|
+
reset() {
|
|
5512
|
+
this.resetStatus();
|
|
5509
5513
|
this._draws.length = 0;
|
|
5510
5514
|
return this;
|
|
5511
5515
|
}
|
|
@@ -5555,9 +5559,9 @@ class CanvasContext extends Path2D {
|
|
|
5555
5559
|
}
|
|
5556
5560
|
this.buildUvs(0, vertices, uvs, current.texture, current.uvTransform);
|
|
5557
5561
|
batchables.push({
|
|
5558
|
-
vertices,
|
|
5559
|
-
indices,
|
|
5560
|
-
uvs,
|
|
5562
|
+
vertices: new Float32Array(vertices),
|
|
5563
|
+
indices: new Float32Array(indices),
|
|
5564
|
+
uvs: new Float32Array(uvs),
|
|
5561
5565
|
texture: current.texture,
|
|
5562
5566
|
type: current.type,
|
|
5563
5567
|
disableWrapMode: current.disableWrapMode,
|
|
@@ -9566,7 +9570,6 @@ class BaseElement2DText extends CoreObject {
|
|
|
9566
9570
|
case "fonts":
|
|
9567
9571
|
case "fill":
|
|
9568
9572
|
case "outline":
|
|
9569
|
-
case "split":
|
|
9570
9573
|
this.parent.requestRedraw();
|
|
9571
9574
|
break;
|
|
9572
9575
|
}
|
|
@@ -9580,6 +9583,9 @@ class BaseElement2DText extends CoreObject {
|
|
|
9580
9583
|
};
|
|
9581
9584
|
this.base.requestUpdate();
|
|
9582
9585
|
}
|
|
9586
|
+
setContent(content) {
|
|
9587
|
+
this.content = normalizeTextContent(content);
|
|
9588
|
+
}
|
|
9583
9589
|
measure() {
|
|
9584
9590
|
this._updateText();
|
|
9585
9591
|
return this.base.measure();
|
|
@@ -9600,8 +9606,6 @@ class BaseElement2DText extends CoreObject {
|
|
|
9600
9606
|
pathSet.paths.forEach((path) => {
|
|
9601
9607
|
ctx.addPath(path);
|
|
9602
9608
|
ctx.style = { ...path.style };
|
|
9603
|
-
ctx.fillStyle = void 0;
|
|
9604
|
-
ctx.strokeStyle = void 0;
|
|
9605
9609
|
ctx.fill();
|
|
9606
9610
|
});
|
|
9607
9611
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modern-canvas",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.6",
|
|
5
5
|
"packageManager": "pnpm@9.15.1",
|
|
6
6
|
"description": "A JavaScript WebGL rendering engine.",
|
|
7
7
|
"author": "wxm",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"colord": "^2.9.3",
|
|
71
|
-
"earcut": "^3.0.
|
|
71
|
+
"earcut": "^3.0.2",
|
|
72
72
|
"modern-font": "^0.4.1",
|
|
73
73
|
"modern-idoc": "^0.8.6",
|
|
74
74
|
"modern-path2d": "^1.4.5",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@antfu/eslint-config": "^4.17.0",
|
|
80
80
|
"@types/earcut": "^3.0.0",
|
|
81
|
-
"@types/node": "^24.0.
|
|
81
|
+
"@types/node": "^24.0.14",
|
|
82
82
|
"bumpp": "^10.2.0",
|
|
83
83
|
"conventional-changelog-cli": "^5.0.0",
|
|
84
84
|
"eslint": "^9.31.0",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"simple-git-hooks": "^2.13.0",
|
|
89
89
|
"typescript": "^5.8.3",
|
|
90
90
|
"unbuild": "^3.5.0",
|
|
91
|
-
"vite": "^7.0.
|
|
91
|
+
"vite": "^7.0.5",
|
|
92
92
|
"vitest": "^3.2.4"
|
|
93
93
|
},
|
|
94
94
|
"simple-git-hooks": {
|