diff options
author | 2023-05-11 09:12:06 -0700 | |
---|---|---|
committer | 2023-05-11 11:13:44 -0700 | |
commit | 6551a0b2ab6c831dd1d3646ecf55180339275e22 (patch) | |
tree | de1e4a85b3176f94fd006fed190ef035d3202e49 /examples/solar_system | |
parent | 669f7cc74b2e7918e86a8197916f503f2d3d9b93 (diff) | |
download | iced-6551a0b2ab6c831dd1d3646ecf55180339275e22.tar.gz iced-6551a0b2ab6c831dd1d3646ecf55180339275e22.tar.bz2 iced-6551a0b2ab6c831dd1d3646ecf55180339275e22.zip |
Added support for gradients as background variants + other optimizations.
Diffstat (limited to 'examples/solar_system')
-rw-r--r-- | examples/solar_system/Cargo.toml | 1 | ||||
-rw-r--r-- | examples/solar_system/src/main.rs | 21 |
2 files changed, 11 insertions, 11 deletions
diff --git a/examples/solar_system/Cargo.toml b/examples/solar_system/Cargo.toml index 835396b0..1a98a87e 100644 --- a/examples/solar_system/Cargo.toml +++ b/examples/solar_system/Cargo.toml @@ -7,4 +7,5 @@ publish = false [dependencies] iced = { path = "../..", features = ["canvas", "tokio", "debug"] } +env_logger = "0.10.0" rand = "0.8.3" diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs index f2606feb..42606e3f 100644 --- a/examples/solar_system/src/main.rs +++ b/examples/solar_system/src/main.rs @@ -10,9 +10,8 @@ use iced::application; use iced::executor; use iced::theme::{self, Theme}; use iced::widget::canvas; -use iced::widget::canvas::gradient::{self, Gradient}; use iced::widget::canvas::stroke::{self, Stroke}; -use iced::widget::canvas::{Cursor, Path}; +use iced::widget::canvas::{Cursor, Gradient, Path}; use iced::window; use iced::{ Application, Color, Command, Element, Length, Point, Rectangle, Renderer, @@ -22,6 +21,8 @@ use iced::{ use std::time::Instant; pub fn main() -> iced::Result { + env_logger::builder().format_timestamp(None).init(); + SolarSystem::run(Settings { antialiasing: true, ..Settings::default() @@ -208,15 +209,13 @@ impl<Message> canvas::Program<Message> for State { let earth = Path::circle(Point::ORIGIN, Self::EARTH_RADIUS); - let earth_fill = - Gradient::linear(gradient::Position::Absolute { - start: Point::new(-Self::EARTH_RADIUS, 0.0), - end: Point::new(Self::EARTH_RADIUS, 0.0), - }) - .add_stop(0.2, Color::from_rgb(0.15, 0.50, 1.0)) - .add_stop(0.8, Color::from_rgb(0.0, 0.20, 0.47)) - .build() - .expect("Build Earth fill gradient"); + let earth_fill = Gradient::linear( + Point::new(-Self::EARTH_RADIUS, 0.0), + Point::new(Self::EARTH_RADIUS, 0.0), + ) + .add_stop(0.2, Color::from_rgb(0.15, 0.50, 1.0)) + .add_stop(0.8, Color::from_rgb(0.0, 0.20, 0.47)) + .build(); frame.fill(&earth, earth_fill); |