Egui::Svg
Inherits Egui::Widget < Reference < Object
Constants
Default currentColor resolution (the parse argument below).
Fit the intrinsic size into rect (aspect preserved,
centered) and replay the art as one textured quad.
The raster texture is software-baked ONCE per (source, tint, pixel size) with anti-aliasing (MAX_RASTER_SIZES bounds the bakes per icon so a size slider evicts the oldest instead of accumulating). Raster and quad are DERIVED from each other: bake at whole physical pixels, then draw the quad at exactly that many pixels, snapped to the pixel grid — a 1:1 texel-to-pixel mapping samples without resampling blur. This is why fonts are crisp: they rasterize at their exact ppem and land 1:1. (A quad of 44.2 px sampling a 45-texel raster smears every texel into its neighbor — the "soapy icon" look.)
Global budget across ALL Svgs (GPU memory + the sokol image pool): past it the oldest bake is destroyed FIFO — scrolled-away icons re-bake on return (~a millisecond each), memory stays bounded whatever the app does. Sized to hold the full lucide set (~1850) plus headroom: sokol frees destroyed image slots a few frames LATE, so a budget below the working set makes rapid eviction churn exhaust the pool even with the cap respected (the LUCIDE_NO_CULL stress lesson).
Constructors
From a file on disk (e.g. assets/icon.svg).
current_color resolves currentColor in the source (icon
sets are monochrome; pass the theme fg here).
Class methods
Optional primary rasterizer: (source, tint, w, h) → straight-alpha RGBA8 bytes, or nil to use NanoSvgCr. backend/ sokol.cr installs the C NanoSVG shim here in DEV builds only (no --release): the C code is cc -O2 regardless of Crystal's flags, while the port's hot loops are 10-100x slower unoptimized — the release build stays pure Crystal.
Optional primary rasterizer: (source, tint, w, h) → straight-alpha RGBA8 bytes, or nil to use NanoSvgCr. backend/ sokol.cr installs the C NanoSVG shim here in DEV builds only (no --release): the C code is cc -O2 regardless of Crystal's flags, while the port's hot loops are 10-100x slower unoptimized — the release build stays pure Crystal.