[][src]Struct minilibx::Mlx

pub struct Mlx { /* fields omitted */ }

Api method holder.

Methods

impl Mlx[src]

pub fn new() -> Result<Self, MlxError>[src]

Creates a new Mlx instance.

Calls the mlx_init C method under the hood.

Usage:

let mlx = Mlx::new().unwrap();

pub fn new_window(
    &self,
    size_x: i32,
    size_y: i32,
    title: &str
) -> Result<MlxWindow, MlxError>
[src]

Creates a new window instance.

Usage:

 let image = mlx.new_window(1920, 1080, "mlx-example").unwrap();

pub fn clear_window(&self, window: &MlxWindow)[src]

Clears the window with black.

pub fn destroy_window(&self, window: &MlxWindow)[src]

Destroys the window. This function also drops the window object.

pub fn get_screen_size(&self) -> (i32, i32)[src]

Get the actual screen size.

pub fn pixel_put(&self, window: &MlxWindow, x: i32, y: i32, color: i32)[src]

Put a pixel on the screen

You should encode the color as RGB on the three last bytes of the int.

0x00|ff(R)|ff(G)|ff(B)

Usage:

 let x = 200;
 let y = 300;
 let color = 0x0000ff; // blue
 mlx.pixel_put(&window, x, y, color);

pub fn string_put(
    &self,
    window: &MlxWindow,
    x: i32,
    y: i32,
    color: i32,
    s: &str
) -> Result<(), MlxError>
[src]

Writes a string on the screen

Color is encoded in rgb as well. Usage:

 let x = 200;
 let y = 300;
 let color = 0xff0000; // red
 mlx.string_put(&window, x, y, color, "Hello World");

pub fn new_image(&self, width: i32, height: i32) -> Result<MlxImage, MlxError>[src]

Creates a new image.

pub fn xpm_to_image(&self, xpm_data: Vec<String>) -> Result<MlxImage, MlxError>[src]

Creates a new image from xpm data.

Note that the minilibx does not use the standard Xpm library. You may not be able to read all types of xpm images.

It however handles transparency.

pub fn xpm_file_to_image(&self, filename: &str) -> Result<MlxImage, MlxError>[src]

Creates a new image from an xpm file.

pub fn destroy_image(&self, image: &MlxImage)[src]

Destroy the image. Also drops the image instance.

pub fn put_image_to_window(
    &self,
    window: &MlxWindow,
    image: &MlxImage,
    x: i32,
    y: i32
)
[src]

Draws an image to the window

Usage:

 let x = 200;
 let y = 200;
 mlx.put_image_to_window(&window, &image, x, y);

pub fn get_color_value(&self, color: i32) -> u32[src]

Transforms an RGB color parameter into a u32 value.

This returns a bits_per_pixel value of the rgb value.

You can use this to write into an image

pub fn do_key_autorepeaton(&self)[src]

Enables key autorepeat when pressing a key

pub fn do_key_autorepeatoff(&self)[src]

Disables key autorepeat when pressing a key

pub fn mouse_move(&self, window: &MlxWindow, x: i32, y: i32)[src]

Moves the mouse cursor

pub fn mouse_show(&self, window: &MlxWindow)[src]

Shows the mouse cursor

pub fn mouse_hide(&self, window: &MlxWindow)[src]

Hides the mouse cursor

pub fn event_loop(&self)[src]

Run the event loop.

This is running an infinite loop which launches hooks when receiving events.

Trait Implementations

impl Clone for Mlx[src]

impl Copy for Mlx[src]

Auto Trait Implementations

impl RefUnwindSafe for Mlx

impl !Send for Mlx

impl !Sync for Mlx

impl Unpin for Mlx

impl UnwindSafe for Mlx

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.