pub enum Generator {
Fill {
paint: Paint,
},
Shapes {
items: Vec<ShapeItem>,
},
Text {
text: String,
style: TextStyle,
},
Layout {
root: Box<LayoutNode>,
},
}Expand description
The picture of a generated source.
A generated picture has the canvas’s size and aspect, like a source that
fills the frame at scale 1. Positions are in its normalized space, (0, 0)
top-left to (1, 1) bottom-right; lengths (radii, stroke widths) are
fractions of its shorter side, so the picture is the same at any render
resolution. A fill or text does not change over time (a clip animates it
with its transform, effects, and masks); shapes and layouts may.
Variants§
Fill
Paint over the whole picture.
Shapes
Shapes drawn from an ordered content tree, as an After Effects shape layer or a Lottie shape layer draws them. Unlike the other generators, its picture changes over time: every value in the tree may be keyframed, in the picture’s time.
Text
Text on a transparent picture, laid out and placed by its style as a
caption track’s cues are: its size and wrapping width fractions of
the canvas, its anchor at style.position. The engine draws it with
the fonts its host registered.
Fields
text: StringThe text; \n starts a line. Non-empty, at most
MAX_TEXT_CONTENT_BYTES bytes.
style: TextStyleHow it looks and where it lies. The font size is at most
MAX_TEXT_GENERATOR_FONT_SIZE.
Layout
Boxes laid out by CSS flexbox around their text and shapes. Its
picture changes over time when any value in the tree is keyframed,
in the picture’s time. The engine lays it out with the fonts it
draws with. See LayoutNode.
Fields
root: Box<LayoutNode>The root box: the whole picture.
Implementations§
Source§impl Generator
impl Generator
Sourcepub fn validate(&self) -> Result<(), GeneratorIssue>
pub fn validate(&self) -> Result<(), GeneratorIssue>
Checks every field. A shapes or layout generator’s problem names
where in its tree it lies; another generator’s is
GeneratorIssue::Invalid. A layout’s pixel font sizes are not
held to the limit here: that takes the canvas (Self::validate_on).
§Errors
Returns the first problem, if any.
Sourcepub fn validate_on(&self, width: u32, height: u32) -> Result<(), GeneratorIssue>
pub fn validate_on(&self, width: u32, height: u32) -> Result<(), GeneratorIssue>
Self::validate for a generator drawn on a width by height
canvas, which a layout’s pixel lengths are pixels of.
§Errors
Returns the first problem, if any.