From dc51080328caa12d2b1fc02febc72cab70bb9f50 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 29 Apr 2020 04:25:49 +0200 Subject: Introduce `Cursor` type in `canvas` --- examples/solar_system/src/main.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'examples/solar_system') 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 canvas::Program for State { - fn draw(&self, bounds: Size) -> Vec { - use canvas::{Path, Stroke}; + fn draw( + &self, + bounds: Rectangle, + _cursor: Cursor, + ) -> Vec { 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 canvas::Program 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); -- cgit