@pixagram/renderart 0.1.0
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/LICENSE +21 -0
- package/README.md +196 -0
- package/dist/index.d.mts +331 -0
- package/dist/index.d.ts +331 -0
- package/dist/index.js +1833 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1819 -0
- package/dist/index.mjs.map +1 -0
- package/dist/wasm/renderart_wasm.d.ts +289 -0
- package/dist/wasm/renderart_wasm.js +893 -0
- package/dist/wasm/renderart_wasm_bg.wasm +0 -0
- package/dist/wasm/renderart_wasm_bg.wasm.d.ts +70 -0
- package/package.json +64 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common types for RenderArt module
|
|
3
|
+
*/
|
|
4
|
+
/** RGBA pixel data as Uint8ClampedArray or Uint8Array */
|
|
5
|
+
type PixelData = Uint8ClampedArray | Uint8Array;
|
|
6
|
+
/** Input image data structure */
|
|
7
|
+
interface ImageInput {
|
|
8
|
+
/** Raw RGBA pixel data */
|
|
9
|
+
data: PixelData;
|
|
10
|
+
/** Image width in pixels */
|
|
11
|
+
width: number;
|
|
12
|
+
/** Image height in pixels */
|
|
13
|
+
height: number;
|
|
14
|
+
}
|
|
15
|
+
/** Output image data structure */
|
|
16
|
+
interface ImageOutput {
|
|
17
|
+
/** Raw RGBA pixel data */
|
|
18
|
+
data: Uint8ClampedArray;
|
|
19
|
+
/** Output width in pixels */
|
|
20
|
+
width: number;
|
|
21
|
+
/** Output height in pixels */
|
|
22
|
+
height: number;
|
|
23
|
+
}
|
|
24
|
+
/** Rendering backend type */
|
|
25
|
+
type Backend = 'gpu' | 'cpu' | 'auto';
|
|
26
|
+
/** CRT effect configuration */
|
|
27
|
+
interface CrtOptions {
|
|
28
|
+
/** Scale factor (2-32, default: 3) */
|
|
29
|
+
scale?: number;
|
|
30
|
+
/** Horizontal warp intensity (0.0-0.1, default: 0.015) */
|
|
31
|
+
warpX?: number;
|
|
32
|
+
/** Vertical warp intensity (0.0-0.1, default: 0.02) */
|
|
33
|
+
warpY?: number;
|
|
34
|
+
/** Scanline hardness (-10 to 0, default: -4) */
|
|
35
|
+
scanHardness?: number;
|
|
36
|
+
/** Scanline opacity (0.0-1.0, default: 0.5) */
|
|
37
|
+
scanOpacity?: number;
|
|
38
|
+
/** Shadow mask opacity (0.0-1.0, default: 0.3) */
|
|
39
|
+
maskOpacity?: number;
|
|
40
|
+
/** Enable barrel distortion (default: true) */
|
|
41
|
+
enableWarp?: boolean;
|
|
42
|
+
/** Enable scanlines (default: true) */
|
|
43
|
+
enableScanlines?: boolean;
|
|
44
|
+
/** Enable shadow mask (default: true) */
|
|
45
|
+
enableMask?: boolean;
|
|
46
|
+
/** Rendering backend (default: 'auto') */
|
|
47
|
+
backend?: Backend;
|
|
48
|
+
}
|
|
49
|
+
/** CRT preset names */
|
|
50
|
+
type CrtPreset = 'default' | 'authentic' | 'subtle' | 'flat';
|
|
51
|
+
/** Hexagon orientation */
|
|
52
|
+
type HexOrientation = 'flat-top' | 'pointy-top';
|
|
53
|
+
/** Hexagonal upscaling configuration */
|
|
54
|
+
interface HexOptions {
|
|
55
|
+
/** Scale factor (2-32, default: 16) */
|
|
56
|
+
scale?: number;
|
|
57
|
+
/** Hexagon orientation (default: 'flat-top') */
|
|
58
|
+
orientation?: HexOrientation;
|
|
59
|
+
/** Draw hexagon borders (default: false) */
|
|
60
|
+
drawBorders?: boolean;
|
|
61
|
+
/** Border color as CSS color or 0xRRGGBBAA (default: '#282828') */
|
|
62
|
+
borderColor?: string | number;
|
|
63
|
+
/** Border thickness in pixels (default: 1) */
|
|
64
|
+
borderThickness?: number;
|
|
65
|
+
/** Background color (default: 'transparent') */
|
|
66
|
+
backgroundColor?: string | number;
|
|
67
|
+
/** Rendering backend (default: 'auto') */
|
|
68
|
+
backend?: Backend;
|
|
69
|
+
}
|
|
70
|
+
/** HEX preset names */
|
|
71
|
+
type HexPreset = 'default' | 'bordered' | 'pointy';
|
|
72
|
+
/** xBRZ scaling configuration */
|
|
73
|
+
interface XbrzOptions {
|
|
74
|
+
/** Scale factor (2-6, default: 2) */
|
|
75
|
+
scale?: number;
|
|
76
|
+
/** Luminance weight for edge detection (0.0-1.0, default: 1.0) */
|
|
77
|
+
luminanceWeight?: number;
|
|
78
|
+
/** Equal color tolerance (0-50, default: 30) */
|
|
79
|
+
equalColorTolerance?: number;
|
|
80
|
+
/** Dominant direction threshold (3.5-6.0, default: 4.4) */
|
|
81
|
+
dominantDirectionThreshold?: number;
|
|
82
|
+
/** Steep direction threshold (2.0-3.0, default: 2.2) */
|
|
83
|
+
steepDirectionThreshold?: number;
|
|
84
|
+
}
|
|
85
|
+
/** XBRZ preset names */
|
|
86
|
+
type XbrzPreset = 'default' | 'sharp' | 'smooth';
|
|
87
|
+
/** Renderer capabilities */
|
|
88
|
+
interface RendererCapabilities {
|
|
89
|
+
/** WebGL2 GPU rendering available */
|
|
90
|
+
gpu: boolean;
|
|
91
|
+
/** WASM CPU rendering available */
|
|
92
|
+
cpu: boolean;
|
|
93
|
+
/** Maximum texture size (GPU) */
|
|
94
|
+
maxTextureSize: number;
|
|
95
|
+
/** Recommended backend for current device */
|
|
96
|
+
recommendedBackend: Backend;
|
|
97
|
+
}
|
|
98
|
+
/** Render statistics */
|
|
99
|
+
interface RenderStats {
|
|
100
|
+
/** Rendering time in milliseconds */
|
|
101
|
+
renderTimeMs: number;
|
|
102
|
+
/** Backend used for rendering */
|
|
103
|
+
backend: Backend;
|
|
104
|
+
/** Input dimensions */
|
|
105
|
+
inputSize: {
|
|
106
|
+
width: number;
|
|
107
|
+
height: number;
|
|
108
|
+
};
|
|
109
|
+
/** Output dimensions */
|
|
110
|
+
outputSize: {
|
|
111
|
+
width: number;
|
|
112
|
+
height: number;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/** Common renderer interface */
|
|
116
|
+
interface Renderer<TOptions> {
|
|
117
|
+
/** Render image with options */
|
|
118
|
+
render(input: ImageInput | ImageData, options?: TOptions): ImageOutput;
|
|
119
|
+
/** Check if renderer is ready */
|
|
120
|
+
isReady(): boolean;
|
|
121
|
+
/** Dispose resources */
|
|
122
|
+
dispose(): void;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* CRT GPU Renderer using WebGL2
|
|
127
|
+
*
|
|
128
|
+
* High-performance CRT effect rendering using fragment shaders.
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
/** CRT GPU Renderer */
|
|
132
|
+
declare class CrtGpuRenderer implements Renderer<CrtOptions> {
|
|
133
|
+
private gl;
|
|
134
|
+
private canvas;
|
|
135
|
+
private program;
|
|
136
|
+
private texture;
|
|
137
|
+
private uniforms;
|
|
138
|
+
private initialized;
|
|
139
|
+
private currentCanvasSize;
|
|
140
|
+
private currentTexSize;
|
|
141
|
+
/** Create a new CRT GPU renderer */
|
|
142
|
+
static create(): CrtGpuRenderer;
|
|
143
|
+
private init;
|
|
144
|
+
private createShader;
|
|
145
|
+
/** Check if renderer is ready */
|
|
146
|
+
isReady(): boolean;
|
|
147
|
+
/** Render CRT effect */
|
|
148
|
+
render(input: ImageInput | ImageData, options?: CrtOptions): ImageOutput;
|
|
149
|
+
/** Dispose resources */
|
|
150
|
+
dispose(): void;
|
|
151
|
+
}
|
|
152
|
+
/** CRT presets */
|
|
153
|
+
declare const CRT_PRESETS: Record<string, Partial<CrtOptions>>;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Hexagonal GPU Renderer using WebGL2
|
|
157
|
+
*
|
|
158
|
+
* High-performance hexagonal pixel grid transformation using fragment shaders.
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
/** Calculate output dimensions for hex rendering */
|
|
162
|
+
declare function hexGetDimensions(srcWidth: number, srcHeight: number, scale: number, orientation?: HexOrientation): {
|
|
163
|
+
width: number;
|
|
164
|
+
height: number;
|
|
165
|
+
};
|
|
166
|
+
/** HEX GPU Renderer */
|
|
167
|
+
declare class HexGpuRenderer implements Renderer<HexOptions> {
|
|
168
|
+
private gl;
|
|
169
|
+
private canvas;
|
|
170
|
+
private program;
|
|
171
|
+
private texture;
|
|
172
|
+
private uniforms;
|
|
173
|
+
private initialized;
|
|
174
|
+
private currentCanvasSize;
|
|
175
|
+
private currentTexSize;
|
|
176
|
+
/** Create a new HEX GPU renderer */
|
|
177
|
+
static create(): HexGpuRenderer;
|
|
178
|
+
private init;
|
|
179
|
+
private createShader;
|
|
180
|
+
/** Check if renderer is ready */
|
|
181
|
+
isReady(): boolean;
|
|
182
|
+
/** Render hexagonal effect */
|
|
183
|
+
render(input: ImageInput | ImageData, options?: HexOptions): ImageOutput;
|
|
184
|
+
/** Dispose resources */
|
|
185
|
+
dispose(): void;
|
|
186
|
+
}
|
|
187
|
+
/** HEX presets */
|
|
188
|
+
declare const HEX_PRESETS: Record<string, Partial<HexOptions>>;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* WASM Module Loader
|
|
192
|
+
*
|
|
193
|
+
* Handles loading and initialization of the Rust WASM module.
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
/** Load WASM module */
|
|
197
|
+
declare function loadWasm(): Promise<any>;
|
|
198
|
+
/** Check if WASM is loaded */
|
|
199
|
+
declare function isWasmLoaded(): boolean;
|
|
200
|
+
/** CRT CPU Renderer using WASM */
|
|
201
|
+
declare class CrtCpuRenderer {
|
|
202
|
+
private ready;
|
|
203
|
+
/** Create and initialize renderer */
|
|
204
|
+
static create(): Promise<CrtCpuRenderer>;
|
|
205
|
+
private init;
|
|
206
|
+
/** Check if renderer is ready */
|
|
207
|
+
isReady(): boolean;
|
|
208
|
+
/** Render CRT effect */
|
|
209
|
+
render(input: ImageInput | ImageData, options?: CrtOptions): ImageOutput;
|
|
210
|
+
/** Dispose resources */
|
|
211
|
+
dispose(): void;
|
|
212
|
+
}
|
|
213
|
+
/** HEX CPU Renderer using WASM */
|
|
214
|
+
declare class HexCpuRenderer {
|
|
215
|
+
private ready;
|
|
216
|
+
/** Create and initialize renderer */
|
|
217
|
+
static create(): Promise<HexCpuRenderer>;
|
|
218
|
+
private init;
|
|
219
|
+
/** Check if renderer is ready */
|
|
220
|
+
isReady(): boolean;
|
|
221
|
+
/** Render hexagonal effect */
|
|
222
|
+
render(input: ImageInput | ImageData, options?: HexOptions): ImageOutput;
|
|
223
|
+
/** Get output dimensions */
|
|
224
|
+
getDimensions(srcWidth: number, srcHeight: number, scale: number, orientation?: HexOrientation): {
|
|
225
|
+
width: number;
|
|
226
|
+
height: number;
|
|
227
|
+
};
|
|
228
|
+
/** Dispose resources */
|
|
229
|
+
dispose(): void;
|
|
230
|
+
}
|
|
231
|
+
/** XBRZ CPU Renderer using WASM */
|
|
232
|
+
declare class XbrzCpuRenderer {
|
|
233
|
+
private ready;
|
|
234
|
+
/** Create and initialize renderer */
|
|
235
|
+
static create(): Promise<XbrzCpuRenderer>;
|
|
236
|
+
private init;
|
|
237
|
+
/** Check if renderer is ready */
|
|
238
|
+
isReady(): boolean;
|
|
239
|
+
/** Render xBRZ scaling */
|
|
240
|
+
render(input: ImageInput | ImageData, options?: XbrzOptions): ImageOutput;
|
|
241
|
+
/** Dispose resources */
|
|
242
|
+
dispose(): void;
|
|
243
|
+
}
|
|
244
|
+
/** XBRZ presets */
|
|
245
|
+
declare const XBRZ_PRESETS: Record<string, Partial<XbrzOptions>>;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* RenderArt - Unified Pixel Art Rendering Engine
|
|
249
|
+
*
|
|
250
|
+
* Provides a unified API for all rendering engines (CRT, HEX, XBRZ)
|
|
251
|
+
* with automatic backend selection (GPU/CPU).
|
|
252
|
+
*/
|
|
253
|
+
|
|
254
|
+
/** CRT rendering engine with GPU/CPU backend support */
|
|
255
|
+
declare class CrtEngine {
|
|
256
|
+
private gpuRenderer;
|
|
257
|
+
private cpuRenderer;
|
|
258
|
+
private gpuAvailable;
|
|
259
|
+
private cpuAvailable;
|
|
260
|
+
constructor(gpuAvailable: boolean, cpuAvailable: boolean);
|
|
261
|
+
/** Initialize GPU renderer */
|
|
262
|
+
private ensureGpu;
|
|
263
|
+
/** Initialize CPU renderer */
|
|
264
|
+
private ensureCpu;
|
|
265
|
+
/** Render with automatic backend selection */
|
|
266
|
+
render(input: ImageInput | ImageData, options?: CrtOptions): Promise<ImageOutput>;
|
|
267
|
+
/** Render with preset */
|
|
268
|
+
render(input: ImageInput | ImageData, preset: CrtPreset, overrides?: Partial<CrtOptions>): Promise<ImageOutput>;
|
|
269
|
+
/** Render synchronously (GPU only) */
|
|
270
|
+
renderSync(input: ImageInput | ImageData, options?: CrtOptions): ImageOutput;
|
|
271
|
+
/** Dispose resources */
|
|
272
|
+
dispose(): void;
|
|
273
|
+
}
|
|
274
|
+
/** HEX rendering engine with GPU/CPU backend support */
|
|
275
|
+
declare class HexEngine {
|
|
276
|
+
private gpuRenderer;
|
|
277
|
+
private cpuRenderer;
|
|
278
|
+
private gpuAvailable;
|
|
279
|
+
private cpuAvailable;
|
|
280
|
+
constructor(gpuAvailable: boolean, cpuAvailable: boolean);
|
|
281
|
+
private ensureGpu;
|
|
282
|
+
private ensureCpu;
|
|
283
|
+
/** Render with automatic backend selection */
|
|
284
|
+
render(input: ImageInput | ImageData, options?: HexOptions): Promise<ImageOutput>;
|
|
285
|
+
/** Render with preset */
|
|
286
|
+
render(input: ImageInput | ImageData, preset: HexPreset, overrides?: Partial<HexOptions>): Promise<ImageOutput>;
|
|
287
|
+
/** Render synchronously (GPU only) */
|
|
288
|
+
renderSync(input: ImageInput | ImageData, options?: HexOptions): ImageOutput;
|
|
289
|
+
/** Get output dimensions */
|
|
290
|
+
getDimensions(srcWidth: number, srcHeight: number, options?: HexOptions): {
|
|
291
|
+
width: number;
|
|
292
|
+
height: number;
|
|
293
|
+
};
|
|
294
|
+
dispose(): void;
|
|
295
|
+
}
|
|
296
|
+
/** XBRZ rendering engine (CPU only - algorithm too complex for efficient GPU) */
|
|
297
|
+
declare class XbrzEngine {
|
|
298
|
+
private cpuRenderer;
|
|
299
|
+
private cpuAvailable;
|
|
300
|
+
constructor(cpuAvailable: boolean);
|
|
301
|
+
private ensureCpu;
|
|
302
|
+
/** Render xBRZ scaling */
|
|
303
|
+
render(input: ImageInput | ImageData, options?: XbrzOptions): Promise<ImageOutput>;
|
|
304
|
+
/** Render with preset */
|
|
305
|
+
render(input: ImageInput | ImageData, preset: XbrzPreset, overrides?: Partial<XbrzOptions>): Promise<ImageOutput>;
|
|
306
|
+
/** Get output dimensions */
|
|
307
|
+
getDimensions(srcWidth: number, srcHeight: number, scale?: number): {
|
|
308
|
+
width: number;
|
|
309
|
+
height: number;
|
|
310
|
+
};
|
|
311
|
+
dispose(): void;
|
|
312
|
+
}
|
|
313
|
+
/** RenderArt - Unified Pixel Art Rendering Engine */
|
|
314
|
+
declare class RenderArt {
|
|
315
|
+
/** CRT effect renderer */
|
|
316
|
+
readonly crt: CrtEngine;
|
|
317
|
+
/** Hexagonal pixel renderer */
|
|
318
|
+
readonly hex: HexEngine;
|
|
319
|
+
/** xBRZ scaling renderer */
|
|
320
|
+
readonly xbrz: XbrzEngine;
|
|
321
|
+
private _capabilities;
|
|
322
|
+
private constructor();
|
|
323
|
+
/** Create and initialize RenderArt instance */
|
|
324
|
+
static create(): Promise<RenderArt>;
|
|
325
|
+
/** Get renderer capabilities */
|
|
326
|
+
get capabilities(): RendererCapabilities;
|
|
327
|
+
/** Dispose all resources */
|
|
328
|
+
dispose(): void;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export { type Backend, CRT_PRESETS, CrtCpuRenderer, CrtGpuRenderer, type CrtOptions, type CrtPreset, HEX_PRESETS, HexCpuRenderer, HexGpuRenderer, type HexOptions, type HexOrientation, type HexPreset, type ImageInput, type ImageOutput, type PixelData, RenderArt, type RenderStats, type Renderer, type RendererCapabilities, XBRZ_PRESETS, XbrzCpuRenderer, type XbrzOptions, type XbrzPreset, hexGetDimensions, isWasmLoaded, loadWasm };
|