-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
282 lines (263 loc) · 6.88 KB
/
types.ts
File metadata and controls
282 lines (263 loc) · 6.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
export type Language = 'en' | 'zh';
export type DrawingTool = 'pan' | 'brush' | 'eraser' | 'eyedropper' | 'bucket' | 'move';
export interface HSLAdjustment {
brightness: number; // -100 to 100
saturation: number; // -100 to 100
hue: number; // -180 to 180
}
export interface PixelSettings {
pixelSize: number;
scale: number;
isGrayscale: boolean;
paletteSize: number;
contrast: number;
smoothing: number;
dithering: number;
outlineColor: string;
hasOutline: boolean;
outlineThickness: number;
hsl: HSLAdjustment;
showGrid: boolean;
gridColor: string;
gridOpacity: number;
}
export interface Layer {
id: string;
name: string;
visible: boolean;
opacity: number;
data: Uint8ClampedArray; // TypedArray for pixel data [r,g,b,a,r,g,b,a,...]
width: number; // Layer width in pixels
height: number; // Layer height in pixels
}
export interface ProjectState {
activeLayerId: string;
savedColors: string[]; // List of hex codes
}
// History delta for optimized undo/redo
export interface HistoryDelta {
type: 'pixel' | 'layer' | 'project';
layerId: string;
changes?: Array<{
x: number;
y: number;
oldColor: [number, number, number, number];
newColor: [number, number, number, number];
}>;
timestamp: number;
}
// History entry containing the delta
export interface HistoryEntry {
delta: HistoryDelta;
timestamp: number;
}
export interface AIHistoryItem {
id: string;
url: string; // Data URL
prompt: string;
timestamp: number;
}
export interface ProcessingState {
isProcessing: boolean;
previewUrl: string | null;
originalWidth: number;
originalHeight: number;
processedWidth: number;
processedHeight: number;
}
export interface VideoProcessOptions {
inputPath: string;
outputDir?: string;
fps: number;
width: number;
height: number;
fileData?: number[]; // 浏览器环境中传递文件数据
settings?: {
pixelSize: number;
scale: number;
isGrayscale: boolean;
paletteSize: number;
contrast: number;
smoothing: number;
dithering: number;
outlineColor: string;
hasOutline: boolean;
outlineThickness: number;
hsl: HSLAdjustment;
};
}
export interface VideoProcessResult {
success: boolean;
outputDir: string;
frameCount: number;
error?: string;
}
export interface VideoPreviewOptions {
inputPath: string;
frameIndex: number;
width: number;
height: number;
settings?: {
pixelSize: number;
scale: number;
isGrayscale: boolean;
paletteSize: number;
contrast: number;
smoothing: number;
dithering: number;
outlineColor: string;
hasOutline: boolean;
outlineThickness: number;
hsl: HSLAdjustment;
};
}
export interface VideoPreviewResult {
success: boolean;
frameData: string; // Base64 encoded image data
totalFrames: number;
error?: string;
}
export interface VideoFrameInfo {
frameIndex: number;
time: number; // in seconds
imageData: string; // Base64 encoded image
}
declare global {
interface Window {
videoAPI?: {
processVideo(options: VideoProcessOptions): Promise<VideoProcessResult>;
previewVideoFrame(options: VideoPreviewOptions): Promise<VideoPreviewResult>;
getVideoInfo(inputPath: string): Promise<{ totalFrames: number; fps: number; duration: number }>;
exportVideoSequence(options: VideoProcessOptions): Promise<VideoProcessResult>;
};
}
}
export interface AIAnalysisResult {
title: string;
description: string;
mood: string;
}
export const LABELS = {
en: {
appTitle: "PIXEL//MONKEY",
subtitle: "SYSTEM READY",
pixelBlockSize: "DATA_BLOCK_SIZE",
pixelDesc: "Abstraction Level",
paletteSize: "COLOR_LIMIT",
paletteDesc: "Quantization Index",
contrast: "SIGNAL_GAIN",
contrastDesc: "Edge Separation",
smoothing: "NOISE_FILTER",
smoothingDesc: "Smoothing Algorithm",
dithering: "DITHER_MATRIX",
ditheringDesc: "Pattern Overlay",
grayscale: "MONOCHROME",
original: "INPUT",
pixelated: "OUTPUT",
analyze: "INITIATE SCAN",
analyzing: "PROCESSING...",
saveSmall: "EXPORT [RAW]",
saveScaled: "EXPORT [UPSCALED]",
dragDrop: "INSERT MEDIA",
uploadInfo: "OR INITIALIZE UPLOAD",
uploadTooltip: "LOAD IMAGE",
zoomOut: "ZOOM -",
zoomIn: "ZOOM +",
resetZoom: "1:1",
tools: "OPERATIONS",
brush: "PENCIL (B)",
erase: "ERASER (E)",
picker: "PICKER (ALT)",
pan: "PAN",
bucket: "FILL (G)",
aiTools: "AI_STUDIO",
aiPromptPlaceholder: "e.g., 'Remove background', 'Make it cyberpunk'...",
aiGenerate: "GENERATE",
outline: "AUTO_OUTLINE",
outlineColor: "STROKE_COLOR",
outlineThickness: "STROKE_WIDTH",
quickSize: "QUICK_RES",
adjustments: "FINE_TUNE",
brightness: "BRIGHTNESS",
saturation: "SATURATION",
hue: "HUE_SHIFT",
layers: "LAYERS",
addLayer: "NEW_LAYER",
timeline: "TIMELINE",
fps: "FPS",
onionSkin: "ONION_SKIN",
play: "PLAY",
pause: "PAUSE",
addFrame: "NEW_FRAME",
aiAnim: "AI_ANIMATE",
undo: "UNDO (Ctrl+Z)",
redo: "REDO (Ctrl+Y)",
colors: "PALETTE",
hex: "HEX",
symmetry: "SYMMETRY",
enabled: "ENABLED",
vertical: "VERTICAL",
horizontal: "HORIZONTAL"
},
zh: {
appTitle: "像素猴",
subtitle: "系统就绪",
pixelBlockSize: "数据块大小",
pixelDesc: "抽象等级",
paletteSize: "色彩限制",
paletteDesc: "量化指数",
contrast: "信号增益",
contrastDesc: "边缘分离度",
smoothing: "降噪滤波器",
smoothingDesc: "平滑算法",
dithering: "抖动矩阵",
ditheringDesc: "纹理覆盖",
grayscale: "单色模式",
original: "输入源",
pixelated: "输出源",
analyze: "启动扫描",
analyzing: "处理中...",
saveSmall: "导出 [原始]",
saveScaled: "导出 [高清]",
dragDrop: "插入媒体",
uploadInfo: "或初始化上传",
uploadTooltip: "读取图片",
zoomOut: "缩小",
zoomIn: "放大",
resetZoom: "重置",
tools: "工具箱",
brush: "铅笔 (B)",
erase: "橡皮 (E)",
picker: "吸管 (按住ALT)",
pan: "拖动",
bucket: "填充 (G)",
aiTools: "AI 实验室",
aiPromptPlaceholder: "例如: '移除背景', '添加赛博朋克滤镜'...",
aiGenerate: "生成",
outline: "自动描边",
outlineColor: "描边颜色",
outlineThickness: "描边宽度",
quickSize: "快速尺寸",
adjustments: "微调",
brightness: "亮度",
saturation: "饱和度",
hue: "色相",
layers: "图层",
addLayer: "新建图层",
timeline: "时间轴",
fps: "帧率",
onionSkin: "洋葱皮",
play: "播放",
pause: "暂停",
addFrame: "新建帧",
aiAnim: "AI 补帧",
undo: "撤销 (Ctrl+Z)",
redo: "重做 (Ctrl+Y)",
colors: "调色板",
hex: "HEX",
symmetry: "对称绘制",
enabled: "启用",
vertical: "纵向",
horizontal: "横向"
}
};