1use frug::{create_text_texture, Color, Event, Instance, Keycode, TextureQuery, Vec2d};
2
3fn main() {
4 let mut frug_instance = Instance::new("Spritesheet Example", 800, 600);
5 let background_color = Color::RGB(70, 70, 100);
6
7 let texture_creator = frug_instance.new_texture_creator();
9 let ttf_context = frug_instance.new_ttf_context().unwrap();
10
11 let font_scale = 7.0;
13 let font_size = 8.0 * font_scale;
14 let text = "FRUG!";
15 let text_color = Color::RGB(100, 255, 100);
16
17 let font = match ttf_context.load_font("examples/PressStart2P-Regular.ttf", font_size) {
19 Ok(font) => font,
20 Err(e) => {
21 eprintln!("Failed to load font: {}", e);
22 return;
23 }
24 };
25
26 let text_texture = match create_text_texture(&font, text, &text_color, &texture_creator) {
28 Ok(texture) => texture,
29 Err(e) => {
30 eprintln!("Failed to create text texture: {}", e);
31 return;
32 }
33 };
34
35 let TextureQuery { width, height, .. } = text_texture.query();
37
38 'running: loop {
39 for event in frug_instance.get_events() {
41 match event {
42 Event::Quit { .. }
44 | Event::KeyDown {
45 keycode: Some(Keycode::Escape),
46 ..
47 } => break 'running,
48 _ => {}
49 }
50 }
51
52 frug_instance.clear(background_color);
54 frug_instance.draw_full_texture(
55 &text_texture,
56 &Vec2d { x: 50, y: 200 },
57 &Vec2d {
58 x: width,
59 y: height,
60 },
61 );
62 frug_instance.present();
63 }
64}