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.
@@ -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): void;
10
+ clearEmptyPixels(imageData: ImageData): ImageData;
11
11
  getSizeOfSparseMatrix(RGBAMatrix: TBuff<number[]>, tempSize: ISize): ISize;
12
12
  getBuffCollection(imageData: ImageData): {
13
13
  rowRGBABuff: TRGBABuff;
@@ -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 imgData;
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
- console.log('beforeSize', beforeSize);
36
- console.log('tempSize', tempSize);
37
- // const cleared = rowRGBABuff.filter((byteArray) => {
38
- // const alpha = byteArray[E_RGBA.a];
39
- // return !!alpha;
40
- // });
41
- // const clearedBuff = cleared.flat();
42
- // const tempCanvas = document.createElement('canvas');
43
- // const tempCtx = tempCanvas.getContext('2d');
44
- // const tempImageData = tempCtx.createImageData(tempSize.width, tempSize.height);
45
- // clearedBuff.forEach((_, i) => tempImageData.data[i] = clearedBuff[i]);
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvas-editor-engine",
3
- "version": "1.1.10",
3
+ "version": "1.1.12",
4
4
  "description": "CanvasEditorEngine library, use: [typescript] [canvas]",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",