summaryrefslogtreecommitdiffstats
path: root/examples/svg/src/main.rs
blob: 811fdfb5d52b07a45d821fd67f6fd2b35b7743ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use iced::{Column, Container, Element, Length, Sandbox, Settings, Svg};

pub fn main() {
    env_logger::init();

    Tiger::run(Settings::default())
}

#[derive(Default)]
struct Tiger;

impl Sandbox for Tiger {
    type Message = ();

    fn new() -> Self {
        Self::default()
    }

    fn title(&self) -> String {
        String::from("SVG - Iced")
    }

    fn update(&mut self, _message: ()) {}

    fn view(&mut self) -> Element<()> {
        let content = Column::new().padding(20).push(
            Svg::new(format!(
                "{}/resources/tiger.svg",
                env!("CARGO_MANIFEST_DIR")
            ))
            .width(Length::Fill)
            .height(Length::Fill),
        );

        Container::new(content)
            .width(Length::Fill)
            .height(Length::Fill)
            .center_x()
            .center_y()
            .into()
    }
}