Expand description
This library constains rust bindings for the linux minilibx, a simple X11 GUI toolkit for beginners.
The bindings should work as expected, if it’s not the case, feel free to open an issue here.
§Dependencies
- libX11
- libXext
- libmlx (minilibx)
§Example
extern crate minilibx;
use std::process;
use minilibx::{Mlx, MlxError};
fn main() {
let mlx = Mlx::new().unwrap();
let width = 1080;
let height = 720;
let window = mlx.new_window(width, height, "Mlx example").unwrap();
let image = match mlx.new_image(width, height) {
Ok(img) => img,
Err(e) => match e {
MlxError::Any(s) => return println!("{}", s),
_ => return,
},
};
println!("{}, {}", image.size_line, image.bits_per_pixel);
window.key_hook(
move |keycode, _| {
// you can also check keycodes using the `xev` command
println!("{}", keycode);
// `q`
if keycode == 113 {
process::exit(0);
// Enter
} else if keycode == 97 {
let x = width / 2;
let y = height / 2;
let color = 0xffffff;
for i in 0..50 {
mlx.pixel_put(&window, x + i, y + i, color);
}
}
},
&(),
);
// this will loop forever
mlx.event_loop();
}
Structs§
- Mlx
- Api method holder.
- MlxImage
- Image data placeholder. Can be used to draw image onto the screen.
- MlxWindow
- Hook api holder. Needed in most Mlx methods.
Enums§
- Endian
- Enum describing the endianness of some data.
- MlxError
- Enum for detecting errors in the minilibx.