Fusuma

Docs

Rendering

Several backends, one trait, one conformance suite.

One trait, three renderersThe Renderer trait is implemented by the integer renderer for microcontrollers, Vello on the CPU, and Vello on the GPU. All three pass the same conformance suite.trait Rendererfill_rect · fill_path · stroke_path · draw_text · draw_image · gradients · shadows · push_layer · clipIntegerfusuma-render-integer· RGB565 target· glyph atlases made at build time· no allocator, no FPU, no unsafe· ESP32-C6 and upVello CPUfusuma-render-vello-cpu· anti-aliased paths· SIMD, optional worker threads· Parley text and bidi· a chip with PSRAM, or no GPUVello GPUfusuma-render-vello· wgpu on the GPU· the same scene description· desktop and the web· falls back to the CPU rendererThe same conformance suite runs on all three. What a backend cannot do says so, and the toolkit draws the plain version.
Pick the renderer by the hardware, with a cargo feature or in fusuma.toml: the app does not change.

The backends

CrateWhatWhere it fits
fusuma-render-integerInteger drawing: smooth text, shapes and images in integer maths, no FPU, no allocator.The lightest. Chips that must keep their RAM free, from an ESP32-C6 up.
fusuma-render-vello-cpuAnti-aliased drawing on vello_cpu.The richest CPU renderer. A chip with PSRAM, or a machine without a GPU.
fusuma-render-velloAnti-aliased GPU drawing on vello_gpu and wgpu.Desktop and anything with a usable GPU.

Side by side

IntegerVello CPUVello GPU
Draws withinteger arithmetic into an RGB565 targetvello_cpu, anti-aliasedvello_gpu on wgpu
Textglyph atlases made at build timeParley, from outlinesParley, from outlines
Allocatornoneneededneeded
Floating pointnonelibm where the chip has no FPUon the GPU
Threadsnooptional worker threadsthe GPU
Fitsa chip, from an ESP32-C6 upa chip with PSRAM, or a machine without a GPUdesktop and the web

One trait

Every backend implements Renderer and passes the same conformance suite, so the same scene goes through the same rules on each: one rule for images, one for gradients, one for dashes. Something a backend cannot do says so, its method returns false or Capabilities says it, and the toolkit draws the plain version instead of failing.

fusuma-render
pub trait Renderer {
    type Error;

    fn capabilities(&self) -> Capabilities;
    fn clear(&mut self, color: Color) -> Result<(), Self::Error>;
    fn fill_rect(&mut self, rect: Rect, radius: u32, color: Color) -> Result<(), Self::Error>;
    fn fill_path(&mut self, path: &[PathCmd], color: Color) -> Result<(), Self::Error>;
    fn stroke_path(&mut self, path: &[PathCmd], width: u32, color: Color) -> Result<(), Self::Error>;
    fn draw_text(&mut self, text: &str, at: Point, style: &TextStyle) -> Result<(), Self::Error>;
    fn measure_text(&self, text: &str, style: &TextStyle) -> Size;

    // Clips, images, gradients, shadows, dashes and layers have defaults
    // built from the methods above; a backend overrides the ones it does better.
}

A widget never sees a renderer’s type: it draws on a canvas that moves and clips the renderer to its box. You can write a widget of your own and it draws the same way as the built-in ones.

Choosing one

fusuma-platform reads the screen and the chip (RAM, PSRAM, FPU, GPU) and picks a renderer, with a reason for its answer. fusuma.toml overrides it:

fusuma.toml
[render]
backend = "auto"   # auto, integer, vello-cpu or vello-gpu

[fonts]
preset = "legible"   # fusuma, material, legible, plex or noto

[theme]
palette = "washi"     # one of 27

Features add up in a build, so linking two renderers links both; the platform chooses among those linked. On the desktop, --renderer vello-cpu (or vello-gpu, integer, auto) overrides it for a run, and RUST_LOG=info shows the choice.

Effects

Rounded clips, gradients, soft shadows, blend layers, backdrop blur, dashed strokes and shaders are all in the trait, and each backend does what it can. The integer renderer does them in one pass over integers: sparse strips for fills, a blur in a ring buffer, layers only when the board has room for a layer store. The gallery’s Effects and Shape pages show them.

Layers

A renderer crate never depends on a toolkit crate, and a platform crate draws nothing itself. A firmware that only draws gets no toolkit code; CI checks both rules.