summaryrefslogblamecommitdiffstats
path: root/examples/svg/src/main.rs
blob: 27d175da7db07c64133b017b422351a2b8c63cef (plain) (tree)
1
2
3
4
5
6
7

                                               
 
                               


                                   





                        
             







                                         

                                                     

                                      
           


                              
                      

                                 
                        




                       
use iced::widget::{container, svg};
use iced::{Element, Length, Sandbox, Settings};

pub fn main() -> iced::Result {
    Tiger::run(Settings::default())
}

struct Tiger;

impl Sandbox for Tiger {
    type Message = ();

    fn new() -> Self {
        Tiger
    }

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

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

    fn view(&self) -> Element<()> {
        let svg = svg(svg::Handle::from_path(format!(
            "{}/resources/tiger.svg",
            env!("CARGO_MANIFEST_DIR")
        )))
        .width(Length::Fill)
        .height(Length::Fill);

        container(svg)
            .width(Length::Fill)
            .height(Length::Fill)
            .padding(20)
            .center_x()
            .center_y()
            .into()
    }
}