1use std::fs::File;
2use tileline::{tile, Config, Element, ElementLink, Rgb};
3
4struct Value(Rgb, Rgb);
5
6impl Value {
7 fn new(
8 background: &str,
9 border: &str,
10 ) -> std::result::Result<Self, Box<dyn std::error::Error>> {
11 Ok(Self(
12 Rgb::from_hex_str(background)?,
13 Rgb::from_hex_str(border)?,
14 ))
15 }
16}
17
18impl Element for Value {
19 fn get_color(&self) -> Rgb {
20 self.0.clone()
21 }
22
23 fn get_border_color(&self) -> Rgb {
24 self.1.clone()
25 }
26
27 fn get_link(&self) -> Option<Box<dyn ElementLink>> {
28 None
29 }
30}
31
32fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
33 let mut val = Vec::new();
34 val.push(
35 vec![
36 Value::new("#009ECE", "#644436")?,
37 Value::new("#FF9E00", "#218559")?,
38 Value::new("#F7D708", "#4EB5D6")?,
39 ]
40 .into_iter(),
41 );
42 val.push(
43 vec![
44 Value::new("#aaaaaa", "#274257")?,
45 Value::new("#CE0000", "#2A75A9")?,
46 Value::new("#9CCF31", "#8F6048")?,
47 ]
48 .into_iter(),
49 );
50
51 let config = Config::new().offset_x(10).offset_y(10).build();
52 let mut out = File::create("./target/logo.svg")?;
53 tile(config.clone(), val.into_iter(), &mut out).unwrap();
54 Ok(())
55}