triangle/
triangle.rs

1#[qqx::qqx(polygon)]
2struct Vertex {
3    pos: qqx::Vec2 <f32>,
4    color: qqx::Color
5}
6
7fn main() {
8    let window = qqx::Window::new().build();
9
10    let triangle = qqx::Polygon::new().vertex(Vertex::new()
11        .pos(qqx::Vec2::new(-0.5, -0.5))
12        .color(qqx::Color::RED))
13    .vertex(Vertex::new()
14        .pos(qqx::Vec2::new(0.0, 0.5))
15        .color(qqx::Color::GREEN))
16    .vertex(Vertex::new()
17        .pos(qqx::Vec2::new(0.5, -0.25))
18        .color(qqx::Color::BLUE)
19    ).bind(window);
20
21    qqx::callback::on_frame(move || {
22        window.draw()
23            .clear(qqx::Color::from(qqx::Vec4::new(0.0, 0.1, 1.0, 1.0)))
24            .draw(&triangle)
25            .finish();
26
27        let next_frame_time = std::time::Instant::now() + std::time::Duration::from_nanos(16_666_667);
28        return qqx::ControlFlow::WaitUntil(next_frame_time);
29    });
30
31    qqx::eventloop();
32}