Compiling#

The compiler itself. Source or IR in, Panel Core out.

Every entry point takes the same two optional keyword arguments – library and metrics – so the character set and the font are both injectable, and neither is read from the environment.

scenet.pipeline#

The compiler: source through IR to Panel Core.

Each stage is separable and independently testable, which is the point of having tiers at all. The frontend never computes a coordinate, the solver never touches artwork, and the emitter never makes a layout decision.

scenet.pipeline.CompileNoteRule#

What each kind of compile note is called: a stable name, as a check’s rule has one, by which a gallery entry’s notes: declares it while the sentence stays free to be reworded. One name per sentence; scenet.diagnostics.COMPILE_NOTES explains each, and the diagnostics reference gives each an entry.

alias of Literal[‘camera-retreated’, ‘curved-tail’, ‘cropped-mouth’, ‘cropped-marks’, ‘inset-covers-face’, ‘slant-cuts-face’, ‘italic-stand-in’, ‘bold-italic-stand-in’]

scenet.pipeline.PRESERVE_ASPECT_RATIO: dict[Fit, Literal['xMidYMid slice', 'xMidYMid meet']] = {Fit.CONTAIN: 'xMidYMid meet', Fit.COVER: 'xMidYMid slice'}#

A fit, as SVG’s preserveAspectRatio says it.

scenet.pipeline.DOCUMENT_LOADERS = {'.script': <function _load_script_document>, '.yaml': <function load_scene_document>, '.yml': <function load_scene_document>}#

The same extensions, read as whole documents – panels and the pages they go on.

scenet.compose#

Sparse override between panels.

Borrowed from OpenUSD’s composition arcs, and specifically from over: a panel names a parent and states only what differs from it.

This matters more for comics than it might look. Consecutive panels in a scene are mostly identical – the same cast, the same staging, the same camera – with one thing changed. Restating all of it per panel is both tedious and a place for inconsistencies to creep in, which is exactly the continuity error comics readers notice.

panels:
  p1:
    camera: {shot: medium_shot}
    cast:
      alice: {reference: alice, at: left_third}
  p2:
    over: p1                      # everything from p1...
    camera: {shot: close_up}      # ...except the framing

Taking something away is JSON Merge Patch’s rule (RFC 7386): “If the value is null, remove”. cast: {bob: null} leaves Bob out of a panel that would otherwise inherit him.

class scenet.compose.Dropped[source]#

Bases: object

A staging relation that named somebody a panel left out.

index#

Where it stood in the panel’s staging, as inherited.

Type:

int

relation#

The relation, as written.

Type:

object

actor#

Who it named that is not in the panel.

Type:

str

__init__(index, relation, actor)#
scenet.compose.looks_toward(relation, actor, leaving)[source]#

Whether a relation is somebody still drawn looking at an actor who is not.

Return type:

bool

scenet.compose.merge(base, override)[source]#

Deep-merge override onto base, with override winning.

Mappings merge recursively so that changing one actor’s pose leaves the rest of the cast alone. Lists replace wholesale rather than concatenating: script and staging are ordered wholes, and appending to an inherited script would make it impossible to write a panel where somebody says less than in the panel before.

A null is kept, not applied: it has to remove the key from whatever the document is merged over next as well – a scene’s defaults come last – so it is settle, once the document is whole, that takes it out.

Return type:

dict[str, Any]

scenet.compose.names(relation, actor)[source]#

Whether a staging relation, as written, names an actor as subject or object.

Return type:

bool

scenet.compose.on_their_side(event, cast)[source]#

An off-panel line with no side named, given the side its speaker was written at.

Return type:

object

scenet.compose.relation_text(relation)[source]#

A staging relation as a sentence, however it was written.

Return type:

str

scenet.compose.resolve_beneath(panels)[source]#

Every panel’s over chain resolved as if no null had been written in it.

What each removal takes away: whoever a panel leaves out, as they stood in the panels it is over, so a line they speak from off panel can end on their side (settle).

Return type:

dict[str, dict[str, Any]]

scenet.compose.resolve_overrides(panels)[source]#

Resolve every panel’s over chain into a self-contained document.

Panels are resolved lazily with memoisation, so a chain is walked once however many panels hang off it, and declaration order does not matter – a panel may inherit from one declared later.

Return type:

dict[str, dict[str, Any]]

scenet.compose.settle(document, *, beneath=None)[source]#

Apply the removals a complete document’s null values ask for.

Every key whose value is null goes, in mappings at any depth – not inside lists, which Merge Patch treats as values. A cast member who goes takes with them every staging relation that names them, since none can hold in a panel they are not in.

All but one kind, while they are heard from off panel in it, as a comic script’s CAROL (OP) has it: bob looking_at carol still holds, since Bob may look toward the side of the frame she is heard from. That side is the one she was written to stand on, at: left_third being the left, unless her line names one.

Parameters:
  • document (dict[str, Any]) – The panel, merged whole.

  • beneath (dict[str, Any] | None) – The same panel with no removal written (resolve_beneath): where whoever it leaves out stood. Without it, their lines are left as written.

Return type:

tuple[dict[str, Any], tuple[Dropped, ...]]

Returns:

The document, and the relations dropped, in the order they were written.

Example

>>> from scenet.compose import settle
>>> settled, dropped = settle({"cast": {"a": {}, "b": None}, "staging": ["a left_of b"]})
>>> settled, [item.actor for item in dropped]
({'cast': {'a': {}}, 'staging': []}, ['b'])