Generic framebuffer implementation in Rust for use with embedded-graphics library


Contributors Forks Stargazers Issues Build Status MIT License LinkedIn

Embedded graphics logo

Fraramebuffer implementation for Rust's Embedded-graphics

Framebuffer approach helps to deal with display flickering when you update multiple parts of the display in separate operations. Intead, with this approach, you're going to write to a in-memory display and push it all at once into your hardware display when the whole picture is drawn.

This technique is useful when you're updating large portions of screen or just simply don't want to deal with partial display updates.
The approach has been tested on TTGO (esp32) with ST7789
Explore the docs »

Rust Crate · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Roadmap
  4. License
  5. Contact
  6. Acknowledgments

About The Project

This library is a Rust implementation of framebuffer approach that is often used when driving hardware displays. The goal is to perform bulk-write of all the screen pixels at once, avoiding multiple individual updates that could lead to screen flickering.

This library has been designed to work with Rust's embedded-graphics library.

(back to top)

Built With

(back to top)

Getting Started

Make sure you have your rust environment configurated


  1. Add library to your Cargo.toml

    embedded-graphics-framebuf = "0.1.0"
  2. Use the library in you code

    use embedded_graphics_framebuf::FrameBuf;
    let mut display = st7789::ST7789::new(
        // SP7789V is designed to drive 240x320 screens, even though the TTGO physical screen is smaller
    static mut FBUFF: FrameBuf<Rgb565, 240_usize, 135_usize> = FrameBuf([[Rgb565::BLACK; 240]; 135]);
    let fbuff = unsafe { &mut FBUFF };
        &"Good luck!",
        Point::new(10, 13),
        MonoTextStyle::new(&FONT_10X20, Rgb565::WHITE.into()),
    // write to the actual display :-)
    let u16_iter = fbuff
        .map(|px| px.into_storage());
    // those are the offsets for my physical ST7789 display
    display.set_pixels(40, 53, 240 - 1 + 40, 53 + 135, u16_iter);
  3. Your flickering problems should be solved at this point :)

(back to top)


  • add tests
  • add rustdocs
  • CI integration with GithHub Actions
  • better error generation & handling

See the open issues for a full list of proposed features (and known issues).

(back to top)


Distributed under the MIT License. See LICENSE for more information.

(back to top)


Bernard Kobos - @bkobos - [email protected]

Project Link:

(back to top)


(back to top)

  • Framebuffer as a contiguous buffer?

    Framebuffer as a contiguous buffer?

    The current implementation is not really friendly to DMA engines, in general, it prefers a continuous block of memory (unless you have one of those fancy 2D DMA engines). I also believe in general (not been benchmarked so, in reality, it may not be true) that a single buffer is better for performance reasons, I think you'll get double bounds checks using an array of an array, as opposed to a single buffer.

    Thoughts on changing the underlying storage? Or providing a storage trait to customise the backing storage?

    opened by MabezDev 5
  • Version 0.2.0

    Version 0.2.0

    In case you agree to the changes in #3, #6, #8, #9, and #10, I merged them all in my fork so you don't have to do that work again. These are breaking changes, so a version update is advised. This also adds a basic CI, based on what @pyaillet had in his repository.

    opened by jounathaen 3
  • Separated Framebuffer and underlying data storage

    Separated Framebuffer and underlying data storage

    This enables linear memory can be used, e.g., for DMA access. Closes #4. Maybe not the best long-term solution, but a nicer one requires a new compiler feature.

    opened by jounathaen 1
  • Reworked iterators

    Reworked iterators

    An iterator over pixels is often more helpful, as all displays which implement embedded_graphics can handle them better. To iterate over the raw color data, a helper function raw_data is added.

    This makes #5 obsolete.

    opened by jounathaen 1
  • Renamed FrameBufIntoIterator to FrameBufIterator

    Renamed FrameBufIntoIterator to FrameBufIterator

    I was highly confused what an "IntoIterator" is, until I gasped that this is simply the iterator type for the framebuffer. I think FrameBufIterator is a better name.

    opened by jounathaen 1
  • There is no boundary check when writing to the framebuf

    There is no boundary check when writing to the framebuf

    Hi! Thank you for making embedded-graphics-framebuf.

    I face a panic when using this library when writing outside of the defined dimensions.

    Would you be interested in a PR adding this checks ? I'm planning to add it for my own use anyway.

    opened by pyaillet 0
  • add ci

    add ci

    Hi !

    Thanks for this project, I was able to use it here.

    This PR adds a minimal CI workflows.

    If you're interested I can create other PR with actions similar to the ones in this project

    opened by pyaillet 0
  • Support for drawing Sprites with transparent pixels - filtering specific color

    Support for drawing Sprites with transparent pixels - filtering specific color

    Hello. I want to open a discussion on how to add support for drawing sprites with transparent pixels.

    Right now, Embedded Graphics and FrameBuf do not allow filtering out specific color (or alpha) when drawing an image. This results in always transferring all pixels. What would it take to implement an option to filter colors?

    E.g., in the days of old DOS games, pink color (RGB = 255,0,255) was not transferred during blit operation, resulting in a "transparent" background of the sprite.

    I made an experimental implementation, basically just copying FrameBuf code and fixing it to a specific type, Rgb565, because generic C does not have the option to check for color. And I've added one condition to match the color value, which is ignored. The implementation works. I'm curious whether it would be possible to do it generically without enforcing the Rgb565 type.

    Another option would be to use the alpha channel, but that seems to be a slightly more complex operation.

    I would appreciate your input @bernii @pyaillet

    opened by georgik 1
  • v0.2.0(Sep 2, 2022)

    Complete overhaul:

    • no-std compatible
    • Separated framebuffer and underlying data storage
    • DMA compatibility
    • Other minor changes

    Includes major API changes!

    Source code(tar.gz)
    Source code(zip)
Bernard Kobos
Bernard Kobos
A vector graphics renderer using OpenGL with a Rust & C API.

bufro A vector graphics renderer using OpenGL with a Rust & C API. A Rust example can be found in examples/ (using glutin). A C example c

Aspect 9 Dec 15, 2022
Kiss3d - Keep it simple, stupid 3d graphics engine for Rust.

Kiss3d - Keep it simple, stupid 3d graphics engine for Rust.

Sébastien Crozet 1.2k Dec 26, 2022
A little cross-platform graphics engine written in rust.

Bismuth This is a version of my C++ graphics engine named Bismuth re-written with Rust. My goal is to learn more about the Rust language and make my g

Admiral サイタマ 1 Nov 1, 2021
Rust bindings to bgfx, a cross-platform, graphics API agnostic

Rust bindings to bgfx, a cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.

Daniel Collin 65 Dec 24, 2022
wgpugd: A WebGPU Graphics Device for R

wgpugd: A WebGPU Graphics Device for R Overview What is WebGPU? WebGPU is an API that exposes the capabilities of GPU hardware. What is wgpu? As the n

Hiroaki Yutani 42 Dec 11, 2022
Graphite is a digital content creation software package for 2D graphics

Powerful 2D vector and raster editing. Procedural and nondestructive. Graphite is a digital content creation software package for 2D graphics, merging

Graphite 2.1k Jan 9, 2023
Native WebGPU implementation based on gfx-hal

This is an active GitHub mirror of the WebGPU implementation in Rust, which now lives in "gfx/wgpu" of Mozilla-central. Issues and pull requests are a

Rust Graphics Mages 6.5k Jan 9, 2023
Graph data structure library for Rust.

petgraph Graph data structure library. Supports Rust 1.41 and later. Please read the API documentation here Crate feature flags: graphmap (default) en

null 2k Jan 9, 2023
A graph library for Rust.

Gamma A graph library for Rust. Gamma provides primitives and traversals for working with graphs. It is based on ideas presented in A Minimal Graph AP

Metamolecular, LLC 122 Dec 29, 2022
Simple but powerful graph library for Rust

Graphlib Graphlib is a simple and powerful Rust graph library. This library attempts to provide a generic api for building, mutating and iterating ove

Purple Protocol 177 Nov 22, 2022
The library provides basic functions to work with Graphviz dot lang from rust code.

Description The library provides the basic access to the graphs in graphviz format with ability to import into or export from it. Base examples: Parse

Boris 28 Dec 16, 2022
Rust library for of graph ensembles

Rust library for random graph ensembles Minimal Rust version: 1.55.0 Implements simple sampling and monte carlo (or rather markov-) steps, that can be

Yannick Feld 2 Dec 14, 2022
An SVG rendering library.

resvg resvg is an SVG rendering library. Purpose resvg can be used as a Rust library, a C library and as a CLI application to render SVG files based o

Evgeniy Reizner 1.8k Jan 7, 2023
Library for Rubik's cube applications.

Rubik Master Do you like to solve Rubik's cube? I do. As a cuber and programmer, I want to build a toolset to build applications like S

Akira Hayakawa 12 Nov 3, 2022
Sub-pixel precision light spot rendering library for astronomy and video tracking applications.

Planetarium Sub-pixel precision light spot rendering library for astronomy and video tracking applications. Example usage use planetarium::{Canvas, Sp

Sergey Kvachonok 5 Mar 27, 2022
Small, lightweight and fast library for rendering text with wgpu.

wgpu-text wgpu-text is a wrapper over glyph-brush for fast and easy text rendering in wgpu. This project was inspired by and is similar to wgpu_glyph,

Leon 20 Nov 30, 2022
Python library for embedding large graphs in 2D space, using force-directed layouts.

Graph Force A python/rust library for embedding graphs in 2D space, using force-directed layouts. Installation pip install graph_force Usage The first

Niko Abeler 159 Dec 29, 2022
A toy ray tracer in Rust

tray_rust - A Toy Ray Tracer in Rust tray_rust is a toy physically based ray tracer built off of the techniques discussed in Physically Based Renderin

Will Usher 492 Dec 19, 2022
A low-overhead Vulkan-like GPU API for Rust.

Getting Started | Documentation | Blog gfx-rs gfx-rs is a low-level, cross-platform graphics and compute abstraction library in Rust. It consists of t

Rust Graphics Mages 5.2k Jan 8, 2023