Purify Animation API and introduce application::timed

This commit is contained in:
Héctor Ramón Jiménez 2025-04-29 03:03:32 +02:00
parent 4334923add
commit 29a19fcde1
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
9 changed files with 281 additions and 104 deletions

View file

@ -8,7 +8,7 @@ use iced::window;
use iced::{Element, Fill, Point, Rectangle, Renderer, Subscription, Theme};
pub fn main() -> iced::Result {
iced::application(Arc::default, Arc::update, Arc::view)
iced::application(Arc::new, Arc::update, Arc::view)
.subscription(Arc::subscription)
.theme(|_| Theme::Dark)
.run()
@ -25,6 +25,13 @@ enum Message {
}
impl Arc {
fn new() -> Self {
Arc {
start: Instant::now(),
cache: Cache::default(),
}
}
fn update(&mut self, _: Message) {
self.cache.clear();
}
@ -38,15 +45,6 @@ impl Arc {
}
}
impl Default for Arc {
fn default() -> Self {
Arc {
start: Instant::now(),
cache: Cache::default(),
}
}
}
impl<Message> canvas::Program<Message> for Arc {
type State = ();