amotify 0.0.2 → 0.0.4
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.
- package/dist/src/@jsminAmotifyExtension/_.d.ts +4 -0
- package/dist/src/@jsminAmotifyExtension/fetch.d.ts +9 -0
- package/dist/src/@jsminAmotifyExtension/formCollect.d.ts +1 -0
- package/dist/src/@jsminAmotifyExtension/spreadSheet.d.ts +4 -0
- package/dist/src/@jsminAmotifyExtension/variables.d.ts +0 -0
- package/dist/src/@types/_.d.ts +6 -0
- package/dist/src/@types/amot.d.ts +260 -0
- package/dist/src/@types/fn.d.ts +1040 -0
- package/dist/src/@types/index.d.ts +62 -0
- package/dist/src/@types/jsminAmotifyExtension.d.ts +134 -0
- package/dist/src/@types/module.d.ts +2 -0
- package/dist/src/@types/state.d.ts +145 -0
- package/dist/src/Atoms/@export.d.ts +4 -0
- package/dist/src/Atoms/FAIcon/parts.d.ts +2 -0
- package/dist/src/Atoms/Logo/parts.d.ts +1 -0
- package/dist/src/Atoms/Various/parts.d.ts +9 -0
- package/dist/src/Functions/@export.d.ts +12 -0
- package/dist/src/Functions/Button/_.d.ts +1 -0
- package/dist/src/Functions/Cropper/parts.d.ts +1 -0
- package/dist/src/Functions/Effects/Fade.d.ts +1 -0
- package/dist/src/Functions/Effects/Ripple.d.ts +1 -0
- package/dist/src/Functions/Effects/_.d.ts +3 -0
- package/dist/src/Functions/Input/Chips/Selector.d.ts +1 -0
- package/dist/src/Functions/Input/Chips/_.d.ts +2 -0
- package/dist/src/Functions/Input/DigitCharacters.d.ts +1 -0
- package/dist/src/Functions/Input/File/_.d.ts +2 -0
- package/dist/src/Functions/Input/Hidden.d.ts +1 -0
- package/dist/src/Functions/Input/List/_.d.ts +1 -0
- package/dist/src/Functions/Input/Segmented/_.d.ts +1 -0
- package/dist/src/Functions/Input/Select/_.d.ts +1 -0
- package/dist/src/Functions/Input/Slider/_.d.ts +1 -0
- package/dist/src/Functions/Input/Switch/_.d.ts +1 -0
- package/dist/src/Functions/Input/Text.d.ts +5 -0
- package/dist/src/Functions/Input/TextArea.d.ts +1 -0
- package/dist/src/Functions/Input/Time/Picker.d.ts +1 -0
- package/dist/src/Functions/Input/Time/_.d.ts +2 -0
- package/dist/src/Functions/Input/_.d.ts +5 -0
- package/dist/src/Functions/Input/core.d.ts +34 -0
- package/dist/src/Functions/Inputs/_.d.ts +3 -0
- package/dist/src/Functions/Inputs/text.d.ts +12 -0
- package/dist/src/Functions/Layout/PageNotFound.d.ts +1 -0
- package/dist/src/Functions/Layout/PageRouter.d.ts +2 -0
- package/dist/src/Functions/Layout/PageViewController/parts.d.ts +1 -0
- package/dist/src/Functions/Layout/Plate.d.ts +1 -0
- package/dist/src/Functions/Layout/RootViewController/parts.d.ts +1 -0
- package/dist/src/Functions/Layout/SwipeView/parts.d.ts +2 -0
- package/dist/src/Functions/Layout/TabBar.d.ts +1 -0
- package/dist/src/Functions/Layout/_.d.ts +2 -0
- package/dist/src/Functions/Loader/corner.d.ts +1 -0
- package/dist/src/Functions/Loader/mini.d.ts +33 -0
- package/dist/src/Functions/Loader/parts.d.ts +3 -0
- package/dist/src/Functions/Loader/top.d.ts +1 -0
- package/dist/src/Functions/Sheet/parts.d.ts +2 -0
- package/dist/src/Functions/SnackBar/parts.d.ts +2 -0
- package/dist/src/Functions/Table/Data/parts.d.ts +3 -0
- package/dist/src/Functions/Table/Drag/parts.d.ts +1 -0
- package/dist/src/Functions/Table/Normal/parts.d.ts +1 -0
- package/dist/src/Functions/Table/_.d.ts +9 -0
- package/dist/src/Functions/Tooltips/parts.d.ts +2 -0
- package/dist/src/Global/@export.d.ts +12 -0
- package/dist/src/Global/LaunchReactApplication.d.ts +1 -0
- package/dist/src/Global/styleConverter.d.ts +2 -0
- package/dist/src/Molecules/@export.d.ts +21 -0
- package/dist/src/Molecules/Accordion/parts.d.ts +2 -0
- package/dist/src/Molecules/LinkifyText/parts.d.ts +1 -0
- package/dist/src/Molecules/List.d.ts +1 -0
- package/dist/src/Organisms/@export.d.ts +2 -0
- package/dist/src/Organisms/DisplayStyleInput/_.d.ts +1 -0
- package/dist/src/Organisms/DisplayStyleInput/darkmode.d.ts +1 -0
- package/dist/src/Organisms/DisplayStyleInput/themeColor.d.ts +27 -0
- package/dist/src/Templates/@export.d.ts +2 -0
- package/dist/src/Templates/PlayGround/parts.d.ts +1 -0
- package/dist/src/config.d.ts +16 -0
- package/dist/src/launch.d.ts +9 -0
- package/dist/src/preload.d.ts +1 -0
- package/package.json +2 -2
- package/src/@jsminAmotifyExtension/_.tsx +4 -0
- package/src/@jsminAmotifyExtension/fetch.tsx +107 -0
- package/src/@jsminAmotifyExtension/formCollect.tsx +89 -0
- package/src/@jsminAmotifyExtension/spreadSheet.tsx +159 -0
- package/src/@jsminAmotifyExtension/variables.tsx +130 -0
- package/src/@styles/@app.scss +4 -0
- package/src/@styles/@variables/customProps.scss +109 -0
- package/src/@styles/@variables/styleSet.scss +38 -0
- package/src/@styles/@variables/themeColor.scss +71 -0
- package/src/@styles/@variables/var.scss +171 -0
- package/src/@styles/UniStyling.scss +996 -0
- package/src/@styles/init.scss +154 -0
- package/src/@types/_.tsx +6 -0
- package/src/@types/amot.tsx +323 -0
- package/src/@types/fn.tsx +1210 -0
- package/src/@types/index.tsx +74 -0
- package/src/@types/jsminAmotifyExtension.tsx +143 -0
- package/src/@types/module.tsx +2 -0
- package/src/@types/state.tsx +199 -0
- package/src/Atoms/@export.tsx +32 -0
- package/src/Atoms/FAIcon/parts.tsx +117 -0
- package/src/Atoms/FAIcon/style.module.scss +9 -0
- package/src/Atoms/Logo/parts.tsx +335 -0
- package/src/Atoms/Logo/style.module.scss +96 -0
- package/src/Atoms/Various/parts.tsx +157 -0
- package/src/Atoms/Various/style.module.scss +40 -0
- package/src/Functions/@export.tsx +29 -0
- package/src/Functions/Button/_.tsx +305 -0
- package/src/Functions/Button/style.module.scss +183 -0
- package/src/Functions/Cropper/parts.tsx +1061 -0
- package/src/Functions/Cropper/style.module.scss +62 -0
- package/src/Functions/Effects/Fade.tsx +81 -0
- package/src/Functions/Effects/Ripple.tsx +141 -0
- package/src/Functions/Effects/_.tsx +33 -0
- package/src/Functions/Effects/style.module.scss +83 -0
- package/src/Functions/Input/Chips/Selector.tsx +451 -0
- package/src/Functions/Input/Chips/_.tsx +286 -0
- package/src/Functions/Input/Chips/style.module.scss +6 -0
- package/src/Functions/Input/DigitCharacters.tsx +241 -0
- package/src/Functions/Input/File/_.tsx +596 -0
- package/src/Functions/Input/File/style.module.scss +34 -0
- package/src/Functions/Input/Hidden.tsx +18 -0
- package/src/Functions/Input/List/_.tsx +383 -0
- package/src/Functions/Input/List/style.module.scss +84 -0
- package/src/Functions/Input/Segmented/_.tsx +238 -0
- package/src/Functions/Input/Segmented/style.module.scss +81 -0
- package/src/Functions/Input/Select/_.tsx +225 -0
- package/src/Functions/Input/Select/style.module.scss +10 -0
- package/src/Functions/Input/Slider/_.tsx +519 -0
- package/src/Functions/Input/Slider/style.module.scss +67 -0
- package/src/Functions/Input/Switch/_.tsx +177 -0
- package/src/Functions/Input/Switch/style.module.scss +18 -0
- package/src/Functions/Input/Text.tsx +437 -0
- package/src/Functions/Input/TextArea.tsx +115 -0
- package/src/Functions/Input/Time/Picker.tsx +950 -0
- package/src/Functions/Input/Time/_.tsx +736 -0
- package/src/Functions/Input/Time/style.module.scss +72 -0
- package/src/Functions/Input/_.tsx +793 -0
- package/src/Functions/Input/core.tsx +461 -0
- package/src/Functions/Input/style.module.scss +43 -0
- package/src/Functions/Inputs/_.tsx +5 -0
- package/src/Functions/Inputs/style.module.scss +15 -0
- package/src/Functions/Inputs/text.tsx +67 -0
- package/src/Functions/Inputs/types.d.ts +1 -0
- package/src/Functions/Layout/PageNotFound.tsx +81 -0
- package/src/Functions/Layout/PageRouter.tsx +107 -0
- package/src/Functions/Layout/PageViewController/parts.tsx +32 -0
- package/src/Functions/Layout/Plate.tsx +30 -0
- package/src/Functions/Layout/RootViewController/parts.tsx +290 -0
- package/src/Functions/Layout/RootViewController/style.module.scss +24 -0
- package/src/Functions/Layout/SwipeView/parts.tsx +380 -0
- package/src/Functions/Layout/SwipeView/style.module.scss +19 -0
- package/src/Functions/Layout/TabBar.tsx +64 -0
- package/src/Functions/Layout/_.tsx +20 -0
- package/src/Functions/Loader/corner.tsx +78 -0
- package/src/Functions/Loader/mini.tsx +117 -0
- package/src/Functions/Loader/parts.tsx +105 -0
- package/src/Functions/Loader/style.module.scss +222 -0
- package/src/Functions/Loader/top.tsx +90 -0
- package/src/Functions/Sheet/parts.tsx +972 -0
- package/src/Functions/Sheet/style.module.scss +235 -0
- package/src/Functions/SnackBar/parts.tsx +215 -0
- package/src/Functions/SnackBar/style.module.scss +25 -0
- package/src/Functions/Table/Data/parts.tsx +955 -0
- package/src/Functions/Table/Drag/parts.tsx +448 -0
- package/src/Functions/Table/Normal/parts.tsx +123 -0
- package/src/Functions/Table/_.tsx +170 -0
- package/src/Functions/Table/style.module.scss +92 -0
- package/src/Functions/Tooltips/parts.tsx +52 -0
- package/src/Global/@export.tsx +138 -0
- package/src/Global/LaunchReactApplication.tsx +30 -0
- package/src/Global/exe.tsx +0 -0
- package/src/Global/styleConverter.tsx +435 -0
- package/src/Molecules/@export.tsx +95 -0
- package/src/Molecules/Accordion/parts.tsx +146 -0
- package/src/Molecules/Accordion/style.module.scss +13 -0
- package/src/Molecules/LinkifyText/parts.tsx +54 -0
- package/src/Molecules/List.tsx +30 -0
- package/src/Organisms/@export.tsx +5 -0
- package/src/Organisms/DisplayStyleInput/_.tsx +18 -0
- package/src/Organisms/DisplayStyleInput/darkmode.tsx +112 -0
- package/src/Organisms/DisplayStyleInput/themeColor.tsx +210 -0
- package/src/Templates/@export.tsx +7 -0
- package/src/Templates/PlayGround/parts.tsx +115 -0
- package/src/Templates/PlayGround/style.module.scss +38 -0
- package/src/config.tsx +132 -0
- package/src/launch.tsx +100 -0
- package/src/preload.tsx +49 -0
- package/tsconfig.json +27 -14
|
@@ -0,0 +1,1061 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useStore
|
|
3
|
+
} from '@global';
|
|
4
|
+
import {
|
|
5
|
+
Box,
|
|
6
|
+
Flex,
|
|
7
|
+
FAIcon
|
|
8
|
+
} from '@atoms';
|
|
9
|
+
import {
|
|
10
|
+
Column,
|
|
11
|
+
Row,
|
|
12
|
+
Text
|
|
13
|
+
} from '@mols';
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
Buttons,
|
|
17
|
+
Input,
|
|
18
|
+
Sheet,
|
|
19
|
+
Loader
|
|
20
|
+
} from '@functions';
|
|
21
|
+
|
|
22
|
+
const {
|
|
23
|
+
useState,
|
|
24
|
+
useEffect,
|
|
25
|
+
} = React;
|
|
26
|
+
|
|
27
|
+
import style from './style.module.scss';
|
|
28
|
+
|
|
29
|
+
type CoreProps = {
|
|
30
|
+
val_file: amotify.fn.Input.Filer.CustomFile
|
|
31
|
+
options: amotify.fn.Cropper.Params
|
|
32
|
+
finishedCallback( files: amotify.fn.Input.Filer.CustomFile[] ): void
|
|
33
|
+
abortCallback(): void
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
class CroppImage {
|
|
37
|
+
set_scale: React.Dispatch<React.SetStateAction<number>>
|
|
38
|
+
val_file: File
|
|
39
|
+
develops: amotify.fn.Cropper.DevelopParams[]
|
|
40
|
+
|
|
41
|
+
use: 'profile' | 'header'
|
|
42
|
+
componentID: string
|
|
43
|
+
Canvas: {
|
|
44
|
+
elm: HTMLCanvasElement
|
|
45
|
+
ctx: CanvasRenderingContext2D
|
|
46
|
+
}
|
|
47
|
+
Picture: {
|
|
48
|
+
elm: HTMLImageElement
|
|
49
|
+
aspect: number
|
|
50
|
+
originDataUrl: string
|
|
51
|
+
revisedAspect: number
|
|
52
|
+
rotate: number
|
|
53
|
+
grayScale: number
|
|
54
|
+
tone: number
|
|
55
|
+
}
|
|
56
|
+
scale: {
|
|
57
|
+
current: number
|
|
58
|
+
default: number
|
|
59
|
+
min: number,max: number
|
|
60
|
+
}
|
|
61
|
+
pst: {
|
|
62
|
+
frame: {
|
|
63
|
+
x: number,y: number,w: number,h: number,aspect: number
|
|
64
|
+
}
|
|
65
|
+
outImage: {
|
|
66
|
+
x: number,y: number,w: number,h: number
|
|
67
|
+
}
|
|
68
|
+
imageX: number,imageY: number
|
|
69
|
+
centerX: number,centerY: number
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
dragEffectInfo: {
|
|
73
|
+
origin: { x: number,y: number }
|
|
74
|
+
frameExpandRate: { x: number,y: number }
|
|
75
|
+
}
|
|
76
|
+
pinchEffectInfo: {
|
|
77
|
+
origin: {
|
|
78
|
+
x: number,
|
|
79
|
+
y: number,
|
|
80
|
+
scale: number
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
constructor( params: {
|
|
85
|
+
set_scale: React.Dispatch<React.SetStateAction<number>>
|
|
86
|
+
val_file: File
|
|
87
|
+
develops: amotify.fn.Cropper.DevelopParams[]
|
|
88
|
+
scale: {
|
|
89
|
+
default: number
|
|
90
|
+
min: number
|
|
91
|
+
max: number
|
|
92
|
+
}
|
|
93
|
+
picture: {
|
|
94
|
+
image: HTMLImageElement
|
|
95
|
+
grayScale: number
|
|
96
|
+
tone: number
|
|
97
|
+
rotate: number
|
|
98
|
+
}
|
|
99
|
+
use: 'profile' | 'header'
|
|
100
|
+
componentID: string
|
|
101
|
+
canvas: HTMLCanvasElement
|
|
102
|
+
} ) {
|
|
103
|
+
this.set_scale = params.set_scale;
|
|
104
|
+
this.val_file = params.val_file;
|
|
105
|
+
this.develops = params.develops;
|
|
106
|
+
|
|
107
|
+
this.use = params.use;
|
|
108
|
+
this.componentID = params.componentID;
|
|
109
|
+
|
|
110
|
+
this.scale = {
|
|
111
|
+
current: params.scale.default,
|
|
112
|
+
default: params.scale.default,
|
|
113
|
+
min: params.scale.min,
|
|
114
|
+
max: params.scale.max
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
let Canvas = params.canvas;
|
|
118
|
+
let {
|
|
119
|
+
width: cvsW,
|
|
120
|
+
height: cvsH
|
|
121
|
+
} = Canvas;
|
|
122
|
+
|
|
123
|
+
let Picture = params.picture.image;
|
|
124
|
+
let {
|
|
125
|
+
width: pictW,
|
|
126
|
+
height: pictH
|
|
127
|
+
} = Picture;
|
|
128
|
+
let pictAsp = pictW / pictH;
|
|
129
|
+
|
|
130
|
+
this.Canvas = {
|
|
131
|
+
elm: Canvas,
|
|
132
|
+
ctx: Canvas.getContext( '2d' )!
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let frameW = 0,frameH = 0;
|
|
136
|
+
if ( this.use == 'profile' ) {
|
|
137
|
+
frameW = Canvas.width / 3 * 2;
|
|
138
|
+
frameH = Canvas.height / 3 * 2;
|
|
139
|
+
} else if ( this.use == 'header' ) {
|
|
140
|
+
frameW = Canvas.width * ( 7 / 9 );
|
|
141
|
+
frameH = frameW / 3;
|
|
142
|
+
}
|
|
143
|
+
let frameX = ( Canvas.width - frameW ) / 2;
|
|
144
|
+
let frameY = ( Canvas.height - frameH ) / 2;
|
|
145
|
+
let frameAsp = frameW / frameH;
|
|
146
|
+
|
|
147
|
+
this.Picture = {
|
|
148
|
+
elm: Picture,
|
|
149
|
+
originDataUrl: Picture.src,
|
|
150
|
+
aspect: pictAsp,
|
|
151
|
+
revisedAspect: frameAsp > pictAsp
|
|
152
|
+
? frameW / pictW
|
|
153
|
+
: frameH / pictH,
|
|
154
|
+
rotate: params.picture.rotate,
|
|
155
|
+
grayScale: params.picture.grayScale,
|
|
156
|
+
tone: params.picture.tone
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
this.pst = {
|
|
160
|
+
frame: {
|
|
161
|
+
x: frameX,
|
|
162
|
+
y: frameY,
|
|
163
|
+
w: frameW,
|
|
164
|
+
h: frameH,
|
|
165
|
+
aspect: frameAsp,
|
|
166
|
+
},
|
|
167
|
+
outImage: { x: 0,y: 0,w: 0,h: 0 },
|
|
168
|
+
imageX: pictW / 2,
|
|
169
|
+
imageY: pictH / 2,
|
|
170
|
+
centerX: cvsW / 2,
|
|
171
|
+
centerY: cvsH / 2
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
this.dragEffectInfo = {
|
|
176
|
+
origin: { x: 0,y: 0 },
|
|
177
|
+
frameExpandRate: { x: 0,y: 0 }
|
|
178
|
+
}
|
|
179
|
+
this.pinchEffectInfo = {
|
|
180
|
+
origin: {
|
|
181
|
+
x: 0,y: 0,
|
|
182
|
+
scale: this.scale.current
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
this.modifyImage();
|
|
186
|
+
}
|
|
187
|
+
dragEffect( params: {
|
|
188
|
+
eventType: 'start' | 'move' | 'end'
|
|
189
|
+
x: number
|
|
190
|
+
y: number
|
|
191
|
+
} ) {
|
|
192
|
+
let {
|
|
193
|
+
eventType,x,y
|
|
194
|
+
} = params;
|
|
195
|
+
|
|
196
|
+
if ( eventType == 'start' ) {
|
|
197
|
+
let CanvasRect = this.Canvas.elm.position();
|
|
198
|
+
this.dragEffectInfo = {
|
|
199
|
+
origin: { x,y },
|
|
200
|
+
frameExpandRate: {
|
|
201
|
+
x: this.Canvas.elm.width / CanvasRect.width,
|
|
202
|
+
y: this.Canvas.elm.height / CanvasRect.height
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
} else {
|
|
206
|
+
let {
|
|
207
|
+
origin,
|
|
208
|
+
frameExpandRate
|
|
209
|
+
} = this.dragEffectInfo;
|
|
210
|
+
let dragX = origin.x - x;
|
|
211
|
+
let dragY = origin.y - y;
|
|
212
|
+
|
|
213
|
+
let scale = this.scale.current * this.Picture.revisedAspect / 100;
|
|
214
|
+
|
|
215
|
+
let shiftX = dragX / scale * frameExpandRate.x;
|
|
216
|
+
let shiftY = dragY / scale * frameExpandRate.y;
|
|
217
|
+
|
|
218
|
+
if ( eventType == 'move' ) {
|
|
219
|
+
this.drawImage(
|
|
220
|
+
this.pst.imageX + shiftX,
|
|
221
|
+
this.pst.imageY + shiftY,
|
|
222
|
+
);
|
|
223
|
+
} else if ( eventType == 'end' ) {
|
|
224
|
+
this.drawImage(
|
|
225
|
+
this.pst.imageX += shiftX,
|
|
226
|
+
this.pst.imageY += shiftY
|
|
227
|
+
)
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
pinchEffect( params: {
|
|
232
|
+
eventType: 'start' | 'move'
|
|
233
|
+
event: any
|
|
234
|
+
} ) {
|
|
235
|
+
let {
|
|
236
|
+
eventType,
|
|
237
|
+
event
|
|
238
|
+
} = params;
|
|
239
|
+
let { x: x1,y: y1 } = $.getCursor( event.touches[ 0 ] );
|
|
240
|
+
let { x: x2,y: y2 } = $.getCursor( event.touches[ 1 ] );
|
|
241
|
+
|
|
242
|
+
let marginX = x2 - x1;
|
|
243
|
+
let marginY = y2 - y1;
|
|
244
|
+
if ( eventType == 'start' ) {
|
|
245
|
+
|
|
246
|
+
this.pinchEffectInfo.origin = {
|
|
247
|
+
x: marginX,y: marginY,
|
|
248
|
+
scale: this.scale.current
|
|
249
|
+
}
|
|
250
|
+
} else if ( eventType == 'move' ) {
|
|
251
|
+
let {
|
|
252
|
+
origin
|
|
253
|
+
} = this.pinchEffectInfo;
|
|
254
|
+
|
|
255
|
+
let originDist = Math.sqrt( Math.pow( origin.x,2 ) + Math.pow( origin.y,2 ) );
|
|
256
|
+
let dist = Math.sqrt( Math.pow( marginX,2 ) + Math.pow( marginY,2 ) );
|
|
257
|
+
let margin = dist / originDist;
|
|
258
|
+
|
|
259
|
+
let scale = Number( origin.scale * margin );
|
|
260
|
+
this.set_scale( scale );
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
updateScale( scale: number ) {
|
|
265
|
+
let nextValue = scale;
|
|
266
|
+
nextValue = Math.max( nextValue,this.scale.min );
|
|
267
|
+
nextValue = Math.min( nextValue,this.scale.max );
|
|
268
|
+
|
|
269
|
+
this.scale.current = nextValue;
|
|
270
|
+
this.drawImage();
|
|
271
|
+
}
|
|
272
|
+
updateFilter( params: {
|
|
273
|
+
grayScale: number
|
|
274
|
+
tone: number
|
|
275
|
+
rotate: number
|
|
276
|
+
} ) {
|
|
277
|
+
this.Picture.grayScale = params.grayScale;
|
|
278
|
+
this.Picture.tone = params.tone;
|
|
279
|
+
this.Picture.rotate = params.rotate;
|
|
280
|
+
this.modifyImage();
|
|
281
|
+
}
|
|
282
|
+
async modifyImage() {
|
|
283
|
+
let {
|
|
284
|
+
grayScale,
|
|
285
|
+
tone,
|
|
286
|
+
rotate
|
|
287
|
+
} = this.Picture;
|
|
288
|
+
|
|
289
|
+
const canvas = document.createElement( 'canvas' );
|
|
290
|
+
let ctx = canvas.getContext( '2d' )!;
|
|
291
|
+
let image = new Image();
|
|
292
|
+
image.src = this.Picture.originDataUrl;
|
|
293
|
+
let ImageW = image.width;
|
|
294
|
+
let ImageH = image.height;
|
|
295
|
+
|
|
296
|
+
if ( rotate == 90 || rotate == 270 ) {
|
|
297
|
+
ImageW = image.height;
|
|
298
|
+
ImageH = image.width;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
canvas.width = ImageW;
|
|
302
|
+
canvas.height = ImageH;
|
|
303
|
+
|
|
304
|
+
if ( grayScale ) ctx.filter = 'grayscale(' + grayScale + '%)';
|
|
305
|
+
|
|
306
|
+
if ( rotate ) {
|
|
307
|
+
ctx.translate( ImageW / 2,ImageH / 2 );
|
|
308
|
+
ctx.rotate( rotate * Math.PI / 180 );
|
|
309
|
+
if ( [ 90,270 ].includes( rotate ) ) {
|
|
310
|
+
ctx.translate( -ImageH / 2,-ImageW / 2 );
|
|
311
|
+
} else {
|
|
312
|
+
ctx.translate( -ImageW / 2,-ImageH / 2 );
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
ctx.drawImage( image,0,0,image.width,image.height );
|
|
317
|
+
let newImage = ctx.getImageData( 0,0,canvas.width,canvas.height );
|
|
318
|
+
let imgData = newImage.data;
|
|
319
|
+
|
|
320
|
+
{
|
|
321
|
+
grayScale /= 100;
|
|
322
|
+
|
|
323
|
+
let ColorDir = [
|
|
324
|
+
[ 255,255,255 ], // Original
|
|
325
|
+
[ 255,200,100 ], // Warm
|
|
326
|
+
[ 170,170,255 ], // Cold
|
|
327
|
+
[ 240,200,145 ], // Sepia
|
|
328
|
+
[ 128,255,255 ], // Cyan
|
|
329
|
+
[ 255,128,255 ], // Magenta
|
|
330
|
+
[ 255,255,128 ], // Yellow
|
|
331
|
+
[ 128,158,169 ], // Origin1
|
|
332
|
+
[ 128,112,162 ], // Origin2
|
|
333
|
+
[ 50,192,87 ], // Origin3
|
|
334
|
+
[ 246,100,140 ], // Origin4
|
|
335
|
+
][ tone ];
|
|
336
|
+
let rCorrect = ColorDir[ 0 ] / 255;
|
|
337
|
+
let gCorrect = ColorDir[ 1 ] / 255;
|
|
338
|
+
let bCorrect = ColorDir[ 2 ] / 255;
|
|
339
|
+
|
|
340
|
+
for ( let iH = 0; iH < ImageH; iH++ ) {
|
|
341
|
+
for ( let iW = 0; iW < ImageW; iW++ ) {
|
|
342
|
+
var Index = ( iH * ImageW + iW ) * 4;
|
|
343
|
+
|
|
344
|
+
if ( grayScale ) {
|
|
345
|
+
let terminal = 0.3 * imgData[ Index ] + 0.59 * imgData[ Index + 1 ] + 0.11 * imgData[ Index + 2 ];
|
|
346
|
+
for ( var k = 0; k < 3; k++ ) {
|
|
347
|
+
let current = imgData[ Index + k ];
|
|
348
|
+
imgData[ Index + k ] = current + ( terminal - current ) * grayScale;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
imgData[ Index ] *= rCorrect;
|
|
353
|
+
imgData[ Index + 1 ] *= gCorrect;
|
|
354
|
+
imgData[ Index + 2 ] *= bCorrect;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
ctx.putImageData( newImage,0,0 );
|
|
360
|
+
|
|
361
|
+
let newDataUrl = canvas.toDataURL( 'image/jpeg' );
|
|
362
|
+
|
|
363
|
+
{
|
|
364
|
+
let Picture = await $.ImageLoader( newDataUrl );
|
|
365
|
+
let {
|
|
366
|
+
width: pictW,
|
|
367
|
+
height: pictH
|
|
368
|
+
} = Picture;
|
|
369
|
+
let pictAsp = pictW / pictH;
|
|
370
|
+
|
|
371
|
+
this.Picture = {
|
|
372
|
+
...this.Picture,
|
|
373
|
+
elm: Picture,
|
|
374
|
+
aspect: pictAsp,
|
|
375
|
+
revisedAspect: this.pst.frame.aspect > pictAsp
|
|
376
|
+
? this.pst.frame.w / pictW
|
|
377
|
+
: this.pst.frame.h / pictH
|
|
378
|
+
}
|
|
379
|
+
// this.pst.imageX = pictW / 2;
|
|
380
|
+
// this.pst.imageY = pictH / 2;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
this.drawImage();
|
|
384
|
+
}
|
|
385
|
+
drawImage( _imageX?: number,_imageY?: number ) {
|
|
386
|
+
let {
|
|
387
|
+
use,
|
|
388
|
+
Canvas: {
|
|
389
|
+
ctx
|
|
390
|
+
},
|
|
391
|
+
pst: {
|
|
392
|
+
frame
|
|
393
|
+
}
|
|
394
|
+
} = this;
|
|
395
|
+
|
|
396
|
+
let ImageX = _imageX || this.pst.imageX;
|
|
397
|
+
let ImageY = _imageY || this.pst.imageY;
|
|
398
|
+
|
|
399
|
+
{
|
|
400
|
+
let scale = this.scale.current / 100;
|
|
401
|
+
|
|
402
|
+
let totalScale = this.Picture.revisedAspect * scale;
|
|
403
|
+
|
|
404
|
+
let imgX = this.pst.centerX - ImageX * totalScale;
|
|
405
|
+
let imgY = this.pst.centerY - ImageY * totalScale;
|
|
406
|
+
let imgW = this.Picture.elm.width * totalScale;
|
|
407
|
+
let imgH = this.Picture.elm.height * totalScale;
|
|
408
|
+
|
|
409
|
+
{
|
|
410
|
+
let minX = this.pst.frame.x + this.pst.frame.w - imgW;
|
|
411
|
+
let maxX = this.pst.frame.x;
|
|
412
|
+
let minY = this.pst.frame.y + this.pst.frame.h - imgH;
|
|
413
|
+
let maxY = this.pst.frame.y;
|
|
414
|
+
|
|
415
|
+
let extraX = 0;
|
|
416
|
+
if ( imgX < minX ) extraX = imgX - minX;
|
|
417
|
+
if ( imgX > maxX ) extraX = imgX - maxX;
|
|
418
|
+
|
|
419
|
+
let extraY = 0;
|
|
420
|
+
if ( imgY < minY ) extraY = imgY - minY;
|
|
421
|
+
if ( imgY > maxY ) extraY = imgY - maxY;
|
|
422
|
+
|
|
423
|
+
this.dragEffectInfo.origin.x += extraX / 2 / this.dragEffectInfo.frameExpandRate.x;
|
|
424
|
+
this.dragEffectInfo.origin.y += extraY / 2 / this.dragEffectInfo.frameExpandRate.y;
|
|
425
|
+
|
|
426
|
+
imgX = Math.min( Math.max( imgX,minX ),maxX );
|
|
427
|
+
imgY = Math.min( Math.max( imgY,minY ),maxY );
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
this.pst.outImage = {
|
|
431
|
+
x: imgX,y: imgY,
|
|
432
|
+
w: imgW,h: imgH
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
ctx.clearRect(
|
|
436
|
+
0,
|
|
437
|
+
0,
|
|
438
|
+
this.Canvas.elm.width,
|
|
439
|
+
this.Canvas.elm.height
|
|
440
|
+
);
|
|
441
|
+
|
|
442
|
+
ctx.drawImage(
|
|
443
|
+
this.Picture.elm,
|
|
444
|
+
0,0,this.Picture.elm.width,this.Picture.elm.height,
|
|
445
|
+
|
|
446
|
+
imgX,
|
|
447
|
+
imgY,
|
|
448
|
+
imgW,
|
|
449
|
+
imgH
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
{
|
|
454
|
+
if ( use == 'profile' ) {
|
|
455
|
+
ctx.fillStyle = 'rgba( 20,24,20,.3 )';
|
|
456
|
+
ctx.beginPath();
|
|
457
|
+
ctx.arc( this.Canvas.elm.width / 2,this.Canvas.elm.height / 2,this.Canvas.elm.width,0,Math.PI * 2,true );
|
|
458
|
+
ctx.arc( this.Canvas.elm.width / 2,this.Canvas.elm.height / 2,this.Canvas.elm.width / 3 * 2 / 2,0,Math.PI * 2,false );
|
|
459
|
+
ctx.closePath();
|
|
460
|
+
ctx.fill();
|
|
461
|
+
} else if ( use == 'header' ) {
|
|
462
|
+
ctx.fillStyle = 'rgba( 20,24,20,.3 )';
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
ctx.beginPath();
|
|
466
|
+
ctx.moveTo( 0,0 );
|
|
467
|
+
ctx.lineTo( this.Canvas.elm.width,0 );
|
|
468
|
+
ctx.lineTo( this.Canvas.elm.width,this.Canvas.elm.height );
|
|
469
|
+
ctx.lineTo( 0,this.Canvas.elm.height );
|
|
470
|
+
ctx.lineTo( 0,0 );
|
|
471
|
+
ctx.closePath();
|
|
472
|
+
|
|
473
|
+
ctx.lineTo( frame.x,frame.y );
|
|
474
|
+
ctx.lineTo( frame.x,frame.y + frame.h );
|
|
475
|
+
ctx.lineTo( frame.x + frame.w,frame.y + frame.h );
|
|
476
|
+
ctx.lineTo( frame.x + frame.w,frame.y );
|
|
477
|
+
ctx.lineTo( frame.x,frame.y );
|
|
478
|
+
ctx.fill();
|
|
479
|
+
|
|
480
|
+
let body = $( document.body );
|
|
481
|
+
let themeColorHSL = body.getStyleProperty( '--color-theme-hsl' );
|
|
482
|
+
ctx.lineWidth = this.Canvas.elm.width / 200;
|
|
483
|
+
ctx.strokeStyle = `hsla( ${ themeColorHSL },1 )`;
|
|
484
|
+
ctx.strokeRect( frame.x,frame.y,frame.w,frame.h );
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
async export() {
|
|
488
|
+
let {
|
|
489
|
+
develops,
|
|
490
|
+
Picture,
|
|
491
|
+
pst: {
|
|
492
|
+
outImage,
|
|
493
|
+
frame
|
|
494
|
+
}
|
|
495
|
+
} = this;
|
|
496
|
+
|
|
497
|
+
let ratioX = outImage.w / Picture.elm.width;
|
|
498
|
+
let ratioY = outImage.h / Picture.elm.height;
|
|
499
|
+
|
|
500
|
+
let Left = ( frame.x - outImage.x ) / ratioX;
|
|
501
|
+
let Right = ( frame.x - outImage.x + frame.w ) / ratioX;
|
|
502
|
+
|
|
503
|
+
let Top = ( frame.y - outImage.y ) / ratioY;
|
|
504
|
+
let Bottom = ( frame.y - outImage.y + frame.h ) / ratioY;
|
|
505
|
+
|
|
506
|
+
let Files: any = Array.from( { length: develops.length } );
|
|
507
|
+
|
|
508
|
+
let MimeType = 'image/jpeg';
|
|
509
|
+
|
|
510
|
+
for ( let index = 0; index < develops.length; index++ ) {
|
|
511
|
+
let {
|
|
512
|
+
size,maxSize
|
|
513
|
+
} = develops[ index ];
|
|
514
|
+
|
|
515
|
+
maxSize = maxSize || {
|
|
516
|
+
S: 1024 * 20,
|
|
517
|
+
R: 1024 * 100,
|
|
518
|
+
L: 1024 * 350
|
|
519
|
+
}[ size ];
|
|
520
|
+
|
|
521
|
+
let width = {
|
|
522
|
+
S: 144,
|
|
523
|
+
R: 576,
|
|
524
|
+
L: 1152
|
|
525
|
+
}[ size ];
|
|
526
|
+
|
|
527
|
+
let height = this.use == 'profile' ? width : width / 3;
|
|
528
|
+
|
|
529
|
+
let Preview = document.createElement( 'canvas' );
|
|
530
|
+
Preview.width = width;
|
|
531
|
+
Preview.height = height;
|
|
532
|
+
|
|
533
|
+
let previewCtx = Preview.getContext( '2d' );
|
|
534
|
+
if ( !previewCtx ) return;
|
|
535
|
+
|
|
536
|
+
previewCtx.clearRect( 0,0,width,height );
|
|
537
|
+
previewCtx.drawImage(
|
|
538
|
+
this.Picture.elm,
|
|
539
|
+
Left,
|
|
540
|
+
Top,
|
|
541
|
+
Right - Left,
|
|
542
|
+
Bottom - Top,
|
|
543
|
+
0,0,
|
|
544
|
+
width,
|
|
545
|
+
height
|
|
546
|
+
);
|
|
547
|
+
|
|
548
|
+
let dataUrl = Preview.toDataURL( MimeType );
|
|
549
|
+
let blob = await dataUrl.toBlob( MimeType );
|
|
550
|
+
if ( !blob ) return;
|
|
551
|
+
|
|
552
|
+
if ( blob.size >= maxSize ) {
|
|
553
|
+
let Ratio = maxSize / blob.size;
|
|
554
|
+
dataUrl = Preview.toDataURL( MimeType,Ratio * 0.92 );
|
|
555
|
+
blob = await dataUrl.toBlob( MimeType );
|
|
556
|
+
if ( !blob ) return;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
let file = new File( [ blob ],this.val_file.name,{ type: MimeType } );
|
|
560
|
+
|
|
561
|
+
Files[ index ] = file;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
return Files;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
const Comps: {
|
|
569
|
+
Core: FNC<CoreProps>
|
|
570
|
+
SettingRegion: FNC<{
|
|
571
|
+
DefaultOptions: plainObject
|
|
572
|
+
val_scale: number
|
|
573
|
+
set_scale: React.Dispatch<React.SetStateAction<number>>
|
|
574
|
+
val_tone: number
|
|
575
|
+
set_tone: React.Dispatch<React.SetStateAction<number>>
|
|
576
|
+
val_grayScale: number
|
|
577
|
+
set_grayScale: React.Dispatch<React.SetStateAction<number>>
|
|
578
|
+
val_rotate: number
|
|
579
|
+
set_rotate: React.Dispatch<React.SetStateAction<number>>
|
|
580
|
+
}>
|
|
581
|
+
} = {
|
|
582
|
+
Core: ( params ) => {
|
|
583
|
+
let {
|
|
584
|
+
val_file,
|
|
585
|
+
options,
|
|
586
|
+
finishedCallback,
|
|
587
|
+
abortCallback,
|
|
588
|
+
} = params;
|
|
589
|
+
let {
|
|
590
|
+
use,
|
|
591
|
+
develops = []
|
|
592
|
+
} = options;
|
|
593
|
+
|
|
594
|
+
let [ val_componentID ] = useState( $.uuidGen( 32 ) );
|
|
595
|
+
|
|
596
|
+
const DefaultOptions = {
|
|
597
|
+
scale: {
|
|
598
|
+
default: 125,
|
|
599
|
+
min: 100,
|
|
600
|
+
max: 300
|
|
601
|
+
},
|
|
602
|
+
rotate: 0,
|
|
603
|
+
grayScale: 0,
|
|
604
|
+
tone: 0
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
let [ val_scale,set_scale ] = useState( DefaultOptions.scale.default );
|
|
608
|
+
let [ val_rotate,set_rotate ] = useState( DefaultOptions.rotate )
|
|
609
|
+
let [ val_grayScale,set_grayScale ] = useState( DefaultOptions.grayScale );
|
|
610
|
+
let [ val_tone,set_tone ] = useState( DefaultOptions.tone );
|
|
611
|
+
|
|
612
|
+
useEffect( () => {
|
|
613
|
+
useStore.set( {
|
|
614
|
+
key: val_componentID,
|
|
615
|
+
value: {}
|
|
616
|
+
} );
|
|
617
|
+
|
|
618
|
+
( async () => {
|
|
619
|
+
amotify.fn.Loader.fn.corner.active();
|
|
620
|
+
|
|
621
|
+
let { target } = await val_file.read();
|
|
622
|
+
if ( !target ) return;
|
|
623
|
+
let dataUrl = target!.result as string;
|
|
624
|
+
|
|
625
|
+
let Canvas = $( '#Canvas-' + val_componentID )[ 0 ] as HTMLCanvasElement;
|
|
626
|
+
if ( !Canvas ) return;
|
|
627
|
+
|
|
628
|
+
let __Cropper = new CroppImage( {
|
|
629
|
+
set_scale,
|
|
630
|
+
val_file,
|
|
631
|
+
develops,
|
|
632
|
+
use: use,
|
|
633
|
+
scale: DefaultOptions.scale,
|
|
634
|
+
componentID: val_componentID,
|
|
635
|
+
canvas: Canvas,
|
|
636
|
+
picture: {
|
|
637
|
+
image: await $.ImageLoader( dataUrl ),
|
|
638
|
+
grayScale: DefaultOptions.grayScale,
|
|
639
|
+
tone: DefaultOptions.tone,
|
|
640
|
+
rotate: DefaultOptions.rotate
|
|
641
|
+
}
|
|
642
|
+
} );
|
|
643
|
+
useStore.set( {
|
|
644
|
+
key: val_componentID,
|
|
645
|
+
value: {
|
|
646
|
+
Instance: __Cropper
|
|
647
|
+
}
|
|
648
|
+
} );
|
|
649
|
+
|
|
650
|
+
const UserEffectStart = function ( event: any ) {
|
|
651
|
+
event.preventDefault();
|
|
652
|
+
|
|
653
|
+
if ( event.touches && event.touches.length > 1 ) {
|
|
654
|
+
__Cropper.pinchEffect( {
|
|
655
|
+
eventType: 'start',
|
|
656
|
+
event
|
|
657
|
+
} );
|
|
658
|
+
|
|
659
|
+
$( document )
|
|
660
|
+
.addEvent( {
|
|
661
|
+
eventType: 'touchmove',eventID: 'CropperEffectMove',option: { passive: false },
|
|
662
|
+
callback: ( event ) => {
|
|
663
|
+
event.preventDefault();
|
|
664
|
+
__Cropper.pinchEffect( {
|
|
665
|
+
eventType: 'move',
|
|
666
|
+
event
|
|
667
|
+
} );
|
|
668
|
+
},
|
|
669
|
+
} )
|
|
670
|
+
.addEvent( {
|
|
671
|
+
eventType: 'touchend',eventID: 'CropperEffectEnd',option: { passive: false },
|
|
672
|
+
callback: EventEnd,
|
|
673
|
+
} )
|
|
674
|
+
} else {
|
|
675
|
+
__Cropper.dragEffect( {
|
|
676
|
+
eventType: 'start',
|
|
677
|
+
...$.getCursor( event )
|
|
678
|
+
} );
|
|
679
|
+
|
|
680
|
+
let { type } = event;
|
|
681
|
+
|
|
682
|
+
$( document )
|
|
683
|
+
.addEvent( {
|
|
684
|
+
eventType: type == 'touchstart' ? 'touchmove' : 'mousemove',eventID: 'CropperEffectMove',option: { passive: false },
|
|
685
|
+
callback: ( event ) => {
|
|
686
|
+
DragEffect( 'move',event );
|
|
687
|
+
},
|
|
688
|
+
} )
|
|
689
|
+
.addEvent( {
|
|
690
|
+
eventType: type == 'touchstart' ? 'touchend' : 'mouseup',eventID: 'CropperEffectEnd',option: { passive: false },
|
|
691
|
+
callback: ( event ) => {
|
|
692
|
+
DragEffect( 'end',event );
|
|
693
|
+
EventEnd( event );
|
|
694
|
+
},
|
|
695
|
+
} );
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
const DragEffect = function ( eventType: 'move' | 'end',event: any ) {
|
|
699
|
+
event.preventDefault();
|
|
700
|
+
__Cropper.dragEffect( {
|
|
701
|
+
eventType: eventType,
|
|
702
|
+
...$.getCursor( event )
|
|
703
|
+
} );
|
|
704
|
+
}
|
|
705
|
+
const EventEnd = function ( event: any ) {
|
|
706
|
+
event.preventDefault();
|
|
707
|
+
|
|
708
|
+
$( document ).removeEvent( [
|
|
709
|
+
'CropperEffectMove',
|
|
710
|
+
'CropperEffectEnd'
|
|
711
|
+
] )
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
$( Canvas )
|
|
715
|
+
.removeEvent( [
|
|
716
|
+
'CropperMouseWheel',
|
|
717
|
+
'CropperTouchStart',
|
|
718
|
+
'CropperMouseDown'
|
|
719
|
+
] )
|
|
720
|
+
.addEvent( {
|
|
721
|
+
eventID: 'CropperMouseWheel',
|
|
722
|
+
eventType: 'wheel',
|
|
723
|
+
callback: ( event ) => {
|
|
724
|
+
event.preventDefault();
|
|
725
|
+
|
|
726
|
+
let bitScale = Number( event.wheelDelta * 0.04 );
|
|
727
|
+
let nextScale = __Cropper.scale.current + bitScale;
|
|
728
|
+
|
|
729
|
+
nextScale = Math.max( nextScale,__Cropper.scale.min );
|
|
730
|
+
nextScale = Math.min( nextScale,__Cropper.scale.max );
|
|
731
|
+
|
|
732
|
+
set_scale( nextScale );
|
|
733
|
+
},
|
|
734
|
+
option: { passive: false }
|
|
735
|
+
} )
|
|
736
|
+
.addEvent( {
|
|
737
|
+
eventType: 'touchstart',eventID: 'CropperTouchStart',
|
|
738
|
+
callback: UserEffectStart,option: { passive: false }
|
|
739
|
+
} )
|
|
740
|
+
.addEvent( {
|
|
741
|
+
eventType: 'mousedown',eventID: 'CropperMouseDown',
|
|
742
|
+
callback: UserEffectStart,option: { passive: false }
|
|
743
|
+
} );
|
|
744
|
+
|
|
745
|
+
setTimeout( () => {
|
|
746
|
+
amotify.fn.Loader.fn.corner.stop();
|
|
747
|
+
},1000 );
|
|
748
|
+
} )();
|
|
749
|
+
},[ val_file.id ] );
|
|
750
|
+
useEffect( () => {
|
|
751
|
+
let Instance: CroppImage = useStore.get( val_componentID )?.Instance;
|
|
752
|
+
if ( Instance ) {
|
|
753
|
+
Instance.updateScale( val_scale );
|
|
754
|
+
}
|
|
755
|
+
},[ val_scale ] );
|
|
756
|
+
useEffect( () => {
|
|
757
|
+
let Instance: CroppImage = useStore.get( val_componentID )?.Instance;
|
|
758
|
+
if ( Instance ) {
|
|
759
|
+
Instance.updateFilter( {
|
|
760
|
+
grayScale: val_grayScale,
|
|
761
|
+
tone: val_tone,
|
|
762
|
+
rotate: val_rotate
|
|
763
|
+
} );
|
|
764
|
+
}
|
|
765
|
+
},[ val_grayScale,val_tone,val_rotate ] );
|
|
766
|
+
|
|
767
|
+
return ( <Sheet.Comps.Body>
|
|
768
|
+
<Flex
|
|
769
|
+
className={ [ style.Wrap,'Use_' + use ].join( ' ' ) }
|
|
770
|
+
flexWrap={ false }
|
|
771
|
+
position='relative'
|
|
772
|
+
overflow={ 'hidden' }
|
|
773
|
+
borderRadius={ 'inherit' }
|
|
774
|
+
boxShadow={ 3 }
|
|
775
|
+
UnderBreakPointStyles={ {
|
|
776
|
+
flexType: 'col'
|
|
777
|
+
} }
|
|
778
|
+
>
|
|
779
|
+
<Box
|
|
780
|
+
flexGrid={ 3 }
|
|
781
|
+
UnderBreakPointStyles={ {
|
|
782
|
+
width: 1,
|
|
783
|
+
padding: 2
|
|
784
|
+
} }
|
|
785
|
+
>
|
|
786
|
+
<Box
|
|
787
|
+
overflow='hidden'
|
|
788
|
+
position='relative'
|
|
789
|
+
backgroundColor={ '4.layer.darken' }
|
|
790
|
+
freeCSS={ {
|
|
791
|
+
zIndex: 1
|
|
792
|
+
} }
|
|
793
|
+
UnderBreakPointStyles={ {
|
|
794
|
+
borderRadius: '1.tone.primary'
|
|
795
|
+
} }
|
|
796
|
+
>
|
|
797
|
+
<canvas
|
|
798
|
+
width={ '2400' }
|
|
799
|
+
height={ use == 'profile' ? '2400' : '1800' }
|
|
800
|
+
className={ style.Canvas }
|
|
801
|
+
id={ 'Canvas-' + val_componentID }
|
|
802
|
+
/>
|
|
803
|
+
</Box>
|
|
804
|
+
</Box>
|
|
805
|
+
<Column
|
|
806
|
+
gap={ 0 }
|
|
807
|
+
flexGrid={ 2 }
|
|
808
|
+
boxShadow={ 3 }
|
|
809
|
+
UnderBreakPointStyles={ {
|
|
810
|
+
width: 1,
|
|
811
|
+
maxWidth: 'unset'
|
|
812
|
+
} }
|
|
813
|
+
freeCSS={ {
|
|
814
|
+
maxWidth: 12 * 28
|
|
815
|
+
} }
|
|
816
|
+
>
|
|
817
|
+
<Column
|
|
818
|
+
gap={ 1 }
|
|
819
|
+
flexSizing={ 0 }
|
|
820
|
+
overflow='auto'
|
|
821
|
+
padding={ 1.5 }
|
|
822
|
+
UnderBreakPointStyles={ {
|
|
823
|
+
flexSizing: 'none'
|
|
824
|
+
} }
|
|
825
|
+
>
|
|
826
|
+
<Box
|
|
827
|
+
flexSizing='none'
|
|
828
|
+
fontSize='4.thirdTitle'
|
|
829
|
+
isBoldFont
|
|
830
|
+
>
|
|
831
|
+
フィルター
|
|
832
|
+
</Box>
|
|
833
|
+
<Comps.SettingRegion
|
|
834
|
+
DefaultOptions={ DefaultOptions }
|
|
835
|
+
val_scale={ val_scale }
|
|
836
|
+
set_scale={ set_scale }
|
|
837
|
+
val_tone={ val_tone }
|
|
838
|
+
set_tone={ set_tone }
|
|
839
|
+
val_grayScale={ val_grayScale }
|
|
840
|
+
set_grayScale={ set_grayScale }
|
|
841
|
+
val_rotate={ val_rotate }
|
|
842
|
+
set_rotate={ set_rotate }
|
|
843
|
+
/>
|
|
844
|
+
</Column>
|
|
845
|
+
<Flex
|
|
846
|
+
padding={ 1.5 }
|
|
847
|
+
flexSizing={ 'none' }
|
|
848
|
+
gap={ 1 }
|
|
849
|
+
borderTop
|
|
850
|
+
>
|
|
851
|
+
<Buttons.Button.Border.R
|
|
852
|
+
flexGrid={ 1 }
|
|
853
|
+
onClick={ () => {
|
|
854
|
+
abortCallback();
|
|
855
|
+
} }
|
|
856
|
+
>
|
|
857
|
+
キャンセル
|
|
858
|
+
</Buttons.Button.Border.R>
|
|
859
|
+
<Buttons.Button.Prime.R
|
|
860
|
+
flexGrid={ 2 }
|
|
861
|
+
onClick={ async () => {
|
|
862
|
+
let Instance: CroppImage = useStore.get( val_componentID )?.Instance;
|
|
863
|
+
if ( !Instance ) return;
|
|
864
|
+
amotify.fn.Loader.fn.mini.active( 'CropperExportation' );
|
|
865
|
+
let Files = await Instance.export();
|
|
866
|
+
|
|
867
|
+
setTimeout( () => {
|
|
868
|
+
amotify.fn.Loader.fn.mini.stop( 'CropperExportation' );
|
|
869
|
+
finishedCallback( Files );
|
|
870
|
+
},3000 );
|
|
871
|
+
} }
|
|
872
|
+
>
|
|
873
|
+
<Row.Center
|
|
874
|
+
gap={ '1/2' }
|
|
875
|
+
>
|
|
876
|
+
<Loader.White.R
|
|
877
|
+
loaderID='CropperExportation'
|
|
878
|
+
/>
|
|
879
|
+
決定
|
|
880
|
+
</Row.Center>
|
|
881
|
+
</Buttons.Button.Prime.R>
|
|
882
|
+
</Flex>
|
|
883
|
+
</Column>
|
|
884
|
+
</Flex>
|
|
885
|
+
</Sheet.Comps.Body> );
|
|
886
|
+
},
|
|
887
|
+
SettingRegion: ( params ) => {
|
|
888
|
+
let ToneList: amotify.fn.Input.List.OptionParams[] = [];
|
|
889
|
+
for ( let index = 1; index <= 10; index++ ) {
|
|
890
|
+
ToneList.push( {
|
|
891
|
+
value: index,
|
|
892
|
+
label: <>
|
|
893
|
+
<Box
|
|
894
|
+
className={ [
|
|
895
|
+
style.ToneBall,
|
|
896
|
+
style[ 'ToneBall_' + index ]
|
|
897
|
+
].join( ' ' ) }
|
|
898
|
+
/>
|
|
899
|
+
<Box
|
|
900
|
+
textAlign='center'
|
|
901
|
+
flexSizing={ 'auto' }
|
|
902
|
+
>
|
|
903
|
+
{ [ '','暖色','寒色','セピア','シアン','マゼンタ','イエロー','オリジナル1','オリジナル2','オリジナル3','オリジナル4' ][ index ] }
|
|
904
|
+
</Box>
|
|
905
|
+
</>
|
|
906
|
+
} );
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
return (
|
|
910
|
+
<>
|
|
911
|
+
<Column gap={ '1/3' } >
|
|
912
|
+
<Box>
|
|
913
|
+
<FAIcon.Rotate
|
|
914
|
+
fontSize='3.paragraph'
|
|
915
|
+
/> Rotate
|
|
916
|
+
</Box>
|
|
917
|
+
<Row.Separate
|
|
918
|
+
flexChilds='even'
|
|
919
|
+
paddingLeft={ 2 }
|
|
920
|
+
>
|
|
921
|
+
<Buttons.Button.Border.R
|
|
922
|
+
onClick={ () => {
|
|
923
|
+
let next = params.val_rotate - 90;
|
|
924
|
+
if ( next < 0 ) next += 360;
|
|
925
|
+
params.set_rotate( next );
|
|
926
|
+
} }
|
|
927
|
+
>
|
|
928
|
+
<FAIcon.RotateLeft /> 左に回転
|
|
929
|
+
</Buttons.Button.Border.R>
|
|
930
|
+
<Buttons.Button.Border.R
|
|
931
|
+
onClick={ () => {
|
|
932
|
+
params.set_rotate( ( params.val_rotate + 90 ) % 360 );
|
|
933
|
+
} }
|
|
934
|
+
>
|
|
935
|
+
右に回転 <FAIcon.RotateRight />
|
|
936
|
+
</Buttons.Button.Border.R>
|
|
937
|
+
</Row.Separate>
|
|
938
|
+
</Column>
|
|
939
|
+
<Column gap={ '1/3' } >
|
|
940
|
+
<Box>
|
|
941
|
+
<FAIcon
|
|
942
|
+
fontSize='3.paragraph'
|
|
943
|
+
d='magnifying-glass-plus'
|
|
944
|
+
/> Zoom
|
|
945
|
+
</Box>
|
|
946
|
+
<Box paddingLeft={ 2 }>
|
|
947
|
+
<Input.Slider
|
|
948
|
+
override='force'
|
|
949
|
+
value={ params.val_scale - 100 }
|
|
950
|
+
min={ params.DefaultOptions.scale.min - 100 }
|
|
951
|
+
max={ params.DefaultOptions.scale.max - 100 }
|
|
952
|
+
step={ 25 }
|
|
953
|
+
onUpdateValidValue={ ( { eventType,value } ) => {
|
|
954
|
+
params.set_scale( value + 100 );
|
|
955
|
+
} }
|
|
956
|
+
legends={ {
|
|
957
|
+
enable: true,
|
|
958
|
+
custom: ( value ) => {
|
|
959
|
+
let scale = Math.round( 100 + value );
|
|
960
|
+
return 'x' + scale / 100;
|
|
961
|
+
}
|
|
962
|
+
} }
|
|
963
|
+
/>
|
|
964
|
+
</Box>
|
|
965
|
+
</Column>
|
|
966
|
+
<Column gap={ '1/3' } >
|
|
967
|
+
<Box>
|
|
968
|
+
<FAIcon
|
|
969
|
+
fontSize='3.paragraph'
|
|
970
|
+
d='palette'
|
|
971
|
+
/> Gray Scale
|
|
972
|
+
</Box>
|
|
973
|
+
<Box paddingLeft={ 2 }>
|
|
974
|
+
<Input.Slider
|
|
975
|
+
value={ params.val_grayScale }
|
|
976
|
+
min={ 0 }
|
|
977
|
+
max={ 100 }
|
|
978
|
+
step={ 25 }
|
|
979
|
+
onUpdateValidValue={ ( { value } ) => {
|
|
980
|
+
params.set_grayScale( value );
|
|
981
|
+
} }
|
|
982
|
+
legends={ {
|
|
983
|
+
enable: true,
|
|
984
|
+
custom: ( value ) => ( value + '%' )
|
|
985
|
+
} }
|
|
986
|
+
/>
|
|
987
|
+
</Box>
|
|
988
|
+
</Column>
|
|
989
|
+
<Column gap={ '1/3' }>
|
|
990
|
+
<Box>
|
|
991
|
+
<FAIcon
|
|
992
|
+
fontSize='3.paragraph'
|
|
993
|
+
d='bars-staggered'
|
|
994
|
+
/> Tone
|
|
995
|
+
</Box>
|
|
996
|
+
<Box paddingLeft={ 2 }>
|
|
997
|
+
<Input.Radio
|
|
998
|
+
value={ params.val_tone }
|
|
999
|
+
gap={ '1/2' }
|
|
1000
|
+
cellStyles={ {
|
|
1001
|
+
isRounded: true,
|
|
1002
|
+
borderWidth: 2,
|
|
1003
|
+
borderColor: '1.thin',
|
|
1004
|
+
padding: '1/2',
|
|
1005
|
+
paddingRight: 1,
|
|
1006
|
+
fontSize: '1.mini',
|
|
1007
|
+
gap: '1/3',
|
|
1008
|
+
flexSizing: 'auto'
|
|
1009
|
+
} }
|
|
1010
|
+
options={ [
|
|
1011
|
+
{
|
|
1012
|
+
value: 0,label: 'なし',
|
|
1013
|
+
padding: [ '1/2',1 ],
|
|
1014
|
+
flexCenter: true
|
|
1015
|
+
},
|
|
1016
|
+
...ToneList
|
|
1017
|
+
] }
|
|
1018
|
+
onUpdateValidValue={ ( { value } ) => {
|
|
1019
|
+
params.set_tone( value[ 0 ] );
|
|
1020
|
+
} }
|
|
1021
|
+
/>
|
|
1022
|
+
</Box>
|
|
1023
|
+
</Column>
|
|
1024
|
+
</>
|
|
1025
|
+
);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
export const Cropper: amotify.fn.Cropper.Methods = {
|
|
1030
|
+
open: async ( params ) => {
|
|
1031
|
+
let Image = await Input.File.fn.openDialog( {
|
|
1032
|
+
// accept: 'image/jpeg,image/jpg,image/png,image/gif',
|
|
1033
|
+
accept: 'image',
|
|
1034
|
+
multiple: false
|
|
1035
|
+
} );
|
|
1036
|
+
|
|
1037
|
+
let sheetID = 'CropperImage';
|
|
1038
|
+
amotify.fn.Sheet.open( {
|
|
1039
|
+
sheetID: sheetID,
|
|
1040
|
+
type: 'normal.middleCenter',
|
|
1041
|
+
size: '3L',
|
|
1042
|
+
freeCSS: {
|
|
1043
|
+
width: params.use == 'header' ? 12 * 100 : 12 * 80
|
|
1044
|
+
},
|
|
1045
|
+
content: <Comps.Core
|
|
1046
|
+
val_file={ Image[ 0 ] as any }
|
|
1047
|
+
options={ params }
|
|
1048
|
+
finishedCallback={ ( files ) => {
|
|
1049
|
+
amotify.fn.Sheet.close( sheetID );
|
|
1050
|
+
params.onProcessFinished( files );
|
|
1051
|
+
} }
|
|
1052
|
+
abortCallback={ () => {
|
|
1053
|
+
amotify.fn.Sheet.close( sheetID );
|
|
1054
|
+
} }
|
|
1055
|
+
/>,
|
|
1056
|
+
closeOption: {
|
|
1057
|
+
escapeKeyDown: false
|
|
1058
|
+
}
|
|
1059
|
+
} );
|
|
1060
|
+
}
|
|
1061
|
+
}
|