canvas-editor-engine 1.1.4 → 1.1.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.
@@ -1,4 +1,5 @@
1
1
  import type { IImageOptions, IImageSize, TRGBABuff } from "../types/image";
2
+ import type { TStringMatrix } from '../types/general';
2
3
  export declare class Filter {
3
4
  ctx: CanvasRenderingContext2D;
4
5
  imageSize: IImageSize;
@@ -6,11 +7,11 @@ export declare class Filter {
6
7
  setImageSize(size: IImageSize): void;
7
8
  copy(options: IImageOptions): ImageData;
8
9
  update(imgData: ImageData, options: IImageOptions): void;
9
- clearEmptyPixels(imageData: ImageData): void;
10
+ clearEmptyPixels(imageData: ImageData): number[];
10
11
  getBuffCollection(imageData: ImageData): {
11
12
  rowRGBABuff: TRGBABuff;
12
13
  hexBuff: `#${string}`[];
13
- buff: import("../types/general").TStringMatrix;
14
+ buff: TStringMatrix;
14
15
  };
15
16
  private getBuff;
16
17
  private getRowRGBABuff;
@@ -17,7 +17,7 @@ class Filter {
17
17
  const width = (options?.width) ? options.width : config_1.default.CANVAS_SIZE.width;
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
- this.clearEmptyPixels(imgData);
20
+ const clearedImageData = this.clearEmptyPixels(imgData);
21
21
  return imgData;
22
22
  }
23
23
  update(imgData, options) {
@@ -26,7 +26,13 @@ class Filter {
26
26
  }
27
27
  clearEmptyPixels(imageData) {
28
28
  const rowRGBABuff = this.getRowRGBABuff(imageData);
29
- console.log('rowRGBABuff', rowRGBABuff);
29
+ const cleared = rowRGBABuff.filter((byteArray) => {
30
+ const a = byteArray[3];
31
+ return !!a;
32
+ });
33
+ const clearedImageData = cleared.flat();
34
+ console.log('cleared', cleared);
35
+ return clearedImageData;
30
36
  }
31
37
  getBuffCollection(imageData) {
32
38
  const rowRGBABuff = this.getRowRGBABuff(imageData);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvas-editor-engine",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "CanvasEditorEngine library, use: [typescript] [canvas]",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",