Minilibx for the rust novice

About

These are the rust ffi bindings for the minilibX C api. \ The api is meant for beginners to learn the basics of graphics development. \ The minilibx itself is a wrapper around X11 utilites to provide a simple library for graphics development. \ More examples are coming very soon.

Dependencies

How To Install

First, you need to have these libraries installed: - libX11 - libXext - libmlx.a (either in /usr/lib* or /usr/local/lib)

to install libmlx, you can do bash $ git clone git@github.com:42Paris/minilibx-linux /tmp/minilibx-linux $ cd /tmp/minilibx-linux $ make $ sudo cp libmlx.a /usr/local/lib

In your project: toml [dependencies] minilibx = "0.2.0"

Example

```rust extern crate minilibx;

use minilibx::{Mlx, MlxError}; use std::process;

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);

window.key_hook(
    move |keycode, _| {
        // you can also check keycodes using the `xev` command on linux
        println!("{}", keycode);

        if keycode == 113 {
            process::exit(0);
        } else if keycode == 97 {
            let x = width / 2;
            let y = height / 2;
            let color = 0xffffff;
            mlx.pixel_put(&window, x, y, color);
        }
    },
    &(),
);

// this will loop forever
mlx.event_loop();

} ```

TODO