PageCore#

Import

from scenet import PageCore

Defined in

scenet.core (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.

class scenet.core.PageCore[source]#

Bases: CoreModel

A fully resolved page: where every panel’s frame is.

The page tier of the same idea as PanelCore. It holds the frames and nothing drawn: each panel’s contents are its own Panel Core, compiled at its frame’s size, so a page adds no layout decision to a panel and a panel’s Core reads the same whether or not it is on a page.

format_version#

Bumped when the shape of this document changes incompatibly.

Type:

int

width#

Page width, in page units.

Type:

float

height#

Page height.

Type:

float

lettering_height#

The height every panel on the page took its type size from, in place of its own – so that a short panel and a tall one letter alike.

Type:

float

frames#

One per panel, in reading order: tier by tier, left to right, or right to left for a page read that way.

Type:

tuple[CoreFrame, ...]

direction#

Which way the page is read. Left out of the JSON for ltr, so every page written before it reads and writes as it always did.

Type:

Direction

bleed#

How far the printed sheet runs past the trim on every side, in page units. Left out of the JSON when 0, as direction is when ltr.

Type:

float

Example

>>> from scenet import PageCore, compile_book
>>> book = compile_book(
...     "cast: {a: {reference: alice}}\n"
...     "pages: [{tiers: [{panels: [one]}]}]\npanels: {one: {}}"
... )
>>> isinstance(book.pages[0], PageCore)
True
>>> [(f.panel, f.width) for f in book.pages[0].frames]
[('one', 1800.0)]

See also

render_page, to draw it. PanelCore, what each frame holds.

to_json()[source]#

Serialise deterministically, exactly as a Panel Core is.

Return type:

str

classmethod from_json(text)[source]#

Read a Page Core back in.

Parameters:

text (str) – A Page Core document.

Return type:

Self

Returns:

The parsed page.

Raises:

CoreSyntaxError – The text is not JSON, or not a Page Core. Also a ValueError.