#![no_std]
use core::time::Duration;
use rattles::presets::prelude as presets;
fn using_ticked() {
let mut rattle = presets::dots().into_ticked();
for _ in 0..8 {
let _frame = rattle.current_frame();
rattle.tick();
}
}
struct UserClock {
elapsed_ms: u64,
}
impl UserClock {
fn new() -> Self {
Self { elapsed_ms: 0 }
}
fn elapsed(&self) -> Duration {
Duration::from_millis(self.elapsed_ms)
}
fn tick_ms(&mut self, delta_ms: u64) {
self.elapsed_ms += delta_ms;
}
}
fn using_user_clock() {
let rattle = presets::dots();
let mut clock = UserClock::new();
for _ in 0..8 {
let elapsed = clock.elapsed();
let _frame = rattle.frame_at(elapsed);
clock.tick_ms(80);
}
}
fn using_frame_index() {
let rattle = presets::dots();
for i in 0..8 {
let _frame = rattle.frame(i);
}
}
fn main() {
using_ticked();
using_user_clock();
using_frame_index();
}