render_strip#

Import

from scenet import render_strip

Defined in

scenet.emit.strip (source)

Install

pip install scenet

Since

0.1

Stability

Public: follows semantic versioning. Below 1.0, a minor release may change it, and the CHANGELOG says how.

scenet.emit.strip.render_strip(panels, *, live_text=False, debug=False, fonts=None, aria=True, embed=None, mono=False)[source]#

Lay panels side by side in reading order: left to right, or right to left.

Each panel is rendered independently and then placed, rather than being re-solved: a panel’s composition must not depend on what sits beside it, or the same source would compile differently in isolation. Panels read right to left are laid from the right; they are still written in reading order, which is the order a screen reader follows.

Parameters:
  • panels (list[tuple[str, PanelCore]]) – Panel name and compiled core, in reading order.

  • live_text (bool) – Emit lettering as <text> rather than glyph outlines.

  • debug (bool) – Place each panel’s diagnostic overlay instead of the panel itself, in exactly the same positions, so a sequence can be debugged as a sequence. live_text does not apply: the overlay labels in plain text already.

  • fonts (Mapping[str, FontMetrics] | None) – The declared fonts the panels were lettered in, by digest – what Book.fonts holds.

  • aria (bool) – Make the strip a named group of panels, each one image a screen reader reads whole, in reading order; its background hidden. False writes none of it. An overlay is a diagnostic, and never has it.

  • embed (Mapping[str, bytes] | None) – The supplied pictures’ bytes, by digest – what Book.images holds – to write into the SVG. Left out, each picture is linked by the path its document wrote.

  • mono (bool) – Draw every value as its grey and ignore its colour, as for a black-and-white edition. Every decision was made on the grey, so this draws exactly what palette: mono would; see PanelCore.as_mono.

Return type:

str

Returns:

One SVG document holding every panel.

Raises:

RenderError – There are no panels, or they are not all read the same way.

Note

Panels are scaled to one height and set side by side in the order given – from the right when they are read right to left. A strip is not a page: it has no trim.

Example

>>> from scenet import compile_scene, render_strip
>>> panels = compile_scene("cast: {a: {reference: alice}}\npanels: {one: {}, two: {}}")
>>> strip = render_strip([(name, result.core) for name, result in panels.items()])
>>> strip.splitlines()[0]
'<?xml version="1.0" encoding="UTF-8"?>'

See also

render_pages, for panels laid out on pages.

Added in version 0.7: The debug parameter.

Added in version 0.11: The fonts parameter.

Added in version 0.12: The aria parameter.

Added in version 0.12: The embed parameter.

Added in version 0.13: The mono parameter.