compile_ir#
Import |
|
Defined in |
|
Install |
|
Since |
0.1 |
Stability |
Public: follows semantic versioning. Below 1.0, a minor release may change it, and the CHANGELOG says how. |
- scenet.pipeline.compile_ir(panel, *, library=None, metrics=None, base=None, lettering_height=None, exclusions=(), outline=None, staged_in=None, lettering_box=None, open_sides=())[source]#
Compile validated IR into Panel Core.
- Parameters:
panel (
PanelIR) – The validated panel.library (
PuppetLibrary|None) – Characters to draw from. Defaults to the two shipped puppets.metrics (
FontMetrics|None) – A regular face to measure lettering against, in place of the one the panel declares or the shipped one.base (
Path|Mapping[str,bytes] |None) – The folder the panel’s document is in, which the font files and the picture it declares are read from – or those files themselves, by the path it writes. Without one, a panel that names a file is refused.lettering_height (
float|None) – The height type sizes are a fraction of, instead of the panel’s own. A page passes the same value to every panel on it; a panel compiled on its own leaves it out. A panel that setslettering.sizeletters at that size instead, and this is not consulted.exclusions (
Sequence[BBox]) – Areas no balloon or caption may touch, in panel units, because something is drawn over them – on a page, the insets set into this panel. Nothing else moves for them: the art under an inset is drawn as usual.outline (
Sequence[tuple[float,float]] |None) – The panel’s border when it is not a rectangle – on a page, a panel in a slanted tier – in panel units. The panel is staged and framed in its bounding box as usual, and cropped to this; lettering stays inside it, a margin in.staged_in (
BBox|None) – For a panel that bleeds past the trim, the part of it the reader sees, in panel units: its cast is staged and framed there, as in a panel that size, so the trim never cuts a shot. Its art covers the whole panel.lettering_box (
BBox|None) – For a panel that bleeds, the box its lettering keeps inside, a margin in, in panel units: its frame as it was before bleeding.open_sides (
tuple[Side,...]) – For a panel that bleeds, the sides with no border.
- Return type:
- Returns:
The compiled panel, with the fonts it was lettered in.
- Raises:
PanelSyntaxError – Rule
font-file, for a declared font that cannot be read,image-file, for a picture,artwork-contract, for the contract beside a picture whose figures the panel casts,unknown-figure, for a figure the picture does not draw, orpuppet-file, for a puppet file a cast member names.
Note
The IR is taken as validated: build it with the frontends, or with the models’ own constructors, which validate as pydantic does. The keyword arguments after
baseare what laying out a page passes in; a single panel leaves them out.Deterministic: the same text, puppets and fonts give the same Core, byte for byte. A compile reads no file but those the document names, and those only from
baseor the folder ofsource; text with neither can name none. It is safe to call from several threads; see the Guarantees page for the caches they share.Example
>>> from scenet import CastMember, PanelIR, SayEvent, compile_ir >>> panel = PanelIR( ... cast={"a": CastMember(reference="alice")}, ... script=[SayEvent(by="a", text="Built in Python.")], ... ) >>> compile_ir(panel).core.balloons[0].lines ('Built in', 'Python.')
See also
PanelIR, the scene graph it compiles.parse_panel, to make one from text.Added in version 0.10: The
exclusionsparameter.Added in version 0.10: The
lettering_heightparameter.Added in version 0.10: The
outlineparameter.Added in version 0.11: The
baseparameter.Added in version 0.13: The
lettering_boxparameter.Added in version 0.13: The
open_sidesparameter.Added in version 0.13: The
staged_inparameter.