pub struct Svg { /* private fields */ }Expand description
a parsed SVG document (immutable; render it as often as needed)
Implementations§
Source§impl Svg
impl Svg
Sourcepub fn parse(data: &[u8]) -> Result<Svg, i32>
pub fn parse(data: &[u8]) -> Result<Svg, i32>
parse an SVG document (UTF-8 XML; gzip data (.svgz) is inflated first): Err(ERR_HDR) when it is no SVG, ERR_LIMIT beyond the size limits
Sourcepub fn size(&self) -> (f64, f64)
pub fn size(&self) -> (f64, f64)
the intrinsic size in px (CSS px = DIP): width / height of the root, else its viewBox, else 300 x 150
Sourcepub fn truncated(&self) -> bool
pub fn truncated(&self) -> bool
the file ended early or a limit dropped elements (what was read is drawn)
Sourcepub fn element_count(&self) -> usize
pub fn element_count(&self) -> usize
the number of elements
Source§impl Svg
impl Svg
Sourcepub fn render(
&self,
sf: &mut Surface,
m: &Matrix,
clip: Option<[i32; 4]>,
opts: &mut Opts<'_>,
)
pub fn render( &self, sf: &mut Surface, m: &Matrix, clip: Option<[i32; 4]>, opts: &mut Opts<'_>, )
draw the document: its viewport (the intrinsic size, viewBox mapped by preserveAspectRatio) through m (intrinsic px -> surface px); clip: the surface rectangle x0, y0, x1, y1 (exclusive) that may change (None: all of it). Content outside the viewport is clipped (to its box under m). The surface: FMT_PARGB, or the window’s FMT_XRGB (blended the same way)