mod render;
use crate::Error;
use crate::import;
use crate::schema::Animation;
use std::collections::HashMap;
use std::ops::Range;
#[cfg(feature = "vello")]
mod vello;
pub mod model;
pub use render::{RenderSink, Renderer};
#[derive(Clone, Default, Debug)]
pub struct Composition {
pub frames: Range<f64>,
pub frame_rate: f64,
pub width: usize,
pub height: usize,
pub assets: HashMap<String, Vec<model::Layer>>,
pub layers: Vec<model::Layer>,
}
impl Composition {
pub fn from_slice(source: impl AsRef<[u8]>) -> Result<Composition, Error> {
let source = Animation::from_slice(source.as_ref())?;
let composition = import::conv_animation(source);
Ok(composition)
}
pub fn from_json(v: serde_json::Value) -> Result<Composition, Error> {
let source = Animation::from_json(v)?;
let composition = import::conv_animation(source);
Ok(composition)
}
}
impl std::str::FromStr for Composition {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let source = Animation::from_str(s)?;
let composition = import::conv_animation(source);
Ok(composition)
}
}