ictdesigntools.draw.svg¶
SVG output, with the standard library only.
Shapes carry their Meta as data-id, data-kind and data-<key> attributes and
their titles as <title> (hover text and an accessible name), so a page can make parts
interactive with a small script and no framework. Components are written once in <defs>
and placed with <use>. Nothing is styled inline, so the SVG works under a strict
Content-Security-Policy.
to_svg ¶
to_svg(
drawing: Drawing,
css_class: str = "",
standalone: bool = False,
theme: dict[str, Style] | None = None,
id_prefix: str = "",
classes: bool = False,
class_prefix: str = "d-",
interactive: bool = False,
) -> str
The drawing as an <svg> element.
standalone adds the namespace and a physical size for a file; id_prefix keeps
component ids unique when a page holds several drawings; theme overrides named styles.
classes also gives every shape with a named style the class <class_prefix><name>, so
a page's stylesheet can restyle it (a dark theme, a highlight) over the colours written as
attributes, which stay as the fallback. interactive marks the drawing for the optional
script (interactive_script()): hover, select, keyboard focus and a draw:select
event for parts that carry a Meta id.
Source code in src/ictdesigntools/draw/svg.py
svg_file ¶
A standalone SVG file, at full size in the drawing's units.
Source code in src/ictdesigntools/draw/svg.py
meta_attrs ¶
data- attributes for a part's meta.