opui 0.1.0

A Rust library for stylish realtime 2D motion visuals and layered hero scenes.
Documentation
use macroquad::prelude::*;

use crate::scene::{FrameContext, Scene};

pub struct VisualApp<S> {
    scene: S,
    clear_color: Color,
}

impl<S> VisualApp<S>
where
    S: Scene,
{
    pub fn new(scene: S) -> Self {
        Self {
            scene,
            clear_color: color_u8!(6, 8, 18, 255),
        }
    }

    pub fn clear_color(mut self, color: Color) -> Self {
        self.clear_color = color;
        self
    }

    pub async fn run(mut self) {
        loop {
            let ctx = FrameContext::gather();
            clear_background(self.clear_color);
            self.scene.update(&ctx);
            self.scene.draw(&ctx);
            next_frame().await;
        }
    }
}