texture/
texture.rs

1use frug::{Color, Event, Instance, Keycode, LoadTexture, Vec2d};
2
3fn main() {
4    let mut frug_instance = Instance::new("Spritesheet Example", 800, 600);
5    let background_color = Color::RGB(100, 100, 150);
6
7    // load the spritesheet
8    let texture_creator = frug_instance.new_texture_creator();
9    let texture = match texture_creator.load_texture("examples/frog.png") {
10        Ok(image) => image,
11        Err(e) => {
12            eprintln!("Failed to load texture: {}", e);
13            return;
14        }
15    };
16
17    'running: loop {
18        // Input
19        for event in frug_instance.get_events() {
20            match event {
21                // Quit the application
22                Event::Quit { .. }
23                | Event::KeyDown {
24                    keycode: Some(Keycode::Escape),
25                    ..
26                } => break 'running,
27                _ => {}
28            }
29        }
30
31        // Render
32        frug_instance.clear(background_color);
33        frug_instance.draw_full_texture(
34            &texture,
35            &Vec2d { x: 200, y: 200 },
36            &Vec2d { x: 200, y: 200 },
37        );
38        frug_instance.present();
39    }
40}