canvas-editor-engine 1.0.36 → 1.0.38
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,7 @@
|
|
1
|
+
import { IImageOptions } from "../types/image";
|
1
2
|
export default class CropService {
|
2
3
|
static setup(): void;
|
3
|
-
static crop(): void;
|
4
|
+
static crop(ctx: CanvasRenderingContext2D): void;
|
4
5
|
static viewCropButton(): void;
|
5
|
-
static get options():
|
6
|
-
x: number;
|
7
|
-
y: number;
|
8
|
-
width: number;
|
9
|
-
height: number;
|
10
|
-
};
|
6
|
+
static get options(): IImageOptions;
|
11
7
|
}
|
@@ -1,14 +1,24 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const excretions_component_1 = require("../components/excretions.component");
|
4
|
+
const config_1 = require("../config");
|
5
|
+
const filter_1 = require("../utils/filter");
|
4
6
|
class CropService {
|
5
7
|
static setup() {
|
6
8
|
excretions_component_1.default.additionStyle = 'crop';
|
7
9
|
}
|
8
|
-
static crop() {
|
10
|
+
static crop(ctx) {
|
9
11
|
if (!!excretions_component_1.default.excretionsCoords?.length === false)
|
10
12
|
return;
|
11
13
|
console.log(CropService.options);
|
14
|
+
const filter = new filter_1.Filter(ctx);
|
15
|
+
const options = CropService.options;
|
16
|
+
const imageData = filter.copy(options);
|
17
|
+
const putOptions = {
|
18
|
+
x: (config_1.default.CANVAS_SIZE.width / 2) - (options.width / 2),
|
19
|
+
y: (config_1.default.CANVAS_SIZE.height / 2) - (options.height / 2),
|
20
|
+
};
|
21
|
+
filter.update(imageData, putOptions);
|
12
22
|
}
|
13
23
|
static viewCropButton() {
|
14
24
|
const cropButtons = excretions_component_1.default.excretionWrap.querySelectorAll('.crop-button');
|
package/dist/utils/filter.js
CHANGED
@@ -20,6 +20,7 @@ class Filter {
|
|
20
20
|
return imgData;
|
21
21
|
}
|
22
22
|
update(imgData, options) {
|
23
|
+
this.ctx.clearRect(0, 0, config_1.default.CANVAS_SIZE.width, config_1.default.CANVAS_SIZE.height);
|
23
24
|
this.ctx.putImageData(imgData, options.x, options.y);
|
24
25
|
}
|
25
26
|
getBuffCollection(imageData) {
|