Pax is a user interface language and rendering engine. Use Pax to build GUIs and interactive 2D graphics with Rust.
Pax compiles through Rust into native Mac apps (LLVM) or Web apps (WebAssembly). Support for more platforms is planned, at least: Linux, Windows, iOS, and Android.
As of September 2022, Pax is being developed in the open, in alpha preview.
Writing Pax is intended to feel familiar, and the language borrows many ideas from prior art.
Following is a simple Pax component called IncrementMe
:
//increment-me.rs
use pax::*;
use pax_std::{Text};
use pax_std::forms::{Button, ArgsButtonSubmit};
use pax_std::layout::{Stacker};
/// Following is the description of a simple form GUI, encapsulated
/// into a reusable component called `IncrementMe`.
#[pax(
<Stacker cells=2>
<Text>{"I have been clicked " + self.num_clicks + " times."}</Text>
<Button @submit=self.increment>"Increment me!"</Button>
</Stacker>
)]
pub struct IncrementMe {
pub num_clicks: Property<i64>
}
impl IncrementMe {
pub async fn increment(&self, args: ArgsButtonSubmit) {
let old_num_clicks = self.num_clicks.get();
self.num_clicks.set(old_num_clicks + 1);
}
}
Any Pax component like the example above may be included inside other Pax components, or may be mounted as the root of a stand-alone app.
See a more thorough and a running example.
- Fast — native rendering targeting 120FPS animations
- Accessible — supports native screen readers for text & GUI elements
- Lightweight — targeting <100kB baseline for WebAssembly binary
- Declarative UI language makes it easy to reason about complex scenes and GUIs
- Reusable component system includes an optional standard library of GUI components
- Multi-platform — currently supports building Web apps or native macOS apps
Read more in The Pax Docs
Refer to the guide for getting started in the Pax docs.
Pax is in alpha-preview and is not yet viable for building apps — read the latest status.
Web browsers | Native iOS | Native Android | Native macOS | Native Windows | Native Linux | |
---|---|---|---|---|---|---|
Development harness & chassis | ✅ | ⏲ | ⏲ | ✅ | ⏲ | ⏲ |
2D rendering and UIs | ✅ Canvas |
⏲ CoreGraphics |
⏲ Cairo |
✅ CoreGraphics |
⏲ Direct2D |
⏲ Cairo |
3D rendering and UIs | ⏲ | ⏲ | ⏲ | ⏲ | ⏲ | ⏲ |
Vector graphics APIs | ✅ | ⏲ | ⏲ | ✅ | ⏲ | ⏲ |
2D layouts | ✅ | ⏲ | ⏲ | ✅ | ⏲ | ⏲ |
Animation APIs | ✅ | ⏲ | ⏲ | ✅ | ⏲ | ⏲ |
Native text rendering | ✅ DOM |
⏲ UIKit |
⏲ android:* |
✅ SwiftUI |
⏲ System.Windows.Forms |
⏲ GTK |
Native form elements | ⏲ DOM |
⏲ UIKit |
⏲ android:* |
⏲ SwiftUI |
⏲ System.Windows.Forms |
⏲ GTK |
Native event handling (e.g. Click, Tap) | ✅ | ⏲ | ⏲ | ✅ | ⏲ | ⏲ |
Rust host language | ✅ WASM |
⏲ LLVM |
⏲ LLVM |
✅ LLVM |
⏲ LLVM |
⏲ LLVM |
JS/TypeScript host language | ⏲ | ⏲ | ⏲ | ⏲ | ⏲ | ⏲ |
Legend: |
---|
✅ Supported |
⏲ Not yet supported |
© 2023 Zachary Brown [contact@pax.rs].
This project is licensed under either of:
at your option.
Use rustc
1.65.0 via rustup
-
Install
wasm-opt
viabinaryen
:brew install binaryen
-
Install 'wasm-pack' via:
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
-
Install
node
: https://nodejs.org/en/download/ -
Install
yarn
:# if necessary: sudo chown -R yourusername /usr/local/lib/node_modules npm i --global yarn
- Install xcode, command line utils
First, refer to the latest project status
The current leading edge of development is in the compiler —
cd pax-compiler
./run-example.sh
To run pax-example
's parser binary and print its output to stdout:
cd pax-example
cargo build --bin=parser --features=parser
To run a full, compiled Pax example you must check out an older branch and run the demo there.
git checkout jabberwocky-demo
./run.sh # or ./run-web.sh
To initialize the docs submodule, for super-grep powers:
git submodule update --init --recursive
As needed, review the git submodule docs.