Package limn.graphics
Interface SvgRasterizer
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
SPI that rasterizes SVG icon bytes to an
Image. The backend installs a
NanoSVG-based rasterizer at startup (via SvgIcon.installRasterizer(limn.graphics.SvgRasterizer));
headless tests can inject a fake. No AWT: the impl lives in the LWJGL backend.-
Method Summary
-
Method Details
-
rasterize
RasterizessvgBytesto fit apixelSize×pixelSizebox, preserving aspect ratio. The result is straight-alpha RGBA8 (row 0 at top); draw it with a tint (Canvas.drawImage(Image, float, float, float, float, Color)) to recolor the shape per theme, or without a tint to keep the SVG's own colors.Called from any thread, including several at once. It runs on the UI thread inside a paint and on the worker pool from
SvgIcon.imageAsync(int), which is the whole reason that asynchronous form can exist, so an implementation must be pure CPU: no GL, no window, and no mutable state shared between calls unless it is synchronized.svgBytesis read, never written: a parser that needs a NUL-terminated or otherwise altered buffer must copy it, because the caller reuses the same array for every size.
-