Expand description
SVG loading and rendering for Blinc
This crate provides SVG file loading and conversion to Blinc drawing primitives.
It uses usvg for parsing and simplification of SVG files.
§Rendering Modes
§Tessellation (Legacy)
Converts SVG paths to triangles via Lyon tessellation. Fast but produces aliased edges on thin strokes.
§Rasterization (Recommended)
Uses resvg for high-quality CPU rasterization with proper anti-aliasing.
Produces pixel-perfect output that can be uploaded as GPU textures.
§Example
ⓘ
use blinc_svg::{SvgDocument, RasterizedSvg};
// Tessellation mode (legacy)
let svg = SvgDocument::from_file("icon.svg")?;
ctx.draw_svg(&svg, Point::new(10.0, 10.0), 1.0);
// Rasterization mode (recommended for icons)
let rasterized = RasterizedSvg::from_str(svg_str, 64, 64)?;
// Upload rasterized.data() to GPU textureStructs§
- Rasterized
Svg - Rasterized SVG image data
- SvgDocument
- A loaded and parsed SVG document
- SvgSub
Element - Metadata for an SVG sub-element with a non-empty ID. Used for CSS selector targeting of SVG internals.
Enums§
- SvgDraw
Command - A drawing command extracted from the SVG
- SvgError
- Errors that can occur when loading or rendering SVG files
Functions§
- extract_
element_ metadata - Extract metadata for all sub-elements with IDs from an SVG string.