neu_draw.vectorfile¶
A vector figure as a tree of named groups, and its two writers: SVG and PDF.
Needs only numpy and the standard library (and imageio, to encode an SVG’s embedded
PNGs); neu_draw.backends.vector builds the tree from a live view. Coordinates are
logical pixels, y down, one pixel per point. Colours are RGBA floats in 0-1, and both
formats composite opacity in sRGB.
Illustrator keeps named groups from the SVG, not the PDF: it opens a PDF it did not
write onto a single layer, while Acrobat shows the PDF’s nested optional content as a
layer tree. The SVG is therefore written for Illustrator’s importer: SVG 1.1,
xlink:href on images (a bare href leaves them blank), no clipPath wrapper, a
baseline offset instead of dominant-baseline, and group ids in Illustrator’s _xHH_
escaping, which it decodes back into layer names.
Attributes¶
Classes¶
Functions¶
|
|
|
The tree as a one-page PDF, each group a nested optional-content layer. |
|
The tree as SVG 1.1. Every group is a |
|
Write |
Module Contents¶
- class neu_draw.vectorfile.Markers¶
Many point markers of one shape and style, e.g. one drawable’s synapse set.
- shape: str¶
- size: float¶
- stroke_width: float = 0.0¶
- xy: numpy.ndarray¶
- class neu_draw.vectorfile.Segments¶
Independent line segments as one stroked path, e.g. a skeleton.
- cap: str = 'round'¶
- segments: numpy.ndarray¶
- width: float¶
- neu_draw.vectorfile.illustrator_id(name: str) str¶
namein Illustrator’s id escaping: anything but a letter, digit,-or.becomes_xHH_, as does a leading digit. Illustrator writes ids this way and decodes them on import, so the layer panel readsT4a 78044864 : Mi1 (17).
- neu_draw.vectorfile.to_pdf(root: Group, width: float, height: float) bytes¶
The tree as a one-page PDF, each group a nested optional-content layer.
- neu_draw.vectorfile.to_svg(root: Group, width: float, height: float) str¶
The tree as SVG 1.1. Every group is a
<g>with an Illustrator-style id and aninkscape:label; the top-level groups are marked as Inkscape layers too.
- neu_draw.vectorfile.write(root: Group, width: float, height: float, path: str) str¶
Write
.svgor.pdfby extension.
- neu_draw.vectorfile.BASELINE = 0.35¶
- neu_draw.vectorfile.FONT_FAMILY = "'Noto Sans', Helvetica, Arial, sans-serif"¶
- neu_draw.vectorfile.KAPPA = 0.5522847498¶
- neu_draw.vectorfile.RGBA¶
- neu_draw.vectorfile.Shape¶