# affineui
Safe, idiomatic Rust bindings for
[AffineUI](https://github.com/benjcooley/affineui) — a tiny
GPU-accelerated HTML/CSS UI renderer for tools and game engines.
**EXPERIMENTAL preview** — published for early testing; APIs and the
underlying C ABI will change while AffineUI is pre-1.0.
Two modes:
- **App-owned** — AffineUI owns the window and main loop:
```rust
use affineui::{App, Config, Theme, View};
let view = View::new(Theme::Decius);
v.button("Click me", true, "go").on_click(|| println!("clicked"));
v.slider("Exposure", 0.5, 0.0, 1.0, "exposure")
.on_change(|value| println!("exposure = {value}"));
});
let app = App::new(Config::default().title("Demo"));
app.load_view(&view);
app.run();
```
- **Embedded** — your engine owns the GPU device, loop, and input;
AffineUI renders into your render targets (`affineui::embedded::Ui`,
D3D11 / Metal / GL / WebGPU handles).
## Native library
This crate drives the `affineui_c` shared library and does not ship
it. Build it from the AffineUI repo
(`cmake -DAFFINEUI_BUILD_C_SHARED=ON`, target `affineui_c`) and set
`AFFINEUI_LIB_DIR` to the output directory; in a repo checkout the
build script finds it automatically and copies it next to your
binaries.
Everything is single-threaded by contract (handles are `!Send`);
callbacks are released exactly once and panics never cross the FFI.