Crate miniwrap

Source
Expand description

A wrapper around minifb that makes managing windows as simple as possible, with hexidecimal RGB rather than raw u32.

Window elements like buffers and dimensions are linked together in the WindowContainer struct. To keep the window alive, call update() from within a loop. This has a built-in graceful exit by pressing ESC.

let window = window!(?500, 500, "Window", "FFFFFF");

loop {
    window.update();
}

Heres an example of a UV map generated from pixel coordinates:

let window = window!(?500, 500, "Window", "FFFFFF");

//iterates with the value and position
for (_, pos) in window.iter() {
    let r = to_hex2(pos.0 as u8).unwrap();
    let g = to_hex2(pos.1 as u8).unwrap();
    let string = format!("{r}{g}00");

    window.set(pos, &string)?;
}

//pressing escape will close the window
loop {
    window.update();
}

Note with the hexidecimal conversions: functions that take hexidecimal will take a &str for convenience, but functions that return hexidecimal will return a String.

Macros§

window
Initializes a WindowContainer. Optional background color. Begin with ? to unwrap.

Structs§

WindowContainer
Contains a Window, pixel buffer, and properties.

Enums§

WinErr
Errors concerning the WindowContainer.

Functions§

from_hex8
Converts an (up to) 8-wide hexidecimal string to a u8.
hex_to_rgb
converts a 0F0F0F format hex string into a u32.
to_hex2
Converts a u8 to a 2-wide hexidecimal string, to concatenate into a RGB hex string. Note that this includes leading zero.
to_hex6
Converts a u32 to a 6-wide hexidecimal string. Note that this includes leading zeros.