1 unstable release

0.1.0 Apr 11, 2022

#31 in #framebuffer

Apache-2.0

7KB
79 lines

fbdraw provides a single interface put_pixel(x, y, color) for drawing on the screen. This simple interface makes it easy to play around with graphics algorithms like curve drawing, without the burden of setting up a window (with an event loop), setting up GPU pipeline, or managing software buffers, etc.

The coordinate system has origin at the top-left, with X and Y axis running left-to-right and top-to-bottom, respectively.

It is a wrapper for the minifb library.


lib.rs:

fbdraw

Provides a simple interface for creating a "surface" and a single primitive put_pixel for drawing on it.

The aim is allow playing around with graphics algorithms like curve drawing, without the burden of setting up a window (with an event loop), setting up GPU pipeline, etc.

This crate wraps the minifb library, and provides a simpler Surface based interface.

The coordinate system has origin at the top-left, with X and Y axis running left-to-right and top-to-bottom, respectively.

Example

use fbdraw::{Color, Surface};

let mut surface = Surface::new(1920, 1200);

surface.begin_draw(my_draw_frame);

// Draw a frame on the surface. This callback function is
// called at a fixed rate of 60 fps.
fn my_draw_frame(surface: &mut Surface) {
    let (width, height) = surface.size();
    surface.put_pixel(width / 2, height / 2, Color::rgb(255, 0, 0));
}

Dependencies

~0.4–1MB
~14K SLoC