[][src]Crate linfb

linfb is a drawing library that uses Linux' /dev/fb0 device as it's backend. For most tasks you probably want to use OpenGL or Vulkan backed library. /dev/fb0 is deprecated but still useful for some specific cases. This library supports framebuffers that use 32 bits per pixel, so (theoretically) most modern systems.

Before drawing on framebuffer you should allocate a virtual terminal and switch to it. I recommend using vt crates for this task. You should never draw on virtual terminal used by X.org/Wayland server, this is unsafe and can lead to panics.

By default linfb includes text and images drawing capabilities, which brings additional dependencies. You can disable these features if you only need low-level framebuffer interactions and Shape trait.

Basic usage can look like this:

This example is not tested
use linfb::Framebuffer;
use linfb::shape::{Color, Shape, Rectangle, Caption, Image, FontBuilder, Alignment};
let mut framebuffer = Framebuffer::open()
    .expect("Failed to open framebuffer");
let mut compositor = framebuffer.compositor((255, 255, 255).into());
    .add("rect1", Rectangle::builder()
        .at(100, 100))
    .add("rect2", Rectangle::builder()
        .at(150, 150))
    .add("image", Image::from_path("image.png")
        .at(500, 500))
    .add("wrapped_text", Caption::builder()
        .text("Some centered text\nwith newlines".into())
        .at(1000, 300));
// Compositor is shape, so we can just draw it at the top left angle
framebuffer.draw(0, 0, &compositor);
// Really changing screen contents



Various drawing primitives


Low-level utilities to deal with framebuffer file descriptor



Shape that can contain other shapes. Can deal with transparency and overlaps.


Builder for Compositor.


Basic object used to manipulate framebuffer. You should normally use Shape and Compositor to draw on it



Type Definitions