rectangle/
rectangle.rs

1use frug::{Color, Event, Instance, Keycode, 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    let rect_pos = Vec2d { x: 50, y: 50 };
8    let rect_size = Vec2d { x: 100, y: 70 };
9
10    'running: loop {
11        // Input
12        for event in frug_instance.get_events() {
13            match event {
14                // Quit the application
15                Event::Quit { .. }
16                | Event::KeyDown {
17                    keycode: Some(Keycode::Escape),
18                    ..
19                } => break 'running,
20                _ => {}
21            }
22        }
23
24        // Render
25        frug_instance.clear(background_color);
26        frug_instance.draw_rect(&rect_pos, &rect_size, Color::RGB(255, 0, 0));
27        frug_instance.present();
28    }
29}