text/
text.rs

1use omage::colors::*;
2use omage::{Components, Config, Image, Rgba};
3
4const HEIGHT: u32 = 100;
5const WIDTH: u32 = 300;
6
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let config = Config::new(
9        WIDTH,
10        HEIGHT,
11        Rgba([255, 255, 255, 0]),
12        Some(WHITE),
13        "output.png",
14        Some("./fonts/Roboto-Medium.ttf"),
15    );
16
17    let mut image = Image::new();
18
19    let circle1 = Components::Circle(50, 55, 30, Rgba([255, 0, 0, 200]));
20    let circle2 = Components::Circle(75, 55, 30, Rgba([0, 255, 0, 200]));
21    let circle3 = Components::Circle(65, 35, 30, Rgba([0, 0, 255, 200]));
22
23    let text = "OMAGE";
24    let text = Components::Text(
25        config.width / 2 - 40,
26        config.height / 2 - 25,
27        50,
28        text,
29        Rgba([255, 255, 255, 255]),
30        Some((BLACK, 3)),
31    );
32
33    image
34        .config(config)
35        .init()?
36        .add_components(vec![&text, &circle1, &circle2, &circle3])
37        .draw()?;
38    Ok(())
39}