modern-canvas 0.23.1 → 0.23.2
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.js
CHANGED
|
@@ -6694,6 +6694,7 @@ function Oi(e, t, n, r, i = {}) {
|
|
|
6694
6694
|
//#endregion
|
|
6695
6695
|
//#region src/scene/2d/element/Element2DForeground.ts
|
|
6696
6696
|
var ki = class extends J {
|
|
6697
|
+
_sourceCanvas;
|
|
6697
6698
|
setProperties(e) {
|
|
6698
6699
|
return super._setProperties(d(e) ? void 0 : g(e));
|
|
6699
6700
|
}
|
|
@@ -6713,12 +6714,17 @@ var ki = class extends J {
|
|
|
6713
6714
|
_applyEffects() {
|
|
6714
6715
|
if (!this.effects?.length || this.animatedTexture || !this.texture) return;
|
|
6715
6716
|
let e = this.texture.source;
|
|
6716
|
-
if (
|
|
6717
|
-
|
|
6717
|
+
if (e && e.width > 0 && e.height > 0) {
|
|
6718
|
+
let t = Math.max(1, Math.round(e.width)), n = Math.max(1, Math.round(e.height)), r = S(t, n), i = r?.getContext("2d");
|
|
6719
|
+
r && i && (i.drawImage(e, 0, 0, t, n), this._sourceCanvas = r);
|
|
6720
|
+
}
|
|
6721
|
+
let t = this._sourceCanvas;
|
|
6722
|
+
if (!t) return;
|
|
6723
|
+
let n = t.width, r = t.height, i = Oi(t, this.effects, n, r);
|
|
6718
6724
|
this.texture = new er({
|
|
6719
|
-
source:
|
|
6720
|
-
width:
|
|
6721
|
-
height:
|
|
6725
|
+
source: i,
|
|
6726
|
+
width: n,
|
|
6727
|
+
height: r
|
|
6722
6728
|
});
|
|
6723
6729
|
}
|
|
6724
6730
|
};
|
|
@@ -4,6 +4,13 @@ export declare class Element2DForeground extends Element2DFill implements Normal
|
|
|
4
4
|
fillWithShape: NormalizedForeground['fillWithShape'];
|
|
5
5
|
/** 图片效果叠层(filling/strokes/offset...);加载后烘焙到运行时 canvas,不持久化 */
|
|
6
6
|
effects?: NormalizedEffect[];
|
|
7
|
+
/**
|
|
8
|
+
* 原图的 CPU 副本(HTMLCanvas),在纹理刚加载、source 仍存活时拍下。
|
|
9
|
+
* 用于烘焙 effects:纹理的 ImageBitmap source 上传 GPU 后可能被
|
|
10
|
+
* `close()`(detached,width/height 归零),此时直接 drawImage 会抛
|
|
11
|
+
* InvalidStateError,故始终从这份不会失效的副本烘焙。
|
|
12
|
+
*/
|
|
13
|
+
protected _sourceCanvas?: HTMLCanvasElement;
|
|
7
14
|
setProperties(properties?: Foreground): this;
|
|
8
15
|
protected _updateProperty(key: string, value: any, oldValue: any): void;
|
|
9
16
|
loadTexture(): Promise<void>;
|