8 releases
| new 0.5.1 | Apr 13, 2026 |
|---|---|
| 0.5.0 | Apr 10, 2026 |
| 0.4.0 | Apr 5, 2026 |
| 0.1.15 | Mar 22, 2026 |
| 0.1.12 | Jan 19, 2026 |
#2111 in GUI
Used in 2 crates
(via blinc_app)
540KB
11K
SLoC
blinc_svg
Part of the Blinc UI Framework
This crate is a component of Blinc, a GPU-accelerated UI framework for Rust. For full documentation and guides, visit the Blinc documentation.
SVG loading and rendering for Blinc UI.
Overview
blinc_svg provides SVG parsing and rendering capabilities using usvg and resvg.
Features
- SVG Parsing: Full SVG support via usvg
- Two Render Modes:
- Tessellation: Fast, converts paths to triangles via Lyon
- Rasterization: High-quality CPU rendering via resvg
- Tinting: Apply color tints to SVGs
- Scaling: Render at any size
Quick Start
use blinc_svg::SvgDocument;
// Load SVG from file
let svg = SvgDocument::load("icon.svg")?;
// Load from string
let svg = SvgDocument::parse(r#"
<svg viewBox="0 0 24 24">
<path d="M12 2L2 7v10l10 5 10-5V7z"/>
</svg>
"#)?;
// Get dimensions
let (width, height) = svg.size();
Rasterization
use blinc_svg::RasterizedSvg;
// Rasterize at specific size
let rasterized = svg.rasterize(64, 64)?;
// Get pixel data
let pixels = rasterized.pixels();
let width = rasterized.width();
let height = rasterized.height();
Usage in Layout
use blinc_layout::prelude::*;
use blinc_icons::icons;
// SVG from string
svg(r#"<svg>...</svg>"#)
.size(24.0, 24.0)
// SVG from icon constant
svg(icons::CHECK)
.size(16.0, 16.0)
.color(Color::GREEN)
// Custom SVG file
svg_file("assets/logo.svg")
.size(100.0, 50.0)
Tinting
// Apply solid color tint
svg(icons::HEART)
.size(24.0, 24.0)
.color(Color::RED)
// SVGs are rendered with the tint color applied
// to all fill and stroke elements
Performance
For best performance:
- Use rasterization for complex SVGs displayed at fixed sizes
- Use tessellation for simple icons that scale dynamically
- Cache rasterized SVGs when displaying the same icon repeatedly
Architecture
blinc_svg
├── document.rs # SVG document parsing
├── rasterize.rs # CPU rasterization via resvg
├── tessellate.rs # Path tessellation via lyon
└── commands.rs # Drawing command generation
License
MIT OR Apache-2.0
Dependencies
~9–12MB
~154K SLoC