Documentation
¶
Index ¶
- func DisplayFont() []byte
- func Encode(tl Timeline, outPath string) error
- func EncodeWithOpts(tl Timeline, outPath string, opts EncodeOpts) error
- func Inspect(tl Timeline, step float64, out io.Writer) error
- func Interpolate(kfs []Keyframe, t float64) map[string]any
- func LoadScript(path string) (string, error)
- func RenderFrame(tl Timeline, t float64) *gg.Context
- func RenderSequence(tl Timeline, dir string) error
- func StdLib() fs.FS
- type AudioTrack
- type Builder
- type EncodeOpts
- type Entity
- type Group
- type Keyframe
- type Scene
- type Timeline
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisplayFont ¶
func DisplayFont() []byte
DisplayFont returns the bundled display typeface: Archivo Black, used for video titles (via --font or the font prop) and the preview UI's own headings. OFL licensed, see examples/assets/fonts/.
func Encode ¶
Encode renders tl and pipes raw RGBA frames to ffmpeg's stdin, which encodes out.mp4. Pixel format, size, and fps must match the flags exactly or the output corrupts — so failures report the exact command plus ffmpeg's own stderr instead of a bare exit code.
func EncodeWithOpts ¶
func EncodeWithOpts(tl Timeline, outPath string, opts EncodeOpts) error
EncodeWithOpts is Encode with explicit CRF/preset. Frames are painted by opts.Workers goroutines, then written to ffmpeg in frame order.
func Inspect ¶
Inspect prints sampled entity state and box overlaps as plain text. It runs no renderer and needs no ffmpeg; Build already validated the script, so this is a pure interpolation walk.
func Interpolate ¶
Interpolate returns the property set at time t (seconds). Numbers lerp linearly, hex colors lerp per channel, everything else snaps to the earlier keyframe. Out-of-range time holds the nearest end instead of extrapolating. Empty input returns an empty map.
func LoadScript ¶
LoadScript reads path plus its local `use "name"` dependencies (`name.lgv` beside the script; `std/` imports stay for Logos itself). Dependencies inline first, use-lines stripped, each file once — Go-side loading so Logos itself is never forked for multi-file scripts. A script with no local imports loads byte-identical apart from a trailing newline. Import cycles are an error, not infinite recursion.
func RenderFrame ¶
RenderFrame paints the frame at time t: find the active scene (or the single implicit scene when none were declared), crossfade across scene boundaries when a transition is set, and draw.
func RenderSequence ¶
RenderSequence renders every frame of tl into dir as frame_%04d.png: frame count is Duration*FPS, frame i sits at t=i/FPS. Zero-padded names keep alphabetical order equal to time order. Failures name the frame index so a bad keyframe is findable without re-running blind.
Types ¶
type AudioTrack ¶
AudioTrack lays one sound file under the video at Offset seconds. Loop repeats short sounds to the last frame instead of going silent.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder collects scene()/shape()/text() declarations out of a script. The script may compute and branch freely; only these calls populate the Timeline, everything else is ignored.
func (*Builder) Bind ¶
func (b *Builder) Bind(vm *interpreter.Interpreter)
Bind registers the declaration builtins on vm. Call before Run, then Build the Timeline after Run returns.
func (*Builder) Build ¶
Build returns the declared Timeline. A script with entities but no scene() has no header to render under, so that's an error. Scenes total their durations into Duration. Entities then pass fail-fast validation (kind/prop/group checks).
type EncodeOpts ¶
type EncodeOpts struct {
CRF int
Preset string
// Workers is the number of goroutines painting frames. Zero or
// negative means runtime.NumCPU(). Each worker owns one canvas.
Workers int
// Progress reports piped frames as (done, total), from the writer
// goroutine. done counts frames handed to ffmpeg in order, so the
// final call is always (total, total) — percent is done*100/total.
Progress func(done, total int)
}
EncodeOpts controls x264 quality. CRF 0-51 lower is better (18 high, 23 default, 28 small), Preset is speed/quality tradeoff: ultrafast..veryslow (medium default).
type Entity ¶
type Entity struct {
Name string
Kind string
Keyframes []Keyframe
Group string // optional group membership; empty means root
}
Entity is one drawable thing (circle, rect, text...). Kind names the renderer dispatch; Keyframes must be sorted by Time.
type Group ¶
Group is a transform container for children. Its keyframes hold x, y, scale, rotate, alpha, layer, and optional parent. Children are entities whose Group == Name; they keep local x/y and animate independently. A group with parent set nests inside that group, so world transform = parent * group * child.
type Keyframe ¶
Keyframe fixes an entity's properties at one moment in seconds. Props holds numbers (float64), colors (hex string), or discrete values (string) — interpretation lives in the interpolator. Ease names the curve of the segment starting here (see easeNames); empty means linear.
type Scene ¶
type Scene struct {
Name string
Duration float64
Entities []Entity
Groups []Group
Camera []Keyframe
Transition string
TransitionDur float64
}
Scene is one segment of a multi-scene timeline. Duration is the scene's own length in seconds (declared keyframes use scene-local times, offset to absolute at bind). Transition names the effect at the scene's start ("fade", "to-black", "push-left", ...; empty or "cut" = instant) and TransitionDur its length in seconds; zero uses the mode's default.
type Timeline ¶
type Timeline struct {
Duration float64
FPS int
Width int
Height int
Font string
Transparent bool
Entities []Entity
Groups []Group
Scenes []Scene
Audio []AudioTrack
// Camera holds x/y/zoom keyframes; empty means a locked frame.
// Used directly when there are no scenes; scenes carry their own.
Camera []Keyframe
}
Timeline is the full scene description: how long the video runs, at what frame rate, and every animated entity in it. Width/Height of zero mean the default canvas (CLI flags or scene defaults win). Empty Font means the built-in default typeface.
A script may declare one or more scenes; with scenes, each scene owns its entities/groups/camera (declared after its scene() call, times auto-offset to absolute) and Duration is the sum. Entities declared before any scene() are global and drawn in every scene.