@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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Pixagram SA
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# @pixagram/renderart
|
|
2
|
+
|
|
3
|
+
High-performance pixel art rendering engines with GPU (WebGL2) and CPU (WASM) support.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **CRT Effect** (2-32x) - Classic CRT display simulation with barrel distortion, scanlines, and shadow mask
|
|
8
|
+
- **HEX Upscaling** (2-32x) - Transform pixel art into hexagonal grid representations
|
|
9
|
+
- **XBRZ Scaling** (2-6x) - Edge-preserving pixel art scaling algorithm
|
|
10
|
+
|
|
11
|
+
All engines support:
|
|
12
|
+
- ⚡ **GPU acceleration** via WebGL2 (CRT, HEX)
|
|
13
|
+
- 🦀 **CPU fallback** via Rust/WASM (all engines)
|
|
14
|
+
- 🎨 **Customizable presets** and fine-grained options
|
|
15
|
+
- 📦 **Zero dependencies** - everything bundled
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @pixagram/renderart
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { RenderArt } from '@pixagram/renderart';
|
|
27
|
+
|
|
28
|
+
// Initialize (loads WASM if needed)
|
|
29
|
+
const renderer = await RenderArt.create();
|
|
30
|
+
|
|
31
|
+
// Get your image data
|
|
32
|
+
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
33
|
+
|
|
34
|
+
// Apply CRT effect
|
|
35
|
+
const crtResult = await renderer.crt.render(imageData, { scale: 3 });
|
|
36
|
+
|
|
37
|
+
// Apply hexagonal transformation
|
|
38
|
+
const hexResult = await renderer.hex.render(imageData, { scale: 16 });
|
|
39
|
+
|
|
40
|
+
// Apply xBRZ scaling
|
|
41
|
+
const xbrzResult = await renderer.xbrz.render(imageData, { scale: 4 });
|
|
42
|
+
|
|
43
|
+
// Use the result
|
|
44
|
+
ctx.putImageData(new ImageData(crtResult.data, crtResult.width, crtResult.height), 0, 0);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## API Reference
|
|
48
|
+
|
|
49
|
+
### RenderArt
|
|
50
|
+
|
|
51
|
+
Main class providing access to all rendering engines.
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
const renderer = await RenderArt.create();
|
|
55
|
+
|
|
56
|
+
// Access capabilities
|
|
57
|
+
console.log(renderer.capabilities);
|
|
58
|
+
// { gpu: true, cpu: true, maxTextureSize: 16384, recommendedBackend: 'gpu' }
|
|
59
|
+
|
|
60
|
+
// Cleanup when done
|
|
61
|
+
renderer.dispose();
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### CRT Engine
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
// With options
|
|
68
|
+
const result = await renderer.crt.render(imageData, {
|
|
69
|
+
scale: 3, // 2-32 (default: 3)
|
|
70
|
+
warpX: 0.015, // Horizontal curvature (default: 0.015)
|
|
71
|
+
warpY: 0.02, // Vertical curvature (default: 0.02)
|
|
72
|
+
scanHardness: -4.0, // Scanline sharpness (default: -4.0)
|
|
73
|
+
scanOpacity: 0.5, // Scanline intensity (default: 0.5)
|
|
74
|
+
maskOpacity: 0.3, // Shadow mask intensity (default: 0.3)
|
|
75
|
+
enableWarp: true, // Enable barrel distortion
|
|
76
|
+
enableScanlines: true, // Enable scanlines
|
|
77
|
+
enableMask: true, // Enable shadow mask
|
|
78
|
+
backend: 'auto', // 'gpu', 'cpu', or 'auto'
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// With preset
|
|
82
|
+
const result = await renderer.crt.render(imageData, 'authentic');
|
|
83
|
+
// Presets: 'default', 'authentic', 'subtle', 'flat'
|
|
84
|
+
|
|
85
|
+
// Synchronous GPU-only rendering
|
|
86
|
+
const result = renderer.crt.renderSync(imageData, { scale: 3 });
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### HEX Engine
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
// With options
|
|
93
|
+
const result = await renderer.hex.render(imageData, {
|
|
94
|
+
scale: 16, // 2-32 (default: 16)
|
|
95
|
+
orientation: 'flat-top', // 'flat-top' or 'pointy-top'
|
|
96
|
+
drawBorders: true, // Draw hexagon borders
|
|
97
|
+
borderColor: '#282828', // Border color (CSS or 0xRRGGBBAA)
|
|
98
|
+
borderThickness: 1, // Border thickness in pixels
|
|
99
|
+
backgroundColor: 'transparent', // Background color
|
|
100
|
+
backend: 'auto',
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// With preset
|
|
104
|
+
const result = await renderer.hex.render(imageData, 'bordered');
|
|
105
|
+
// Presets: 'default', 'bordered', 'pointy'
|
|
106
|
+
|
|
107
|
+
// Get output dimensions
|
|
108
|
+
const dims = renderer.hex.getDimensions(64, 64, { scale: 16 });
|
|
109
|
+
// { width: 123, height: 134 }
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### XBRZ Engine
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
// With options
|
|
116
|
+
const result = await renderer.xbrz.render(imageData, {
|
|
117
|
+
scale: 4, // 2-6 (default: 2)
|
|
118
|
+
luminanceWeight: 1.0, // Edge detection weight
|
|
119
|
+
equalColorTolerance: 30, // Color matching tolerance
|
|
120
|
+
dominantDirectionThreshold: 4.4, // Edge direction threshold
|
|
121
|
+
steepDirectionThreshold: 2.2, // Steep edge threshold
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// With preset
|
|
125
|
+
const result = await renderer.xbrz.render(imageData, 'sharp');
|
|
126
|
+
// Presets: 'default', 'sharp', 'smooth'
|
|
127
|
+
|
|
128
|
+
// Get output dimensions
|
|
129
|
+
const dims = renderer.xbrz.getDimensions(64, 64, 4);
|
|
130
|
+
// { width: 256, height: 256 }
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Backend Selection
|
|
134
|
+
|
|
135
|
+
Each engine automatically selects the best available backend:
|
|
136
|
+
|
|
137
|
+
| Engine | GPU (WebGL2) | CPU (WASM) |
|
|
138
|
+
|--------|--------------|------------|
|
|
139
|
+
| CRT | ✅ Primary | ✅ Fallback |
|
|
140
|
+
| HEX | ✅ Primary | ✅ Fallback |
|
|
141
|
+
| XBRZ | ❌ N/A | ✅ Only |
|
|
142
|
+
|
|
143
|
+
Force a specific backend:
|
|
144
|
+
```typescript
|
|
145
|
+
// Force GPU
|
|
146
|
+
const result = await renderer.crt.render(imageData, { backend: 'gpu' });
|
|
147
|
+
|
|
148
|
+
// Force CPU
|
|
149
|
+
const result = await renderer.crt.render(imageData, { backend: 'cpu' });
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Browser Support
|
|
153
|
+
|
|
154
|
+
- Chrome 79+
|
|
155
|
+
- Firefox 75+
|
|
156
|
+
- Safari 15+
|
|
157
|
+
- Edge 79+
|
|
158
|
+
|
|
159
|
+
Requires:
|
|
160
|
+
- WebGL2 for GPU rendering
|
|
161
|
+
- WebAssembly for CPU rendering
|
|
162
|
+
|
|
163
|
+
## Performance Tips
|
|
164
|
+
|
|
165
|
+
1. **Reuse the renderer instance** - initialization is expensive
|
|
166
|
+
2. **Use GPU when available** - significantly faster for CRT and HEX
|
|
167
|
+
3. **Choose appropriate scale** - larger scales need more GPU memory
|
|
168
|
+
4. **Consider XBRZ scale limits** - 2-6x only, higher factors use more CPU
|
|
169
|
+
|
|
170
|
+
## Building from Source
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Install dependencies
|
|
174
|
+
npm install
|
|
175
|
+
|
|
176
|
+
# Build WASM module
|
|
177
|
+
npm run build:wasm
|
|
178
|
+
|
|
179
|
+
# Build TypeScript
|
|
180
|
+
npm run build:ts
|
|
181
|
+
|
|
182
|
+
# Full build
|
|
183
|
+
npm run build
|
|
184
|
+
|
|
185
|
+
# Run tests
|
|
186
|
+
npm test
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Requirements:
|
|
190
|
+
- Node.js 16+
|
|
191
|
+
- Rust toolchain
|
|
192
|
+
- wasm-pack
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
MIT © Pixagram SA
|
package/dist/index.d.mts
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 };
|