PanelIR#

Import

from scenet import PanelIR

Defined in

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

class scenet.ir.PanelIR[source]#

Bases: Strict

A complete, validated panel: the language’s real definition.

Every frontend produces one of these and nothing else, which is what lets the YAML syntax and the comic-script syntax coexist without the solver knowing either exists. Nothing here carries a coordinate – computing those is the solver’s job, and keeping them out is what makes a panel reusable at any size.

Validation is strict and total: unknown keys are rejected, every actor id mentioned in staging or script must exist in cast, and the ordering relations must not contain a cycle. A misspelled key that was silently ignored would produce a panel that is subtly wrong with no indication of why, which for a language meant to be precise is the worst possible failure.

Example

>>> from scenet import PanelIR, parse_panel
>>> panel = parse_panel("panel: {size: [800.0, 600.0]}")
>>> isinstance(panel, PanelIR)
True
>>> panel.panel.width, panel.camera.shot.value
(800.0, 'medium_shot')

See also

compile_ir, to turn one of these into geometry.

description#

What the panel shows, in words, for a reader who cannot see it. Carried into the SVG as its accessible name and never interpreted. Not inherited: a panel drawn over: another is a different picture. Left out, one is generated from the shot, the setting and the cast.

Type:

str | None

direction#

Which way the comic is read: ltr from the top left, rtl from the top right, as manga are – panels, pages and the balloons in a panel. Its progression, not its text: the words in a balloon still read left to right. Written once for the whole document; the scene is never mirrored.

Type:

Direction

palette#

What the panel is drawn in: mono, the value ladder in grey, or tinted, each value in a colour with the same lightness. Colour never changes a value, so a tinted panel is, in monochrome, the mono one. Inherited like any default; a panel may have its own.

Type:

Palette

panel: PanelSpec#

The panel’s frame: its size and margin, in panel units.

camera: CameraSpec#

How the cast is framed: the shot, and the camera’s height.

setting: SettingSpec#

Where and when the panel happens: a named place, tonal masses or a picture behind the cast, with the time of day and the weather.

lettering: LetteringSpec#

How the lettering is set: the dialogue type size, and the font files.

cast: dict[str, CastMember]#

Who is in the panel: each actor id, chosen by the author, and the puppet that plays them or the figure a picture draws. Their order means nothing.

staging: tuple[Relation, ...]#

How the cast stand to each other, as sentences: alice left_of bob. One relation each.

script: tuple[SayEvent | CaptionEvent | SfxEvent | SayEvent | CaptionEvent | SfxEvent, ...]#

What is said and heard, in the order it is read: say for a balloon, caption for a box, sfx for a sound effect.

figures()[source]#

The cast members a supplied picture draws, and the figure each plays.

Example

>>> from scenet import parse_panel
>>> parse_panel("cast: {ana: {figure: ana_in_red}}").figures()
{'ana': 'ana_in_red'}
Return type:

dict[str, str]

puppets()[source]#

The cast members Scenet poses, and the puppet each is drawn by.

Return type:

dict[str, str]

property drawn_by_its_picture: bool#

Whether everybody in the cast is a figure the panel’s picture draws.

Then nothing is staged, the camera does not run, and the shot is whatever the artist drew.

ordering_constraints()[source]#

Normalised (left, right) pairs from both left_of and right_of relations.

Return type:

tuple[tuple[str, str], ...]

gaze_targets()[source]#

Who is looking at whom.

Return type:

dict[str, str]

Returns:

A mapping from each looking actor to the actor they are looking at. An actor may look at only one target, so a later looking_at relation for the same subject replaces an earlier one.

Example

>>> from scenet import parse_panel
>>> panel = parse_panel(
...     "{cast: {a: {reference: alice}, b: {reference: bob}},"
...     " staging: [a looking_at b]}"
... )
>>> panel.gaze_targets()
{'a': 'b'}
off_panel_speakers()[source]#

Who is heard from off panel, and the side each is heard from, if any line names one.

Return type:

dict[str, Side | None]

Returns:

Speaker to the first side a line of theirs names, or None when every line of theirs says only off_panel: true, in the order they first speak.

Example

>>> from scenet import parse_panel
>>> panel = parse_panel(
...     "{script: [{say: {by: carol, text: Hi, off_panel: true}},"
...     " {say: {by: carol, text: Here, off_panel: left}}]}"
... )
>>> panel.off_panel_speakers()
{'carol': <Side.LEFT: 'left'>}
ground_groups()[source]#

Actors joined by ground_shared_with, as connected components.

Union-find rather than pairwise handling, so that ‘a with b’ plus ‘b with c’ puts all three on one ground line without the author saying ‘a with c’.

Return type:

tuple[frozenset[str], ...]