Skip to main content

Module scene

Module scene 

Source
Expand description

What a resolved design is, and how one becomes the next. A Scene is a tree of Nodes — each with its own attributes, colours in both Themes, and an id that survives saves — with the image and font files it shows, read through the Files port. An Edit names its nodes by id; Edits are a list of them with the files they bring, and applying them (apply) is all or nothing, undone on a refusal, at the cost of the edits alone. Applied says what they did, for a drawing kept beside the scene to follow.

It is what every other part of the engine speaks: [crate::resolve] makes scenes and their edits, crate::render draws them, and crate::wire carries both to the browser.

Structs§

Applied
What edits did, by id, for a drawing kept beside the scene to follow: the subtrees that left their place — removed, or moved away — the subtrees placed — inserted, or moved here — and the nodes that kept their place and took new own attributes, with the ones they had.
Color
A color in a scene: its value in each theme. A color written as #… has the same value in both; theme.name has the themes’ two.
Edits
Edits with the image and font files they bring: everything that takes a scene to the next. Of the files, only those the scene before didn’t hold — each travels once.
Ids
Where each node of a scene is, by its id: what a patch finds its nodes by.
Image
An Image’s file: its address in the served folder and which ImageFile in the scene it shows.
ImageFile
A decoded image file: its bytes, its own size, and the pixels it is drawn from — the file’s own, or resampled to at most MAX_IMAGE_SIDE a side.
ImageId
An image file’s identity: the SHA-256 of its bytes. Two Images showing the same bytes — the same file used twice, or two copies of it — share one ImageFile, decoded once and sent once.
Node
One node of a scene.
Origin
Where an attribute was written, for a problem found only once the design is laid out and painted. It is never part of what a node draws: two nodes that differ only in it are equal, and it doesn’t travel on the wire.
Rgba
One color’s value: straight-alpha RGBA.
Scene
A resolved design: its tree, each distinct image file its Images show and font file its texts are set in, and whether it is themed — whether any theme. reference reached its nodes.
Shadow
TextStyle
Undo
What puts a scene back as it was before edits applied to it: each step undone, last first, the files they let go held again, and whether it was themed.
Uses
How many nodes of a scene show each image file and are set in each font file: what lets edits drop the files no node uses any more without walking the scene.
Vector
A Vector’s path and the box of path coordinates it is drawn from.

Enums§

Align
Edit
One step from a scene to the next, naming its nodes by id.
Fill
How a box is filled: one color, or a CSS-style linear gradient.
Kind
Layout
Size
TextAlign
Theme
Which of a design’s two themes it is drawn in.

Constants§

MAX_IMAGE_SIDE
The most pixels a side an image is drawn from. The GPU keeps every image a drawing paints in one atlas of crate::atlas::SIDE pixels a side, so a larger file is resampled to fit this, keeping its aspect, when it is decoded — and both backends draw those same pixels.

Traits§

Files
Reads a design’s files by their path from the top of the served folder.
Holder
Where a design’s one scene is held: what resolving it again reads the scene from, and brings it across by — by edits applied to it there, once, and to whatever is kept beside it, like a drawing.

Functions§

applied
apply, and what puts the scene back as it was before them, at their cost again: for a holder that finds only after applying them that the scene they made can’t be drawn, and draws the one before.
apply
Applies edits to scene, whose files uses counts, or says why it can’t — leaving both as they were. The work is the edits’: each finds its nodes by id, and the files no node uses any more are dropped by count, never by a walk of the scene.
decode
A PNG or JPEG file’s pixels, as straight-alpha RGBA, or why it has none.
fit
rgba, width × height, resampled to at most max pixels a side with its aspect kept, or as it is when it already fits. Each new pixel is the area-weighted average of the pixels under it, in premultiplied alpha so a transparent pixel lends no color.
listed
The names of the files directly in folder, from every path a store holds — None when it holds none there.
subtree
The edits that turn the subtree of old at at — whose root has the id new’s root has — into new: what a part of a scene resolved again is brought across by, costing that part alone.

Type Aliases§

ImageFiles
A scene’s image files by id, each decoded once however many Images show it.