canvas-editor-engine 1.0.41 → 1.0.43

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.
@@ -20,12 +20,12 @@ class CropService {
20
20
  y: (config_1.default.CANVAS_SIZE.height / 2) - (options.height / 2),
21
21
  };
22
22
  filter.update(imageData, putOptions);
23
+ store_1.default.store.imageState.tempImageData = imageData;
23
24
  store_1.default.store.imageState.position = putOptions;
24
25
  store_1.default.store.imageState.size = {
25
26
  width: options.width,
26
27
  height: options.height,
27
28
  };
28
- console.log('AppStore.store', store_1.default.store);
29
29
  }
30
30
  static viewCropButton() {
31
31
  const cropButtons = excretions_component_1.default.excretionWrap.querySelectorAll('.crop-button');
@@ -1,7 +1,9 @@
1
1
  import type { IDrawImageArgs, IFilterOptions, IImageOptions } from "../types/image";
2
2
  export default class DrawService {
3
+ static scImage: SCImage;
3
4
  static drawImage(ctx: CanvasRenderingContext2D, src: string, options: IDrawImageArgs): void;
4
- static drawSmoothImage(ctx: CanvasRenderingContext2D, src: string, options: IDrawImageArgs, filterOptions: IFilterOptions): void;
5
+ static drawSmoothImage(useStore: boolean, options: IDrawImageArgs, filterOptions: IFilterOptions): void;
6
+ private static getFilterArgs;
5
7
  }
6
8
  export declare class SCImage {
7
9
  private img;
@@ -3,25 +3,43 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SCImage = void 0;
4
4
  const config_1 = require("../config");
5
5
  const filters_1 = require("../filters");
6
+ const store_1 = require("../store/store");
6
7
  class DrawService {
8
+ static scImage;
7
9
  static drawImage(ctx, src, options) {
8
- const img = new SCImage(src, ctx);
9
- img.draw(options);
10
+ DrawService.scImage = new SCImage(src, ctx);
11
+ DrawService.scImage.draw(options);
10
12
  }
11
- static drawSmoothImage(ctx, src, options, filterOptions) {
12
- const img = new SCImage(src, ctx);
13
- const filterArgs = {
14
- x: options.position.x,
15
- y: options.position.y,
16
- };
17
- if (options.size !== 'initial') {
18
- if (!!options.size?.width && !!options.size?.height) {
19
- filterArgs.width = options.size.width;
20
- filterArgs.height = options.size.height;
13
+ static drawSmoothImage(useStore, options, filterOptions) {
14
+ const filterArgs = DrawService.getFilterArgs(useStore, options);
15
+ this.scImage.draw(options).then(() => this.scImage.vague(filterArgs, filterOptions));
16
+ }
17
+ static getFilterArgs(useStore, options) {
18
+ let filterArgs;
19
+ const store = store_1.default.store.imageState;
20
+ if (useStore) {
21
+ filterArgs = {
22
+ x: store.position.x,
23
+ y: store.position.y,
24
+ };
25
+ if (!!store.size.width && !!store.size.height) {
26
+ filterArgs.width = store.size.width;
27
+ filterArgs.height = store.size.height;
28
+ }
29
+ }
30
+ else {
31
+ filterArgs = {
32
+ x: options.position.x,
33
+ y: options.position.y,
34
+ };
35
+ if (options.size !== 'initial') {
36
+ if (!!options.size?.width && !!options.size?.height) {
37
+ filterArgs.width = options.size.width;
38
+ filterArgs.height = options.size.height;
39
+ }
21
40
  }
22
41
  }
23
- console.log('filterArgs', filterArgs);
24
- img.draw(options).then(() => img.vague(filterArgs, filterOptions));
42
+ return filterArgs;
25
43
  }
26
44
  }
27
45
  exports.default = DrawService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvas-editor-engine",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "description": "CanvasEditorEngine library, use: [typescript] [canvas]",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",