Blyx Nest Blyx language
Registry / Framework
framework · v0.1.2

Animation Scrub

Fence asynchronous preview callbacks to the most recently selected animation frame.

Source repository · Package JSON

Use Animation Scrub

use vendor::animation_scrub::animation_scrub;

Run the example

nest demo animation_scrub@0.1.2
blyxc native-run animation_scrub-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::animation_scrub::animation_scrub;

fn main() {
    let arguments = cli_args();
    if args_len(arguments) > 0 {
        if args_len(arguments) % 2 != 0 {
            stderr_line("Expected event and value pairs");
            process_exit(2);
        }
        let mut live = animation_scrub_start();
        let mut i = 0;
        while i < args_len(arguments) {
            let input = args_at(arguments, i + 1);
            if !text_is_number(input) {
                stderr_line("Expected a whole numeric event value");
                process_exit(2);
            }
            live = animation_scrub_step(live, args_at(arguments, i), text_number(input));
            let command = animation_scrub_command(live);
            println!(command);
            if command == "reject" { process_exit(1); }
            i += 2;
        }
        return;
    }
    let mut state = animation_scrub_start();
    state = animation_scrub_step(state, "seek", 4.0);
    println!(animation_scrub_command(state));
    state = animation_scrub_step(state, "seek", 7.0);
    println!(animation_scrub_command(state));
    state = animation_scrub_step(state, "loaded", 4.0);
    println!(animation_scrub_command(state));
    state = animation_scrub_step(state, "loaded", 7.0);
    println!(animation_scrub_command(state));
    state = animation_scrub_step(state, "play", 0.0);
    println!(animation_scrub_command(state));
    state = animation_scrub_step(state, "pause", 9.0);
    println!(animation_scrub_command(state));
}

Expected output

request_frame
supersede_frame
reject
draw_frame
resume_timeline
freeze_frame

Published versions

VersionPackageSource commitSHA-256
0.1.2Download ZIP · Browse filesb9031fa07897e46231678afd349a983779d24507e487a5bcc61e127b3683789a1c381173a9
0.1.1Download ZIP · Browse filesc43566384d497c066b3200dbc25ad2997dba9b113e486f4cdbe3bf6003ca0e34e10f3eb62e
0.1.0Download ZIP · Browse files6349f237845ad04a884924f162a6bf9e162eda533ab75f223c2027966159bd275174f8e6d8