mirui. Small screens. Big play.
Small screens.
pub fn classify(width: Fixed, height: Fixed) -> Self {
let short = width.min(height);
let long = width.max(height);
if long * 10 <= short * 12 && long <= Fixed::from_int(480) {
Self::Dial
} else if short < Fixed::from_int(200) {
Self::Micro
} else if height * 10 > width * 13 {
Self::Portrait
} else {
Self::Landscape
}
}
iris/composition.rs740–753
match ${ model.layout() } {
IrisLayout :: Micro => {
compose_micro (model)
}
IrisLayout :: Dial => {
compose_dial (model)
}
IrisLayout :: Portrait => {
compose_portrait (model)
}
IrisLayout :: Landscape => {
compose_landscape (model)
}
}
LayoutIrisLayout::Micro
Scale—
Web Canvas · wasm32
Drag the screen corner to resize. Click a match arm to switch screens.
Big play.
01 / 13
↗ PLAY✳ MAKE⌘ CODE◎ REPEAT
↗ PLAY✳ MAKE⌘ CODE◎ REPEAT
↗ PLAY✳ MAKE⌘ CODE◎ REPEAT
↗ PLAY✳ MAKE⌘ CODE◎ REPEAT
↗ PLAY✳ MAKE⌘ CODE◎ REPEAT
↗ PLAY✳ MAKE⌘ CODE◎ REPEAT
↗ PLAY✳ MAKE⌘ CODE◎ REPEAT
↗ PLAY✳ MAKE⌘ CODE◎ REPEAT
↗ PLAY✳ MAKE⌘ CODE◎ REPEAT
↗ PLAY✳ MAKE⌘ CODE◎ REPEAT
↗ PLAY✳ MAKE⌘ CODE◎ REPEAT
↗ PLAY✳ MAKE⌘ CODE◎ REPEAT
Games
Play.
Games for small screens and desktop windows. Each one also builds as a native app.
No games match this search.
Demos
Explore.
Components, rendering, motion, effects, state and scrolling, each with its Rust source.
No demos match this search.
How it works
Build once.
Route precisely.
One retained component tree. Layout runs in Q24.8 fixed point, then each target draws it with the backend it has.
Q24.8 layout + hit testing
no_std + alloc core
Dirty-region redraw
Software + GPU routes
Compose · ui!README.md
#[compose]
fn build_root() {
ui! {
Column (grow: 1.0) {
View (
bg_color: ColorToken::Primary,
text_color: ColorToken::OnPrimary,
height: 40,
border_radius: 8,
padding: Padding::all(10)
) {
Text ("Hello mirui!")
}
View (bg_color: ColorToken::SurfaceVariant, grow: 1.0)
Text ("ECS + DSL", height: 30, paragraph: ParagraphStyle::label())
}
};
}
Bind · $README.md, adapted
#[model]
struct Counter {
#[observe]
value: i32,
}
#[compose]
fn counter_panel(counter: model!(Counter)) {
ui! {
Row {
Button(text: "+") on Tap { counter.increment(); }
Text(text: ${ format!("count: {}", counter.value()) })
}
};
}
// Starts at 41. One tap and the Text reads 42.
Respond · @README.md
ui! {
Column (container: true) {
Text(
"Adaptive title",
font_size: @width {
if width < Fixed::from_int(520) { 18_u16 } else { 30_u16 }
},
padding: @(width, height) {
Padding::all(width.min(height) / 24)
}
)
}
}
Drag the screen corner in the hero to watch this kind of rule run.
Route · Surfacecompose_backend!
RETAINEDUI TREEECS · Q24.8
NORMALIZEDSCENECOMMANDS
BOUNDEDSOFTWARERGB565 · MCU
NATIVEGPUWGPU · SDL
BROWSERWEBCANVAS
FRAMEBUF · SDL2 · WGPU · WEB CANVAS · FBDEV / DRM · NUTTX
Composeui! macro · #[compose]
Runtime targets
Everywhere.
The same component tree on each host. Rows marked Show open that screen in the hero above.
Target
Hardware or OS
mirui backend
MCU
RISC-V, Arm Cortex-M and other microcontrollers. No FPU needed
FramebufSurface · no_std + alloc
Template
NuttX
Real-time OS · round 1.28″ 240 × 240
NuttX surface
Linux
Embedded Linux without a compositor
fbdev · DRM
Android · iOS
Phones and tablets
WGPU · bounded software
Template
Desktop
Linux · macOS · Windows
SDL2 CPU / GPU · WGPU
Template
Browser
WebAssembly. This page is one
Web Canvas
Template
Getting started
Open a terminal.
Make it yours.
Add mirui to an existing crate, or generate a project for desktop, browser, mobile or an embedded board.
Add to a crate
crates.io
Use the library directly when the runtime and window integration already exist.
cargo add mirui
Read the API docs
Generate one target, or a workspace with desktop, WebAssembly, embedded, Android and iOS apps.
cargo install cargo-generatecargo generate --git https://github.com/W-Mai/mirui-templates.git templates/workspace --name hello-mirui