Skip to main content

collect_svg

Function collect_svg 

Source
pub fn collect_svg(
    snapshot: &DomSnapshot,
    svg_id: NodeId,
    color_scheme: ColorScheme,
    text_color: Color,
) -> Option<SvgContent>
Expand description

Collects the inline SVG content of an <svg> element: its viewBox and the solid-color shapes of its content, recursively.

Container elements (g, a, symbol) are walked with their transform and opacity attributes composed down the tree. path/rect/circle/ ellipse become SvgShapes whose paths are pre-transformed into viewBox space, so emit_commands only maps the viewBox onto the content box. text_color is the <svg> element’s computed CSS color, used to resolve fill="currentColor". Returns None when the element has no usable viewBox or no paintable subpaths.