diff options
author | 2020-04-29 04:25:49 +0200 | |
---|---|---|
committer | 2020-04-29 04:25:49 +0200 | |
commit | dc51080328caa12d2b1fc02febc72cab70bb9f50 (patch) | |
tree | 0a9781223d1b78a8c404d57b17c61fb0136b196e /examples/solar_system | |
parent | 5586034d6626e013cdd718aca1c4f19f6a060ff3 (diff) | |
download | iced-dc51080328caa12d2b1fc02febc72cab70bb9f50.tar.gz iced-dc51080328caa12d2b1fc02febc72cab70bb9f50.tar.bz2 iced-dc51080328caa12d2b1fc02febc72cab70bb9f50.zip |
Introduce `Cursor` type in `canvas`
Diffstat (limited to 'examples/solar_system')
-rw-r--r-- | examples/solar_system/src/main.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs index e2f107bd..a25e43df 100644 --- a/examples/solar_system/src/main.rs +++ b/examples/solar_system/src/main.rs @@ -7,8 +7,9 @@ //! //! [1]: https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Basic_animations#An_animated_solar_system use iced::{ - canvas, executor, window, Application, Canvas, Color, Command, Element, - Length, Point, Settings, Size, Subscription, Vector, + canvas::{self, Cursor, Path, Stroke}, + executor, window, Application, Canvas, Color, Command, Element, Length, + Point, Rectangle, Settings, Size, Subscription, Vector, }; use std::time::Instant; @@ -132,11 +133,14 @@ impl State { } impl<Message> canvas::Program<Message> for State { - fn draw(&self, bounds: Size) -> Vec<canvas::Geometry> { - use canvas::{Path, Stroke}; + fn draw( + &self, + bounds: Rectangle, + _cursor: Cursor, + ) -> Vec<canvas::Geometry> { use std::f32::consts::PI; - let background = self.space_cache.draw(bounds, |frame| { + let background = self.space_cache.draw(bounds.size(), |frame| { let space = Path::rectangle(Point::new(0.0, 0.0), frame.size()); let stars = Path::new(|path| { @@ -151,7 +155,7 @@ impl<Message> canvas::Program<Message> for State { frame.fill(&stars, Color::WHITE); }); - let system = self.system_cache.draw(bounds, |frame| { + let system = self.system_cache.draw(bounds.size(), |frame| { let center = frame.center(); let sun = Path::circle(center, Self::SUN_RADIUS); |