use quicksilver::{
geom::{Rectangle, Vector},
graphics::{Color, Graphics, Image},
run,
Input,
Result,
Settings,
Timer,
Window,
};
use silver_animation::SimpleLinearConfig;
fn main() {
run(
Settings {
size: Vector::new(800.0, 600.0),
title: "Simple Linear Example",
..Settings::default()
},
app,
);
}
async fn app(window: Window, mut gfx: Graphics, mut input: Input) -> Result<()> {
let i1 = Image::load(&gfx, "img1.png").await?;
let i2 = Image::load(&gfx, "img2.png").await?;
let i3 = Image::load(&gfx, "img3.png").await?;
let i4 = Image::load(&gfx, "img4.png").await?;
let images = [i1, i2, i3, i4].into();
let timing = Timer::time_per_second(8.);
let mut animation = SimpleLinearConfig { images, timing }.into_animation();
let location = Rectangle::new(Vector::new(200., 200.), Vector::new(200., 200.));
gfx.clear(Color::WHITE);
gfx.present(&window)?;
loop {
while input.next_event().await.is_some() {}
gfx.clear(Color::WHITE);
animation.draw(&mut gfx, location)?;
gfx.present(&window)?;
}
}