diff options
Diffstat (limited to '')
| -rw-r--r-- | examples/arc/src/main.rs | 53 | 
1 files changed, 17 insertions, 36 deletions
diff --git a/examples/arc/src/main.rs b/examples/arc/src/main.rs index 6a68cca1..4576404f 100644 --- a/examples/arc/src/main.rs +++ b/examples/arc/src/main.rs @@ -1,20 +1,17 @@  use std::{f32::consts::PI, time::Instant}; -use iced::executor;  use iced::mouse;  use iced::widget::canvas::{      self, stroke, Cache, Canvas, Geometry, Path, Stroke,  }; -use iced::{ -    Application, Command, Element, Length, Point, Rectangle, Renderer, -    Settings, Subscription, Theme, -}; +use iced::{Element, Length, Point, Rectangle, Renderer, Subscription, Theme};  pub fn main() -> iced::Result { -    Arc::run(Settings { -        antialiasing: true, -        ..Settings::default() -    }) +    iced::program("Arc - Iced", Arc::update, Arc::view) +        .subscription(Arc::subscription) +        .theme(|_| Theme::Dark) +        .antialiasing(true) +        .run()  }  struct Arc { @@ -27,30 +24,9 @@ enum Message {      Tick,  } -impl Application for Arc { -    type Executor = executor::Default; -    type Message = Message; -    type Theme = Theme; -    type Flags = (); - -    fn new(_flags: ()) -> (Self, Command<Message>) { -        ( -            Arc { -                start: Instant::now(), -                cache: Cache::default(), -            }, -            Command::none(), -        ) -    } - -    fn title(&self) -> String { -        String::from("Arc - Iced") -    } - -    fn update(&mut self, _: Message) -> Command<Message> { +impl Arc { +    fn update(&mut self, _: Message) {          self.cache.clear(); - -        Command::none()      }      fn view(&self) -> Element<Message> { @@ -60,16 +36,21 @@ impl Application for Arc {              .into()      } -    fn theme(&self) -> Theme { -        Theme::Dark -    } -      fn subscription(&self) -> Subscription<Message> {          iced::time::every(std::time::Duration::from_millis(10))              .map(|_| Message::Tick)      }  } +impl Default for Arc { +    fn default() -> Self { +        Arc { +            start: Instant::now(), +            cache: Cache::default(), +        } +    } +} +  impl<Message> canvas::Program<Message> for Arc {      type State = ();  | 
