Crate wwind

source ·
Expand description

wwind is a cross-platform Rust UI library that is meant to provide a nice programming experience and significantly reduce runtime errors and undefined/unexpected behavior. It is meant to do all of this while still providing reasonable performance and platform consistency.

Example

use wwind::{WWindInstance, WWindState, Window, Color, RectRegion};

fn main() {
    let instance = WWindInstance::new(|state: &mut WWindState| {
        let mut window = state.add_window(100, 100, 500, 500, "test title");

        window.on_redraw(|_, window, _| {
            let (w, h) = window.get_size();
            let window_rect = RectRegion { x: 0, y: 0, width: w, height: h };

            let mut context = window.get_drawing_context();

            // Draw background //

            context.set_draw_color(Color::from_hex(0xffffff));
            context.draw_rectangle(window_rect);
             
            // Draw lines //

            context.set_draw_color(Color::from_rgb(0, 255, 0));
            context.draw_line(0, 0, w, h);
             
            context.set_draw_color(Color::from_rgb(255,0,0));
            context.draw_line(w, 0, 0, h);
        });
    });

    instance.unwrap().run();
}

Expected Output

Structs