summaryrefslogtreecommitdiffstats
path: root/examples/solar_system
diff options
context:
space:
mode:
authorLibravatar shan <shankern@protonmail.com>2022-09-29 10:52:58 -0700
committerLibravatar shan <shankern@protonmail.com>2022-09-29 11:15:35 -0700
commit40f45d7b7e35dd4937abe6b5ce16b6256b4f1eeb (patch)
tree38ffc5dd6bae5da4da3b93664dfe27e024dfa261 /examples/solar_system
parent97f385e093711c269df315b28f76e66e0220e22a (diff)
downloadiced-40f45d7b7e35dd4937abe6b5ce16b6256b4f1eeb.tar.gz
iced-40f45d7b7e35dd4937abe6b5ce16b6256b4f1eeb.tar.bz2
iced-40f45d7b7e35dd4937abe6b5ce16b6256b4f1eeb.zip
Adds linear gradient support to 2D meshes in the canvas widget.
Diffstat (limited to 'examples/solar_system')
-rw-r--r--examples/solar_system/src/main.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs
index c59d73a8..fcd20561 100644
--- a/examples/solar_system/src/main.rs
+++ b/examples/solar_system/src/main.rs
@@ -19,6 +19,7 @@ use iced::{
};
use std::time::Instant;
+use crate::canvas::StrokeStyle;
pub fn main() -> iced::Result {
SolarSystem::run(Settings {
@@ -37,9 +38,9 @@ enum Message {
}
impl Application for SolarSystem {
+ type Executor = executor::Default;
type Message = Message;
type Theme = Theme;
- type Executor = executor::Default;
type Flags = ();
fn new(_flags: ()) -> (Self, Command<Message>) {
@@ -65,10 +66,6 @@ impl Application for SolarSystem {
Command::none()
}
- fn subscription(&self) -> Subscription<Message> {
- time::every(std::time::Duration::from_millis(10)).map(Message::Tick)
- }
-
fn view(&self) -> Element<Message> {
canvas(&self.state)
.width(Length::Fill)
@@ -86,6 +83,10 @@ impl Application for SolarSystem {
text_color: Color::WHITE,
})
}
+
+ fn subscription(&self) -> Subscription<Message> {
+ time::every(std::time::Duration::from_millis(10)).map(Message::Tick)
+ }
}
#[derive(Debug)]
@@ -178,8 +179,8 @@ impl<Message> canvas::Program<Message> for State {
frame.stroke(
&orbit,
Stroke {
+ style: StrokeStyle::Solid(Color::from_rgba8(0, 153, 255, 0.1)),
width: 1.0,
- color: Color::from_rgba8(0, 153, 255, 0.1),
line_dash: canvas::LineDash {
offset: 0,
segments: &[3.0, 6.0],