@acorex/components 18.10.11 → 18.10.13
Sign up to get free protection for your applications and to get access to all the features.
- package/button/lib/button.component.d.ts +1 -1
- package/esm2022/button/lib/button.component.mjs +3 -3
- package/esm2022/color-box/lib/color-box.component.mjs +3 -3
- package/esm2022/conversation/lib/conversation-messages/conversation-message-file/conversation-message-file.component.mjs +1 -1
- package/esm2022/conversation/lib/conversation-messages/conversation-message-voice/conversation-message-voice.component.mjs +1 -1
- package/esm2022/image-editor/acorex-components-image-editor.mjs +5 -0
- package/esm2022/image-editor/index.mjs +8 -0
- package/esm2022/image-editor/lib/image-editor-container/image-editor-container.component.mjs +23 -0
- package/esm2022/image-editor/lib/image-editor-toolbar/image-editor-toolbar.component.mjs +69 -0
- package/esm2022/image-editor/lib/image-editor-tools/image-editor-color-picker/image-editor-color-picker.component.mjs +46 -0
- package/esm2022/image-editor/lib/image-editor-tools/image-editor-crop/image-editor-crop.component.mjs +36 -0
- package/esm2022/image-editor/lib/image-editor-tools/image-editor-pen-mode-changer/image-editor-pen-mode-changer.component.mjs +56 -0
- package/esm2022/image-editor/lib/image-editor-view/image-editor-view.component.mjs +304 -0
- package/esm2022/image-editor/lib/image-editor.module.mjs +69 -0
- package/esm2022/image-editor/lib/image-editor.service.mjs +22 -0
- package/esm2022/loading/lib/loading-spinner.component.mjs +7 -5
- package/esm2022/loading/lib/loading.component.mjs +2 -2
- package/esm2022/media-viewer/lib/media-viewer-container/media-viewer-container.component.mjs +3 -3
- package/esm2022/paint/index.mjs +1 -2
- package/esm2022/paint/lib/paint/paint-toolbar/paint-toolbar.component.mjs +3 -3
- package/esm2022/paint/lib/paint/paint-tools/paint-color-picker/paint-color-picker.component.mjs +3 -3
- package/esm2022/paint/lib/paint/paint-tools/paint-pen-mode-changer/paint-pen-mode-changer.component.mjs +3 -3
- package/esm2022/paint/lib/paint/paint-view/paint-view.component.mjs +2 -4
- package/esm2022/paint/lib/paint/paint.service.mjs +1 -2
- package/esm2022/paint/lib/paint.module.mjs +1 -5
- package/fesm2022/acorex-components-button.mjs +2 -2
- package/fesm2022/acorex-components-button.mjs.map +1 -1
- package/fesm2022/acorex-components-color-box.mjs +2 -2
- package/fesm2022/acorex-components-color-box.mjs.map +1 -1
- package/fesm2022/acorex-components-conversation.mjs +2 -2
- package/fesm2022/acorex-components-conversation.mjs.map +1 -1
- package/fesm2022/acorex-components-image-editor.mjs +595 -0
- package/fesm2022/acorex-components-image-editor.mjs.map +1 -0
- package/fesm2022/acorex-components-loading.mjs +8 -6
- package/fesm2022/acorex-components-loading.mjs.map +1 -1
- package/fesm2022/acorex-components-media-viewer.mjs +2 -2
- package/fesm2022/acorex-components-media-viewer.mjs.map +1 -1
- package/fesm2022/acorex-components-paint.mjs +9 -47
- package/fesm2022/acorex-components-paint.mjs.map +1 -1
- package/image-editor/README.md +3 -0
- package/image-editor/index.d.ts +7 -0
- package/image-editor/lib/image-editor-container/image-editor-container.component.d.ts +13 -0
- package/image-editor/lib/image-editor-toolbar/image-editor-toolbar.component.d.ts +27 -0
- package/image-editor/lib/image-editor-tools/image-editor-color-picker/image-editor-color-picker.component.d.ts +27 -0
- package/image-editor/lib/image-editor-tools/image-editor-crop/image-editor-crop.component.d.ts +18 -0
- package/image-editor/lib/image-editor-tools/image-editor-pen-mode-changer/image-editor-pen-mode-changer.component.d.ts +34 -0
- package/image-editor/lib/image-editor-view/image-editor-view.component.d.ts +65 -0
- package/image-editor/lib/image-editor.module.d.ts +21 -0
- package/image-editor/lib/image-editor.service.d.ts +24 -0
- package/loading/lib/loading-spinner.component.d.ts +1 -1
- package/media-viewer/lib/media-viewer-container/media-viewer-container.component.d.ts +1 -1
- package/package.json +30 -24
- package/paint/index.d.ts +0 -1
- package/paint/lib/paint/paint.service.d.ts +0 -1
- package/paint/lib/paint.module.d.ts +9 -10
- package/esm2022/paint/lib/paint/paint-tools/paint-pen-cap/paint-pen-cap.component.mjs +0 -37
- package/paint/lib/paint/paint-tools/paint-pen-cap/paint-pen-cap.component.d.ts +0 -20
@@ -0,0 +1,595 @@
|
|
1
|
+
import { MXLookComponent, MXInputBaseValueComponent, AXComponent, AXFocusableComponent, AXClearableComponent, AXValuableComponent } from '@acorex/components/common';
|
2
|
+
import * as i0 from '@angular/core';
|
3
|
+
import { signal, Injectable, inject, Component, ViewEncapsulation, forwardRef, HostBinding, input, viewChild, afterNextRender, effect, ChangeDetectionStrategy, NgModule } from '@angular/core';
|
4
|
+
import * as i1 from '@acorex/components/loading';
|
5
|
+
import { AXLoadingModule } from '@acorex/components/loading';
|
6
|
+
import { AXDialogService, AXDialogModule } from '@acorex/components/dialog';
|
7
|
+
import * as i2 from '@angular/forms';
|
8
|
+
import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
|
9
|
+
import * as i1$1 from '@acorex/components/button';
|
10
|
+
import { AXButtonModule } from '@acorex/components/button';
|
11
|
+
import * as i3 from '@acorex/components/color-palette';
|
12
|
+
import { AXColorPaletteModule } from '@acorex/components/color-palette';
|
13
|
+
import * as i4 from '@acorex/components/popover';
|
14
|
+
import { AXPopoverModule } from '@acorex/components/popover';
|
15
|
+
import * as i5 from '@acorex/components/decorators';
|
16
|
+
import { AXDecoratorModule } from '@acorex/components/decorators';
|
17
|
+
import * as i3$1 from '@acorex/components/range-slider';
|
18
|
+
import { AXRangeSliderModule } from '@acorex/components/range-slider';
|
19
|
+
import { AXSelectBoxModule } from '@acorex/components/select-box';
|
20
|
+
|
21
|
+
class AXImageEditorService {
|
22
|
+
constructor() {
|
23
|
+
this.penColor = signal('');
|
24
|
+
this.lineCap = signal('round');
|
25
|
+
this.lineWidth = signal(10);
|
26
|
+
this.penType = signal('pen');
|
27
|
+
this.toggleClear = signal({ state: false, userInteract: false });
|
28
|
+
this.cropState = signal({ state: false, userInteract: false });
|
29
|
+
this.rotate = signal({ state: 0, userInteract: false });
|
30
|
+
this.isImageLoad = signal(false);
|
31
|
+
this.newImage = signal(new Image());
|
32
|
+
this.initialImage = signal(new Image());
|
33
|
+
}
|
34
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
35
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorService }); }
|
36
|
+
}
|
37
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorService, decorators: [{
|
38
|
+
type: Injectable
|
39
|
+
}] });
|
40
|
+
|
41
|
+
/**
|
42
|
+
* paint container.
|
43
|
+
* @category Components
|
44
|
+
*/
|
45
|
+
class AXImageEditorContainerComponent extends MXLookComponent {
|
46
|
+
constructor() {
|
47
|
+
super(...arguments);
|
48
|
+
/** @ignore */
|
49
|
+
this.service = inject(AXImageEditorService);
|
50
|
+
}
|
51
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorContainerComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
52
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.0", type: AXImageEditorContainerComponent, selector: "ax-image-editor-container", providers: [AXImageEditorService], usesInheritance: true, ngImport: i0, template: "@if (service.isImageLoad()) {\n <div class=\"ax-editor-container ax-look-solid\">\n <ng-content> </ng-content>\n </div>\n} @else {\n <ax-loading-spinner [size]=\"16\" color=\"primary\" text=\"Loading Image ...\"></ax-loading-spinner>\n}\n", styles: ["ax-image-editor-container>.ax-editor-container{display:flex;flex-direction:column;justify-content:center;align-items:center;height:auto!important}\n"], dependencies: [{ kind: "component", type: i1.AXLoadingSpinnerComponent, selector: "ax-loading-spinner", inputs: ["text", "color", "size", "stroke"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
53
|
+
}
|
54
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorContainerComponent, decorators: [{
|
55
|
+
type: Component,
|
56
|
+
args: [{ selector: 'ax-image-editor-container', encapsulation: ViewEncapsulation.None, providers: [AXImageEditorService], template: "@if (service.isImageLoad()) {\n <div class=\"ax-editor-container ax-look-solid\">\n <ng-content> </ng-content>\n </div>\n} @else {\n <ax-loading-spinner [size]=\"16\" color=\"primary\" text=\"Loading Image ...\"></ax-loading-spinner>\n}\n", styles: ["ax-image-editor-container>.ax-editor-container{display:flex;flex-direction:column;justify-content:center;align-items:center;height:auto!important}\n"] }]
|
57
|
+
}] });
|
58
|
+
|
59
|
+
/**
|
60
|
+
*paint toolbar
|
61
|
+
* @category Components
|
62
|
+
*/
|
63
|
+
class AXImageEditorToolbarComponent extends MXInputBaseValueComponent {
|
64
|
+
constructor() {
|
65
|
+
super(...arguments);
|
66
|
+
/** @ignore */
|
67
|
+
this.dialogService = inject(AXDialogService);
|
68
|
+
/** @ignore */
|
69
|
+
this.service = inject(AXImageEditorService);
|
70
|
+
/** @ignore */
|
71
|
+
this.options = signal({
|
72
|
+
color: 'primary',
|
73
|
+
title: 'Attention',
|
74
|
+
vertical: false,
|
75
|
+
content: 'Do you want to save changes?',
|
76
|
+
orientation: 'vertical',
|
77
|
+
draggable: true,
|
78
|
+
});
|
79
|
+
}
|
80
|
+
/** @ignore */
|
81
|
+
saveHandler() {
|
82
|
+
if (this.service.initialImage() !== this.service.newImage()) {
|
83
|
+
this.dialogService
|
84
|
+
.confirm(this.options().title, this.options().content, this.options().color, this.options().orientation, this.options().draggable)
|
85
|
+
.then((data) => {
|
86
|
+
if (data.result) {
|
87
|
+
this.service.initialImage.set(this.service.newImage());
|
88
|
+
this.commitValue(this.service.newImage().src);
|
89
|
+
}
|
90
|
+
});
|
91
|
+
}
|
92
|
+
}
|
93
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorToolbarComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
94
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.0", type: AXImageEditorToolbarComponent, selector: "ax-image-editor-toolbar", outputs: { onValueChanged: "onValueChanged" }, providers: [
|
95
|
+
{ provide: AXComponent, useExisting: AXImageEditorToolbarComponent },
|
96
|
+
{ provide: AXFocusableComponent, useExisting: AXImageEditorToolbarComponent },
|
97
|
+
{ provide: AXClearableComponent, useExisting: AXImageEditorToolbarComponent },
|
98
|
+
{ provide: AXValuableComponent, useExisting: AXImageEditorToolbarComponent },
|
99
|
+
{
|
100
|
+
provide: NG_VALUE_ACCESSOR,
|
101
|
+
useExisting: forwardRef(() => AXImageEditorToolbarComponent),
|
102
|
+
multi: true,
|
103
|
+
},
|
104
|
+
], usesInheritance: true, ngImport: i0, template: "<div class=\"ax-toolbar-container\">\n <ng-content select=\"ax-prefix\"></ng-content>\n <ng-content></ng-content>\n <ng-content select=\"ax-suffix\"></ng-content>\n</div>\n<ax-button color=\"primary\" (onClick)=\"saveHandler()\" class=\"ax-save-btn ax-sm\" text=\"Save\"></ax-button>\n", styles: ["ax-image-editor-toolbar{padding:.3rem;width:100%;display:flex;align-items:center;justify-content:space-between}ax-image-editor-toolbar .ax-toolbar-container{display:flex;align-items:center;flex-wrap:wrap}ax-image-editor-toolbar .ax-icon{font-weight:900;font-size:1rem}ax-image-editor-toolbar .ax-save-btn{margin-inline:.5rem}\n"], dependencies: [{ kind: "component", type: i1$1.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "type", "responsiveOn", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "responsiveOnChange", "loadingTextChange"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
105
|
+
}
|
106
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorToolbarComponent, decorators: [{
|
107
|
+
type: Component,
|
108
|
+
args: [{ selector: 'ax-image-editor-toolbar', encapsulation: ViewEncapsulation.None, outputs: ['onValueChanged'], providers: [
|
109
|
+
{ provide: AXComponent, useExisting: AXImageEditorToolbarComponent },
|
110
|
+
{ provide: AXFocusableComponent, useExisting: AXImageEditorToolbarComponent },
|
111
|
+
{ provide: AXClearableComponent, useExisting: AXImageEditorToolbarComponent },
|
112
|
+
{ provide: AXValuableComponent, useExisting: AXImageEditorToolbarComponent },
|
113
|
+
{
|
114
|
+
provide: NG_VALUE_ACCESSOR,
|
115
|
+
useExisting: forwardRef(() => AXImageEditorToolbarComponent),
|
116
|
+
multi: true,
|
117
|
+
},
|
118
|
+
], template: "<div class=\"ax-toolbar-container\">\n <ng-content select=\"ax-prefix\"></ng-content>\n <ng-content></ng-content>\n <ng-content select=\"ax-suffix\"></ng-content>\n</div>\n<ax-button color=\"primary\" (onClick)=\"saveHandler()\" class=\"ax-save-btn ax-sm\" text=\"Save\"></ax-button>\n", styles: ["ax-image-editor-toolbar{padding:.3rem;width:100%;display:flex;align-items:center;justify-content:space-between}ax-image-editor-toolbar .ax-toolbar-container{display:flex;align-items:center;flex-wrap:wrap}ax-image-editor-toolbar .ax-icon{font-weight:900;font-size:1rem}ax-image-editor-toolbar .ax-save-btn{margin-inline:.5rem}\n"] }]
|
119
|
+
}] });
|
120
|
+
|
121
|
+
/**
|
122
|
+
* paint color picker.
|
123
|
+
* @category Components
|
124
|
+
*/
|
125
|
+
class AXImageEditorColorPickerComponent {
|
126
|
+
constructor() {
|
127
|
+
/** @ignore */
|
128
|
+
this.service = inject(AXImageEditorService);
|
129
|
+
/** @ignore */
|
130
|
+
this.selectedColor = signal('rgb(12, 12, 12)');
|
131
|
+
/** @ignore */
|
132
|
+
this.popoverOption = {
|
133
|
+
openOn: 'click',
|
134
|
+
closeOn: 'clickOut',
|
135
|
+
placement: 'top',
|
136
|
+
offsetX: 0,
|
137
|
+
offsetY: 0,
|
138
|
+
};
|
139
|
+
}
|
140
|
+
/** @ignore */
|
141
|
+
changeColorHandler(e) {
|
142
|
+
this.service.penColor.set(e);
|
143
|
+
this.selectedColor.set(e);
|
144
|
+
}
|
145
|
+
get __hostClass() {
|
146
|
+
return `.5rem`;
|
147
|
+
}
|
148
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorColorPickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
149
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.0", type: AXImageEditorColorPickerComponent, selector: "ax-image-editor-color-picker", host: { properties: { "style.marginInline": "this.__hostClass" } }, ngImport: i0, template: "<ax-button #colorBtn look=\"blank\">\n <ax-icon class=\"ax-icon ax-icon-color-palette\"></ax-icon>\n</ax-button>\n<ax-popover\n [openOn]=\"popoverOption.openOn\"\n [closeOn]=\"popoverOption.closeOn\"\n [target]=\"colorBtn\"\n [placement]=\"popoverOption.placement\"\n>\n <div class=\"ax-overlay-pane\">\n <ax-color-palette (ngModelChange)=\"changeColorHandler($event)\" [ngModel]=\"selectedColor()\">\n <ax-color-palette-preview></ax-color-palette-preview>\n <ax-color-palette-picker></ax-color-palette-picker>\n <ax-color-palette-input></ax-color-palette-input>\n </ax-color-palette>\n </div>\n</ax-popover>\n", dependencies: [{ kind: "component", type: i1$1.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "type", "responsiveOn", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "responsiveOnChange", "loadingTextChange"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i3.AXColorPalleteComponent, selector: "ax-color-palette", inputs: ["disabled", "tabIndex", "readonly", "value", "state", "name", "checked"], outputs: ["onBlur", "onFocus", "valueChange", "stateChange", "onValueChanged", "readonlyChange", "disabledChange"] }, { kind: "component", type: i3.AXColorPalettePreviewComponent, selector: "ax-color-palette-preview" }, { kind: "component", type: i3.AXColorPaletteInputComponent, selector: "ax-color-palette-input" }, { kind: "component", type: i3.AXColorPalettePickerComponent, selector: "ax-color-palette-picker" }, { kind: "component", type: i4.AXPopoverComponent, selector: "ax-popover", inputs: ["offsetX", "offsetY", "target", "placement", "content", "openOn", "closeOn", "hasBackdrop", "openAfter", "closeAfter", "backdropClass", "adaptivityEnabled"], outputs: ["onOpened", "onClosed"] }, { kind: "component", type: i5.AXDecoratorIconComponent, selector: "ax-icon", inputs: ["icon"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
150
|
+
}
|
151
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorColorPickerComponent, decorators: [{
|
152
|
+
type: Component,
|
153
|
+
args: [{ selector: 'ax-image-editor-color-picker', encapsulation: ViewEncapsulation.None, template: "<ax-button #colorBtn look=\"blank\">\n <ax-icon class=\"ax-icon ax-icon-color-palette\"></ax-icon>\n</ax-button>\n<ax-popover\n [openOn]=\"popoverOption.openOn\"\n [closeOn]=\"popoverOption.closeOn\"\n [target]=\"colorBtn\"\n [placement]=\"popoverOption.placement\"\n>\n <div class=\"ax-overlay-pane\">\n <ax-color-palette (ngModelChange)=\"changeColorHandler($event)\" [ngModel]=\"selectedColor()\">\n <ax-color-palette-preview></ax-color-palette-preview>\n <ax-color-palette-picker></ax-color-palette-picker>\n <ax-color-palette-input></ax-color-palette-input>\n </ax-color-palette>\n </div>\n</ax-popover>\n" }]
|
154
|
+
}], propDecorators: { __hostClass: [{
|
155
|
+
type: HostBinding,
|
156
|
+
args: ['style.marginInline']
|
157
|
+
}] } });
|
158
|
+
|
159
|
+
/**
|
160
|
+
* paint mode.
|
161
|
+
* @category Components
|
162
|
+
*/
|
163
|
+
class AXImageEditorCropComponent {
|
164
|
+
constructor() {
|
165
|
+
/** @ignore */
|
166
|
+
this.service = inject(AXImageEditorService);
|
167
|
+
}
|
168
|
+
/** @ignore */
|
169
|
+
rotateRightHandler() {
|
170
|
+
this.service.rotate.set({ state: 90, userInteract: true });
|
171
|
+
}
|
172
|
+
/** @ignore */
|
173
|
+
rotateLeftHandler() {
|
174
|
+
this.service.rotate.set({ state: -90, userInteract: true });
|
175
|
+
}
|
176
|
+
/** @ignore */
|
177
|
+
crop() {
|
178
|
+
this.service.cropState.update((prev) => {
|
179
|
+
return { userInteract: true, state: !prev.state };
|
180
|
+
});
|
181
|
+
}
|
182
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorCropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
183
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.0", type: AXImageEditorCropComponent, selector: "ax-image-editor-crop", ngImport: i0, template: "<ax-button [selected]=\"service.cropState().state && true\" (click)=\"crop()\" look=\"blank\">\n <ax-icon class=\"ax-icon ax-icon-crop\"></ax-icon>\n</ax-button>\n\n<ax-button (click)=\"rotateLeftHandler()\" look=\"blank\">\n <ax-icon class=\"ax-icon ax-icon-undo\"></ax-icon>\n</ax-button>\n\n<ax-button (click)=\"rotateRightHandler()\" look=\"blank\">\n <ax-icon class=\"ax-icon ax-icon-redo\"></ax-icon>\n</ax-button>\n", dependencies: [{ kind: "component", type: i1$1.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "type", "responsiveOn", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "responsiveOnChange", "loadingTextChange"] }, { kind: "component", type: i5.AXDecoratorIconComponent, selector: "ax-icon", inputs: ["icon"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
184
|
+
}
|
185
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorCropComponent, decorators: [{
|
186
|
+
type: Component,
|
187
|
+
args: [{ selector: 'ax-image-editor-crop', encapsulation: ViewEncapsulation.None, template: "<ax-button [selected]=\"service.cropState().state && true\" (click)=\"crop()\" look=\"blank\">\n <ax-icon class=\"ax-icon ax-icon-crop\"></ax-icon>\n</ax-button>\n\n<ax-button (click)=\"rotateLeftHandler()\" look=\"blank\">\n <ax-icon class=\"ax-icon ax-icon-undo\"></ax-icon>\n</ax-button>\n\n<ax-button (click)=\"rotateRightHandler()\" look=\"blank\">\n <ax-icon class=\"ax-icon ax-icon-redo\"></ax-icon>\n</ax-button>\n" }]
|
188
|
+
}] });
|
189
|
+
|
190
|
+
/**
|
191
|
+
* paint mode.
|
192
|
+
* @category Components
|
193
|
+
*/
|
194
|
+
class AXImageEditorPenModeChangerComponent {
|
195
|
+
constructor() {
|
196
|
+
/** @ignore */
|
197
|
+
this.service = inject(AXImageEditorService);
|
198
|
+
/** @ignore */
|
199
|
+
this.value = 10;
|
200
|
+
/** @ignore */
|
201
|
+
this.popoverOption = {
|
202
|
+
openOn: 'click',
|
203
|
+
closeOn: 'clickOut',
|
204
|
+
placement: 'top',
|
205
|
+
offsetX: 0,
|
206
|
+
offsetY: 0,
|
207
|
+
};
|
208
|
+
/** @ignore */
|
209
|
+
this.selectedPenType = signal('pen');
|
210
|
+
}
|
211
|
+
/** @ignore */
|
212
|
+
penTypeHandler(e) {
|
213
|
+
this.service.penType.set(e);
|
214
|
+
}
|
215
|
+
/** @ignore */
|
216
|
+
clear() {
|
217
|
+
this.service.toggleClear.set({ userInteract: true, state: true });
|
218
|
+
}
|
219
|
+
/** @ignore */
|
220
|
+
get __hostClass() {
|
221
|
+
return `.5rem`;
|
222
|
+
}
|
223
|
+
/** @ignore */
|
224
|
+
valueHandler(e) {
|
225
|
+
this.service.lineWidth.set(e);
|
226
|
+
}
|
227
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorPenModeChangerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
228
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.0", type: AXImageEditorPenModeChangerComponent, selector: "ax-image-editor-pen-mode-changer", host: { properties: { "style.marginInline": "this.__hostClass" } }, ngImport: i0, template: "<div class=\"ax-paint-pen-mode-changer-container\">\n <div class=\"ax-pen-type-container\">\n <ax-button look=\"blank\" #alignPop>\n <ax-icon class=\"ax-icon ax-icon-pen-ruler\"></ax-icon>\n </ax-button>\n </div>\n\n <ax-button (click)=\"clear()\" look=\"blank\">\n <ax-icon class=\"ax-icon ax-icon-refresh\"></ax-icon>\n </ax-button>\n\n <ax-popover\n [openOn]=\"popoverOption.openOn\"\n [closeOn]=\"popoverOption.closeOn\"\n [target]=\"alignPop\"\n [placement]=\"popoverOption.placement\"\n >\n <div class=\"ax-overlay-pane\">\n <ax-button\n (click)=\"penTypeHandler('pen')\"\n look=\"blank\"\n [selected]=\"this.service.penType() === 'pen' ? true : false\"\n >\n <ax-icon class=\"ax-icon ax-icon-pen\"></ax-icon>\n </ax-button>\n\n <ax-button\n (click)=\"penTypeHandler('highlight')\"\n look=\"blank\"\n [selected]=\"this.service.penType() === 'highlight' ? true : false\"\n >\n <ax-icon class=\"ax-icon ax-icon-highlight\"></ax-icon>\n </ax-button>\n\n <div class=\"ax-paint-width-slider\">\n <ax-range-slider\n [min]=\"2\"\n [max]=\"20\"\n [(ngModel)]=\"value\"\n (ngModelChange)=\"valueHandler($event)\"\n ></ax-range-slider>\n </div>\n </div>\n </ax-popover>\n</div>\n", styles: ["ax-range-slider{padding:.5rem .75rem}ax-range-slider .ax-range-slider .ax-range-slider-handler{width:1rem!important;height:1rem!important}.ax-paint-pen-mode-changer-container{display:flex;align-items:center}.ax-paint-pen-mode-changer-container .ax-pen-type-container{margin-inline-end:.5rem}.ax-overlay-pane{padding:.5rem!important}\n"], dependencies: [{ kind: "component", type: i1$1.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "type", "responsiveOn", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "responsiveOnChange", "loadingTextChange"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i3$1.AXRangeSliderComponent, selector: "ax-range-slider", inputs: ["disabled", "readonly", "orientation", "color", "values", "mode", "min", "max", "step", "snap", "tooltipMode", "snapMode", "hasStep", "hasSnap", "hasLable", "hasTooltip"], outputs: ["valuesChange"] }, { kind: "component", type: i4.AXPopoverComponent, selector: "ax-popover", inputs: ["offsetX", "offsetY", "target", "placement", "content", "openOn", "closeOn", "hasBackdrop", "openAfter", "closeAfter", "backdropClass", "adaptivityEnabled"], outputs: ["onOpened", "onClosed"] }, { kind: "component", type: i5.AXDecoratorIconComponent, selector: "ax-icon", inputs: ["icon"] }], encapsulation: i0.ViewEncapsulation.None }); }
|
229
|
+
}
|
230
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorPenModeChangerComponent, decorators: [{
|
231
|
+
type: Component,
|
232
|
+
args: [{ selector: 'ax-image-editor-pen-mode-changer', encapsulation: ViewEncapsulation.None, template: "<div class=\"ax-paint-pen-mode-changer-container\">\n <div class=\"ax-pen-type-container\">\n <ax-button look=\"blank\" #alignPop>\n <ax-icon class=\"ax-icon ax-icon-pen-ruler\"></ax-icon>\n </ax-button>\n </div>\n\n <ax-button (click)=\"clear()\" look=\"blank\">\n <ax-icon class=\"ax-icon ax-icon-refresh\"></ax-icon>\n </ax-button>\n\n <ax-popover\n [openOn]=\"popoverOption.openOn\"\n [closeOn]=\"popoverOption.closeOn\"\n [target]=\"alignPop\"\n [placement]=\"popoverOption.placement\"\n >\n <div class=\"ax-overlay-pane\">\n <ax-button\n (click)=\"penTypeHandler('pen')\"\n look=\"blank\"\n [selected]=\"this.service.penType() === 'pen' ? true : false\"\n >\n <ax-icon class=\"ax-icon ax-icon-pen\"></ax-icon>\n </ax-button>\n\n <ax-button\n (click)=\"penTypeHandler('highlight')\"\n look=\"blank\"\n [selected]=\"this.service.penType() === 'highlight' ? true : false\"\n >\n <ax-icon class=\"ax-icon ax-icon-highlight\"></ax-icon>\n </ax-button>\n\n <div class=\"ax-paint-width-slider\">\n <ax-range-slider\n [min]=\"2\"\n [max]=\"20\"\n [(ngModel)]=\"value\"\n (ngModelChange)=\"valueHandler($event)\"\n ></ax-range-slider>\n </div>\n </div>\n </ax-popover>\n</div>\n", styles: ["ax-range-slider{padding:.5rem .75rem}ax-range-slider .ax-range-slider .ax-range-slider-handler{width:1rem!important;height:1rem!important}.ax-paint-pen-mode-changer-container{display:flex;align-items:center}.ax-paint-pen-mode-changer-container .ax-pen-type-container{margin-inline-end:.5rem}.ax-overlay-pane{padding:.5rem!important}\n"] }]
|
233
|
+
}], propDecorators: { __hostClass: [{
|
234
|
+
type: HostBinding,
|
235
|
+
args: ['style.marginInline']
|
236
|
+
}] } });
|
237
|
+
|
238
|
+
class AXImageEditorViewComponent {
|
239
|
+
/** @ignore */
|
240
|
+
constructor() {
|
241
|
+
/**
|
242
|
+
* its receive image src.
|
243
|
+
*/
|
244
|
+
this.src = input('');
|
245
|
+
/** @ignore */
|
246
|
+
this.canvasElem = viewChild('canvasElem');
|
247
|
+
/** @ignore */
|
248
|
+
this.ctx = signal(null);
|
249
|
+
/** @ignore */
|
250
|
+
this.service = inject(AXImageEditorService);
|
251
|
+
/** @ignore */
|
252
|
+
this.cropImageData = signal(null);
|
253
|
+
/** @ignore */
|
254
|
+
this.isMouseDown = signal(false);
|
255
|
+
/** @ignore */
|
256
|
+
this.cropStartX = signal(0);
|
257
|
+
/** @ignore */
|
258
|
+
this.cropStartY = signal(0);
|
259
|
+
/** @ignore */
|
260
|
+
this.cropEndX = signal(0);
|
261
|
+
/** @ignore */
|
262
|
+
this.cropEndY = signal(0);
|
263
|
+
afterNextRender(() => {
|
264
|
+
this.service.initialImage().src = this.src();
|
265
|
+
this.service.initialImage().crossOrigin = 'anonymous';
|
266
|
+
this.EventListener = this.service.initialImage().addEventListener('load', this.imageLoaded.bind(this));
|
267
|
+
});
|
268
|
+
effect(() => {
|
269
|
+
if (!this.service.toggleClear().userInteract)
|
270
|
+
return;
|
271
|
+
if (this.service.toggleClear().state) {
|
272
|
+
this.imageLoaded();
|
273
|
+
}
|
274
|
+
}, { allowSignalWrites: true });
|
275
|
+
effect(() => {
|
276
|
+
if (!this.service.cropState().userInteract || !this.ctx())
|
277
|
+
return;
|
278
|
+
if (this.service.cropState().state) {
|
279
|
+
this.ctx().filter = 'brightness(40%)';
|
280
|
+
}
|
281
|
+
else {
|
282
|
+
this.ctx().filter = 'brightness(100%)';
|
283
|
+
}
|
284
|
+
this.ctx().drawImage(this.service.newImage(), 0, 0, this.service.newImage().width, this.service.newImage().height);
|
285
|
+
}, { allowSignalWrites: true });
|
286
|
+
effect(() => {
|
287
|
+
if (!this.service.rotate().userInteract || !this.ctx())
|
288
|
+
return;
|
289
|
+
this.rotateImage();
|
290
|
+
}, { allowSignalWrites: true });
|
291
|
+
}
|
292
|
+
/** @ignore */
|
293
|
+
ngOnDestroy() {
|
294
|
+
removeEventListener('load', this.EventListener);
|
295
|
+
}
|
296
|
+
/** @ignore */
|
297
|
+
imageLoaded() {
|
298
|
+
this.service.newImage.set(this.service.initialImage());
|
299
|
+
this.canvasElem().nativeElement.width = this.service.initialImage().width;
|
300
|
+
this.canvasElem().nativeElement.height = this.service.initialImage().height;
|
301
|
+
this.ctx.set(this.canvasElem().nativeElement.getContext('2d', { willReadFrequently: true }));
|
302
|
+
this.ctx().drawImage(this.service.initialImage(), 0, 0, this.service.initialImage().width, this.service.initialImage().height);
|
303
|
+
this.service.toggleClear.set({ userInteract: false, state: false });
|
304
|
+
this.service.isImageLoad.set(true);
|
305
|
+
this.ctx().lineJoin = 'round';
|
306
|
+
this.ctx().lineCap = this.service.lineCap();
|
307
|
+
this.ctx().strokeStyle = this.service.penColor();
|
308
|
+
this.ctx().lineWidth = this.service.lineWidth();
|
309
|
+
this.ctx().globalCompositeOperation = 'source-over';
|
310
|
+
this.ctx().globalAlpha = 1;
|
311
|
+
}
|
312
|
+
/** @ignore */
|
313
|
+
penConfigHandler(penType) {
|
314
|
+
switch (penType) {
|
315
|
+
case 'pen':
|
316
|
+
this.ctx().globalAlpha = 1;
|
317
|
+
break;
|
318
|
+
case 'highlight':
|
319
|
+
this.ctx().globalAlpha = 0.008;
|
320
|
+
break;
|
321
|
+
}
|
322
|
+
}
|
323
|
+
/** @ignore */
|
324
|
+
getBoundingCanvasHandler() {
|
325
|
+
return this.canvasElem().nativeElement.getBoundingClientRect();
|
326
|
+
}
|
327
|
+
/** @ignore */
|
328
|
+
mouseDownHandler(e) {
|
329
|
+
this.isMouseDown.set(true);
|
330
|
+
if (this.service.cropState().state) {
|
331
|
+
this.cropStartX.set(e.offsetX);
|
332
|
+
this.cropStartY.set(e.offsetY);
|
333
|
+
this.cropEndX.set(0);
|
334
|
+
}
|
335
|
+
else {
|
336
|
+
this.penConfigHandler(this.service.penType());
|
337
|
+
this.ctx().strokeStyle = this.service.penColor();
|
338
|
+
this.ctx().lineCap = this.service.lineCap();
|
339
|
+
this.ctx().lineWidth = this.service.lineWidth();
|
340
|
+
this.ctx().beginPath();
|
341
|
+
this.ctx().moveTo(e.offsetX, e.offsetY);
|
342
|
+
this.ctx().lineTo(e.offsetX, e.offsetY);
|
343
|
+
this.ctx().stroke();
|
344
|
+
}
|
345
|
+
}
|
346
|
+
/** @ignore */
|
347
|
+
mouseMoveHandler(e) {
|
348
|
+
if (!this.isMouseDown())
|
349
|
+
return;
|
350
|
+
if (this.service.cropState().state) {
|
351
|
+
this.ctx().globalCompositeOperation = 'screen';
|
352
|
+
this.cropEndX.set(e.offsetX);
|
353
|
+
this.cropEndY.set(e.offsetY);
|
354
|
+
this.drawSelection();
|
355
|
+
}
|
356
|
+
else {
|
357
|
+
this.ctx().lineTo(e.offsetX, e.offsetY);
|
358
|
+
this.ctx().stroke();
|
359
|
+
}
|
360
|
+
}
|
361
|
+
/** @ignore */
|
362
|
+
mouseUpHandler() {
|
363
|
+
this.isMouseDown.set(false);
|
364
|
+
if (this.service.cropState().state && this.cropEndX()) {
|
365
|
+
this.ctx().globalCompositeOperation = 'source-over';
|
366
|
+
this.cropImageFunction();
|
367
|
+
}
|
368
|
+
else {
|
369
|
+
this.ctx().closePath();
|
370
|
+
this.saveImageChange();
|
371
|
+
}
|
372
|
+
}
|
373
|
+
/** @ignore */
|
374
|
+
touchStartHandler(e) {
|
375
|
+
const offsetX = e.touches[0].clientX - this.getBoundingCanvasHandler().left;
|
376
|
+
const offsetY = e.touches[0].clientY - this.getBoundingCanvasHandler().top;
|
377
|
+
this.isMouseDown.set(true);
|
378
|
+
if (this.service.cropState().state) {
|
379
|
+
this.cropStartX.set(offsetX);
|
380
|
+
this.cropStartY.set(offsetY);
|
381
|
+
this.cropEndX.set(0);
|
382
|
+
}
|
383
|
+
else {
|
384
|
+
this.penConfigHandler(this.service.penType());
|
385
|
+
this.ctx().strokeStyle = this.service.penColor();
|
386
|
+
this.ctx().lineCap = this.service.lineCap();
|
387
|
+
this.ctx().lineWidth = this.service.lineWidth();
|
388
|
+
this.ctx().beginPath();
|
389
|
+
this.ctx().moveTo(offsetX, offsetY);
|
390
|
+
this.ctx().lineTo(offsetX, offsetY);
|
391
|
+
this.ctx().stroke();
|
392
|
+
}
|
393
|
+
}
|
394
|
+
/** @ignore */
|
395
|
+
touchMoveHandler(e) {
|
396
|
+
e.preventDefault(); // prevent page from scroll
|
397
|
+
if (!this.isMouseDown())
|
398
|
+
return;
|
399
|
+
const offsetX = e.touches[0].clientX - this.getBoundingCanvasHandler().left;
|
400
|
+
const offsetY = e.touches[0].clientY - this.getBoundingCanvasHandler().top;
|
401
|
+
if (this.service.cropState().state) {
|
402
|
+
this.ctx().globalCompositeOperation = 'screen';
|
403
|
+
this.cropEndX.set(offsetX);
|
404
|
+
this.cropEndY.set(offsetY);
|
405
|
+
this.drawSelection();
|
406
|
+
}
|
407
|
+
else {
|
408
|
+
this.ctx().lineTo(offsetX, offsetY);
|
409
|
+
this.ctx().stroke();
|
410
|
+
}
|
411
|
+
}
|
412
|
+
/** @ignore */
|
413
|
+
touchEndHandler() {
|
414
|
+
this.isMouseDown.set(false);
|
415
|
+
if (this.service.cropState().state && this.cropEndX()) {
|
416
|
+
this.ctx().globalCompositeOperation = 'source-over';
|
417
|
+
this.cropImageFunction();
|
418
|
+
}
|
419
|
+
else {
|
420
|
+
this.ctx().closePath();
|
421
|
+
this.saveImageChange();
|
422
|
+
}
|
423
|
+
}
|
424
|
+
/** @ignore */
|
425
|
+
drawSelection() {
|
426
|
+
const cropWidth = this.cropEndX() - this.cropStartX();
|
427
|
+
const cropHeight = this.cropEndY() - this.cropStartY();
|
428
|
+
this.ctx().clearRect(0, 0, this.canvasElem().nativeElement.width, this.canvasElem().nativeElement.height);
|
429
|
+
this.ctx().drawImage(this.service.newImage(), 0, 0);
|
430
|
+
this.ctx().strokeStyle = 'white';
|
431
|
+
this.ctx().setLineDash([4, 10]);
|
432
|
+
this.ctx().lineWidth = 2;
|
433
|
+
this.ctx().strokeRect(this.cropStartX(), this.cropStartY(), cropWidth, cropHeight);
|
434
|
+
}
|
435
|
+
/** @ignore */
|
436
|
+
cropImageFunction() {
|
437
|
+
this.ctx().clearRect(0, 0, this.canvasElem().nativeElement.width, this.canvasElem().nativeElement.height);
|
438
|
+
this.ctx().drawImage(this.service.newImage(), 0, 0);
|
439
|
+
let imageData;
|
440
|
+
if (this.cropStartX() < this.cropEndX() && this.cropStartY() > this.cropEndY()) {
|
441
|
+
imageData = this.ctx().getImageData(this.cropStartX(), this.cropEndY(), this.cropEndX() - this.cropStartX(), this.cropStartY() - this.cropEndY());
|
442
|
+
}
|
443
|
+
else if (this.cropStartX() > this.cropEndX() && this.cropStartY() > this.cropEndY()) {
|
444
|
+
imageData = this.ctx().getImageData(this.cropEndX(), this.cropEndY(), this.cropStartX() - this.cropEndX(), this.cropStartY() - this.cropEndY());
|
445
|
+
}
|
446
|
+
else if (this.cropStartX() < this.cropEndX() && this.cropStartY() < this.cropEndY()) {
|
447
|
+
imageData = this.ctx().getImageData(this.cropStartX(), this.cropStartY(), this.cropEndX() - this.cropStartX(), this.cropEndY() - this.cropStartY());
|
448
|
+
}
|
449
|
+
else if (this.cropStartX() > this.cropEndX() && this.cropStartY() < this.cropEndY()) {
|
450
|
+
imageData = this.ctx().getImageData(this.cropEndX(), this.cropStartY(), this.cropStartX() - this.cropEndX(), this.cropEndY() - this.cropStartY());
|
451
|
+
}
|
452
|
+
const data = imageData.data;
|
453
|
+
const brightnessFactor = 2.4; // Increase brightness by 20%
|
454
|
+
for (let i = 0; i < data.length; i += 4) {
|
455
|
+
data[i] = data[i] * brightnessFactor; // Red
|
456
|
+
data[i + 1] = data[i + 1] * brightnessFactor; // Green
|
457
|
+
data[i + 2] = data[i + 2] * brightnessFactor; // Blue
|
458
|
+
}
|
459
|
+
if (this.cropStartX() < this.cropEndX() && this.cropStartY() > this.cropEndY()) {
|
460
|
+
this.ctx().putImageData(imageData, this.cropStartX(), this.cropEndY());
|
461
|
+
}
|
462
|
+
else if (this.cropStartX() > this.cropEndX() && this.cropStartY() > this.cropEndY()) {
|
463
|
+
this.ctx().putImageData(imageData, this.cropEndX(), this.cropEndY());
|
464
|
+
}
|
465
|
+
else if (this.cropStartX() < this.cropEndX() && this.cropStartY() < this.cropEndY()) {
|
466
|
+
this.ctx().putImageData(imageData, this.cropStartX(), this.cropStartY());
|
467
|
+
}
|
468
|
+
else if (this.cropStartX() > this.cropEndX() && this.cropStartY() < this.cropEndY()) {
|
469
|
+
this.ctx().putImageData(imageData, this.cropEndX(), this.cropStartY());
|
470
|
+
}
|
471
|
+
this.cropImageData.set(imageData);
|
472
|
+
}
|
473
|
+
/** @ignore */
|
474
|
+
cropButtonHandler() {
|
475
|
+
let cropWidth;
|
476
|
+
let cropHeight;
|
477
|
+
this.service.rotate.update((prev) => {
|
478
|
+
return { userInteract: false, state: prev.state };
|
479
|
+
});
|
480
|
+
if (this.cropStartX() < this.cropEndX() && this.cropStartY() > this.cropEndY()) {
|
481
|
+
cropWidth = this.cropEndX() - this.cropStartX();
|
482
|
+
cropHeight = this.cropStartY() - this.cropEndY();
|
483
|
+
}
|
484
|
+
else if (this.cropStartX() > this.cropEndX() && this.cropStartY() > this.cropEndY()) {
|
485
|
+
cropWidth = this.cropStartX() - this.cropEndX();
|
486
|
+
cropHeight = this.cropStartY() - this.cropEndY();
|
487
|
+
}
|
488
|
+
else if (this.cropStartX() < this.cropEndX() && this.cropStartY() < this.cropEndY()) {
|
489
|
+
cropWidth = this.cropEndX() - this.cropStartX();
|
490
|
+
cropHeight = this.cropEndY() - this.cropStartY();
|
491
|
+
}
|
492
|
+
else if (this.cropStartX() > this.cropEndX() && this.cropStartY() < this.cropEndY()) {
|
493
|
+
cropWidth = this.cropStartX() - this.cropEndX();
|
494
|
+
cropHeight = this.cropEndY() - this.cropStartY();
|
495
|
+
}
|
496
|
+
this.canvasElem().nativeElement.width = cropWidth;
|
497
|
+
this.canvasElem().nativeElement.height = cropHeight;
|
498
|
+
this.ctx().putImageData(this.cropImageData(), 0, 0);
|
499
|
+
this.saveImageChange();
|
500
|
+
this.cropImageData.set(null);
|
501
|
+
this.service.cropState.set({ userInteract: false, state: false });
|
502
|
+
}
|
503
|
+
/** @ignore */
|
504
|
+
rotateImage() {
|
505
|
+
this.ctx().save();
|
506
|
+
this.ctx().clearRect(0, 0, this.canvasElem().nativeElement.width, this.canvasElem().nativeElement.height);
|
507
|
+
this.ctx().translate(this.service.newImage().width / 2, this.service.newImage().height / 2);
|
508
|
+
this.ctx().rotate((this.service.rotate().state * Math.PI) / 180);
|
509
|
+
this.ctx().drawImage(this.service.newImage(), -this.service.newImage().width / 2, -this.service.newImage().height / 2, this.service.newImage().width, this.service.newImage().height);
|
510
|
+
this.ctx().restore();
|
511
|
+
this.saveImageChange();
|
512
|
+
this.service.rotate.update((prev) => {
|
513
|
+
return { state: prev.state, userInteract: false };
|
514
|
+
});
|
515
|
+
}
|
516
|
+
/** @ignore */
|
517
|
+
saveImageChange() {
|
518
|
+
const newImage = new Image();
|
519
|
+
newImage.crossOrigin = 'anonymous';
|
520
|
+
newImage.src = this.canvasElem().nativeElement.toDataURL('image/jpeg', 1);
|
521
|
+
this.service.newImage.set(newImage);
|
522
|
+
}
|
523
|
+
/** @ignore */
|
524
|
+
get __hostStyle() {
|
525
|
+
return `width: ${this.service.initialImage().width}px; height: ${this.service.initialImage().height}px`;
|
526
|
+
}
|
527
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorViewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
528
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "18.2.0", type: AXImageEditorViewComponent, selector: "ax-image-editor-view", inputs: { src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style": "this.__hostStyle" } }, viewQueries: [{ propertyName: "canvasElem", first: true, predicate: ["canvasElem"], descendants: true, isSignal: true }], ngImport: i0, template: "<canvas\n tabindex=\"1\"\n (mousedown)=\"mouseDownHandler($event)\"\n (mouseup)=\"mouseUpHandler()\"\n (mousemove)=\"mouseMoveHandler($event)\"\n (touchstart)=\"touchStartHandler($event)\"\n (touchend)=\"touchEndHandler()\"\n (touchmove)=\"touchMoveHandler($event)\"\n class=\"ax-canvas-element\"\n #canvasElem\n></canvas>\n<ax-button\n (click)=\"cropButtonHandler()\"\n [style]=\"{ display: service.cropState().state ? 'block' : 'none' }\"\n class=\"ax-crop-save ax-sm\"\n text=\"Crop\"\n></ax-button>\n", styles: ["ax-image-editor-view{position:relative;display:flex;justify-content:center;align-items:center;background-color:#fff;width:100%}ax-image-editor-view .ax-canvas-element{cursor:crosshair}ax-image-editor-view .ax-crop-save{position:absolute;top:0;right:0;margin:1rem}\n"], dependencies: [{ kind: "component", type: i1$1.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "type", "responsiveOn", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "responsiveOnChange", "loadingTextChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
529
|
+
}
|
530
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorViewComponent, decorators: [{
|
531
|
+
type: Component,
|
532
|
+
args: [{ selector: 'ax-image-editor-view', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<canvas\n tabindex=\"1\"\n (mousedown)=\"mouseDownHandler($event)\"\n (mouseup)=\"mouseUpHandler()\"\n (mousemove)=\"mouseMoveHandler($event)\"\n (touchstart)=\"touchStartHandler($event)\"\n (touchend)=\"touchEndHandler()\"\n (touchmove)=\"touchMoveHandler($event)\"\n class=\"ax-canvas-element\"\n #canvasElem\n></canvas>\n<ax-button\n (click)=\"cropButtonHandler()\"\n [style]=\"{ display: service.cropState().state ? 'block' : 'none' }\"\n class=\"ax-crop-save ax-sm\"\n text=\"Crop\"\n></ax-button>\n", styles: ["ax-image-editor-view{position:relative;display:flex;justify-content:center;align-items:center;background-color:#fff;width:100%}ax-image-editor-view .ax-canvas-element{cursor:crosshair}ax-image-editor-view .ax-crop-save{position:absolute;top:0;right:0;margin:1rem}\n"] }]
|
533
|
+
}], ctorParameters: () => [], propDecorators: { __hostStyle: [{
|
534
|
+
type: HostBinding,
|
535
|
+
args: ['style']
|
536
|
+
}] } });
|
537
|
+
|
538
|
+
const COMPONENT = [
|
539
|
+
AXImageEditorToolbarComponent,
|
540
|
+
AXImageEditorColorPickerComponent,
|
541
|
+
AXImageEditorPenModeChangerComponent,
|
542
|
+
AXImageEditorViewComponent,
|
543
|
+
AXImageEditorContainerComponent,
|
544
|
+
AXImageEditorCropComponent,
|
545
|
+
];
|
546
|
+
const MODULES = [
|
547
|
+
AXButtonModule,
|
548
|
+
FormsModule,
|
549
|
+
AXRangeSliderModule,
|
550
|
+
AXSelectBoxModule,
|
551
|
+
AXColorPaletteModule,
|
552
|
+
AXPopoverModule,
|
553
|
+
AXDecoratorModule,
|
554
|
+
AXLoadingModule,
|
555
|
+
AXDialogModule,
|
556
|
+
];
|
557
|
+
class AXImageEditorModule {
|
558
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
559
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorModule, declarations: [AXImageEditorToolbarComponent,
|
560
|
+
AXImageEditorColorPickerComponent,
|
561
|
+
AXImageEditorPenModeChangerComponent,
|
562
|
+
AXImageEditorViewComponent,
|
563
|
+
AXImageEditorContainerComponent,
|
564
|
+
AXImageEditorCropComponent], imports: [AXButtonModule,
|
565
|
+
FormsModule,
|
566
|
+
AXRangeSliderModule,
|
567
|
+
AXSelectBoxModule,
|
568
|
+
AXColorPaletteModule,
|
569
|
+
AXPopoverModule,
|
570
|
+
AXDecoratorModule,
|
571
|
+
AXLoadingModule,
|
572
|
+
AXDialogModule], exports: [AXImageEditorToolbarComponent,
|
573
|
+
AXImageEditorColorPickerComponent,
|
574
|
+
AXImageEditorPenModeChangerComponent,
|
575
|
+
AXImageEditorViewComponent,
|
576
|
+
AXImageEditorContainerComponent,
|
577
|
+
AXImageEditorCropComponent] }); }
|
578
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorModule, imports: [MODULES] }); }
|
579
|
+
}
|
580
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: AXImageEditorModule, decorators: [{
|
581
|
+
type: NgModule,
|
582
|
+
args: [{
|
583
|
+
declarations: [...COMPONENT],
|
584
|
+
imports: [...MODULES],
|
585
|
+
exports: [...COMPONENT],
|
586
|
+
providers: [],
|
587
|
+
}]
|
588
|
+
}] });
|
589
|
+
|
590
|
+
/**
|
591
|
+
* Generated bundle index. Do not edit.
|
592
|
+
*/
|
593
|
+
|
594
|
+
export { AXImageEditorColorPickerComponent, AXImageEditorContainerComponent, AXImageEditorCropComponent, AXImageEditorModule, AXImageEditorPenModeChangerComponent, AXImageEditorToolbarComponent, AXImageEditorViewComponent };
|
595
|
+
//# sourceMappingURL=acorex-components-image-editor.mjs.map
|