
The core GLORP algorithm. It analyzes color adjacency to build complex, multi-anchor SVG paths using greedy meshing optimization. Version 4.0.0 improves vertex merging for even cleaner vector outputs.
Exact 1:1 pixel-to-rect representation. In v4.0.0, we've implemented a performance detection overlay that warns you before generating heavy SVGs, preventing browser lag on massive grids.
Input raster is read into a dense uint32 grid where each cell encodes RGBA. Fully transparent pixels are ignored during meshing. This compact layout enables vectorization algorithms to operate directly on a single numeric matrix for cache- and SIMD-friendly operations.
Using a two-pass discrete edge-finder we construct horizontal and vertical edge maps. Edge types are encoded as directional markers (clockwise / anticlockwise) which the path extractor consumes to produce closed contours without redundant vertices.
The engine performs greedy scans that consolidate adjacent runs of matching edges into compact path commands (hN / vN). This minimizes SVG node count by merging collinear runs and eliminating one-pixel noise through simple heuristics.
Contour traversal is implemented with boundary checks and fallbacks to prevent out-of-bounds access on irregular shapes. The browser engine simulates performance limits and warns before emitting extremely large vectors to protect the UI thread.
Lossless WebP export path preserves alpha and applies browser-native encoding via canvas.toDataURL('image/webp'). This path is used when the user prefers raster output over vector conversion.
Files are queued in a lightweight drawer and processed sequentially inside a Pyodide worker context. Downloads are triggered per-file; the engine clears its queue after completion and restores scroll behavior reliably across devices.