canvas-editor-engine 1.1.10 → 1.1.12
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/utils/filter.d.ts +1 -1
- package/dist/utils/filter.js +12 -14
- package/package.json +1 -1
package/dist/utils/filter.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare class Filter {
|
|
|
7
7
|
setImageSize(size: IImageSize): void;
|
|
8
8
|
copy(options: IImageOptions): ImageData;
|
|
9
9
|
update(imgData: ImageData, options: IImageOptions): void;
|
|
10
|
-
clearEmptyPixels(imageData: ImageData):
|
|
10
|
+
clearEmptyPixels(imageData: ImageData): ImageData;
|
|
11
11
|
getSizeOfSparseMatrix(RGBAMatrix: TBuff<number[]>, tempSize: ISize): ISize;
|
|
12
12
|
getBuffCollection(imageData: ImageData): {
|
|
13
13
|
rowRGBABuff: TRGBABuff;
|
package/dist/utils/filter.js
CHANGED
|
@@ -18,7 +18,7 @@ class Filter {
|
|
|
18
18
|
const height = (options?.height) ? options.height : config_1.default.CANVAS_SIZE.height;
|
|
19
19
|
const imgData = this.ctx.getImageData(options.x, options.y, width, height);
|
|
20
20
|
const clearedImageData = this.clearEmptyPixels(imgData);
|
|
21
|
-
return
|
|
21
|
+
return clearedImageData;
|
|
22
22
|
}
|
|
23
23
|
update(imgData, options) {
|
|
24
24
|
this.ctx.clearRect(0, 0, config_1.default.CANVAS_SIZE.width, config_1.default.CANVAS_SIZE.height);
|
|
@@ -32,19 +32,17 @@ class Filter {
|
|
|
32
32
|
height: imageData.height,
|
|
33
33
|
};
|
|
34
34
|
const tempSize = this.getSizeOfSparseMatrix(RGBAMatrix, beforeSize);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// console.log('cleared', cleared);
|
|
47
|
-
// return tempImageData;
|
|
35
|
+
const cleared = rowRGBABuff.filter((byteArray) => {
|
|
36
|
+
const alpha = byteArray[3 /* E_RGBA.a */];
|
|
37
|
+
return !!alpha;
|
|
38
|
+
});
|
|
39
|
+
const clearedBuff = cleared.flat();
|
|
40
|
+
const tempCanvas = document.createElement('canvas');
|
|
41
|
+
const tempCtx = tempCanvas.getContext('2d');
|
|
42
|
+
const tempImageData = tempCtx.createImageData(tempSize.width, tempSize.height);
|
|
43
|
+
clearedBuff.forEach((_, i) => tempImageData.data[i] = clearedBuff[i]);
|
|
44
|
+
console.log('cleared', cleared);
|
|
45
|
+
return tempImageData;
|
|
48
46
|
}
|
|
49
47
|
getSizeOfSparseMatrix(RGBAMatrix, tempSize) {
|
|
50
48
|
// case 1: Xcanvas -> Ximage && case 3: Ycanvas -> Yimage
|