SVG
无需加载外部 SVG 资源即可渲染完整的内联 SVG 文档。
正在加载交互演示…
svg(Svg::from_bytes(ICON).expect("svg"))
.size(72.0, 72.0)
.text_color(Color::rgb8(37, 99, 235))#导入
从 quickgui 导入 Svg。
use quickgui::*;#用法
svg(Svg::from_bytes(ICON).expect("svg"))
.size(72.0, 72.0)
.text_color(Color::rgb8(37, 99, 235))#API 参考
展开条目查看说明和完整签名。短横线表示声明中未记录默认值。
Svg
查看源码pub fn from_bytes(source: impl AsRef<[u8]>) -> Result<Self, SvgError>Parse an SVG or SVGZ document from memory with strict source-size limits. System fonts are loaded lazily only when the document may contain a `<text>` element. External and embedded raster images are deliberately ignored, keeping parsing and rasterization bounded for UI icons.
from_svgpub fn from_svg(source: impl AsRef<str>) -> Result<Self, SvgError>—
Parse an SVG document from UTF-8 text.
pub fn from_svg(source: impl AsRef<str>) -> Result<Self, SvgError>查看源码openpub fn open(path: impl AsRef<Path>) -> Result<Self, SvgError>—
Read and parse an SVG or SVGZ file synchronously. Applications should call this during setup or on their own background executor rather than from latency-sensitive input handling.
pub fn open(path: impl AsRef<Path>) -> Result<Self, SvgError>查看源码widthpub fn width(&self) -> f32—
heightpub fn height(&self) -> f32—
sizepub fn size(&self) -> Size—
source_byte_lenpub fn source_byte_len(&self) -> usize—
svg
查看源码pub fn svg(source: impl Into<Svg>) -> ElementCreate a monochrome SVG element with intrinsic sizing and inherited text color.
