render_pages#

Import

from scenet import render_pages

Defined in

scenet.emit.page (source)

Install

pip install scenet

Since

0.10

Stability

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

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

Render every page side by side, as one SVG document.

What a single view shows – the playground’s, for one. Each page sits in a group page-<n>, and panel positions count on across pages, so every id in the document stays unique.

Parameters:
  • pages (Sequence[PageCore]) – The pages, in order.

  • panels (Mapping[str, PanelCore]) – Every panel’s compiled Core, by name.

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

  • debug (bool) – Place each panel’s diagnostic overlay instead of the panel.

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

  • aria (bool) – Make the document a named group of pages, each a named group of panels a screen reader reads in order. False writes none of 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:

Every page, side by side, as SVG – left to right, or for pages read right to left, from the right, as a manga’s spread opens. They are written in reading order.

Raises:

RenderError – There are no pages, a page places a panel panels does not hold, a Core names a font not given as fonts, a picture is to be embedded and its bytes are not in embed, or the pages are not all read the same way.

Note

The spread opens as the pages are read: from the right for pages read right to left.

Example

>>> from scenet import compile_book, render_pages
>>> book = compile_book(
...     "cast: {a: {reference: alice}}\n"
...     "panels: {one: {}, two: {}}\n"
...     "pages: [{tiers: [{panels: [one]}]}, {tiers: [{panels: [two]}]}]"
... )
>>> cores = {name: result.core for name, result in book.panels.items()}
>>> render_pages(book.pages, cores, fonts=book.fonts).splitlines()[0]
'<?xml version="1.0" encoding="UTF-8"?>'

See also

render_page, for one page.

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.