vibesketch.render.vector

EPS and EMF figures for office documents, from the publication SVG (#96).

Word processors and slide programs take EMF (Windows Enhanced Metafile) and EPS as editable vector pictures. Both are written here from the same scene SVG the other formats come from, so a figure looks the same in every format: the SVG is reduced to filled and stroked paths, the text outlined from the bundled Roboto face (so no font is needed where the file is opened), and the paths written in each format. No converter or font is taken from the system.

Formats:

  • EPS: Adobe “Encapsulated PostScript File Format Specification” 3.0 and the PostScript Language Reference, 3rd ed.; one point is one PostScript unit.

  • EMF: Microsoft “[MS-EMF]: Enhanced Metafile Format”, records EMR_HEADER, EMR_EXTCREATEPEN, EMR_CREATEBRUSHINDIRECT, EMR_SELECTOBJECT, the path records and EMR_EOF; coordinates in twentieths of a point (a 1440 dpi reference device) and the frame in hundredths of a millimetre.

  • SVG elliptical arcs follow the SVG 1.1 implementation notes, appendix F.6, and are approximated by cubic Béziers of at most a quarter turn.

Module Attributes

Op

("M", p), ("L", p), ("C", c1, c2, p) or ("Z",).

Functions

emf(svg)

The figure as an Enhanced Metafile, text outlined, at its physical size.

eps(svg)

The figure as Encapsulated PostScript, text outlined, at its physical size.

paints(svg)

The figure's paths in drawing order, and its box (left, top, width, height) in points.

Classes

Paint(ops, fill, stroke[, width, evenodd, ...])

One path, filled and/or stroked, in figure points with y down.

class vibesketch.render.vector.Paint(ops, fill, stroke, width=1.0, evenodd=False, cap='butt', join='miter')[source]

Bases: object

One path, filled and/or stroked, in figure points with y down.

Parameters:
ops: list[tuple[object, ...]]
fill: tuple[float, float, float] | None
stroke: tuple[float, float, float] | None
width: float = 1.0
evenodd: bool = False
cap: str = 'butt'
join: str = 'miter'
vibesketch.render.vector.eps(svg)[source]

The figure as Encapsulated PostScript, text outlined, at its physical size.

Parameters:

svg (bytes)

Return type:

bytes

vibesketch.render.vector.emf(svg)[source]

The figure as an Enhanced Metafile, text outlined, at its physical size.

Parameters:

svg (bytes)

Return type:

bytes

vibesketch.render.vector.paints(svg)[source]

The figure’s paths in drawing order, and its box (left, top, width, height) in points.

Parameters:

svg (bytes)

Return type:

tuple[list[Paint], tuple[float, float, float, float]]