Pax
Pax is a cross-platform rendering engine & Rust framework for interactive graphics, animations, and GUIs.
Pax extends the Rust programming language with a syntax for declarative component-based graphical content and behavior. Pax programs compile through Rust into lightweight native app executables or WebAssembly-powered Web apps with a <100kB base footprint and up to 120FPS rendering.
As of September 2022, Pax is being developed in the open, in alpha preview.
Example
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};
#[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 running example in the docs.
Docs
Read more in The Pax Docs
Getting Started
Refer to the guide for getting started in the Pax docs.
Current status & support
Pax is in alpha-preview and is not yet viable for building apps — read the latest status.
End-to-end:
- Syntax design
✅ - Parser
✅ - Compiler front-end
❌ WIP - Compiler back-end
✅ - Rendering engine
✅ - Cross-platform chassis
✅ - Browser runtime
✅ - macOS runtime
✅
Support matrix:
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: |
---|
|
|
License
© 2022 The Pax Foundation [[email protected]].
This project is licensed under either of:
at your option.
Development
Architectural Reference
Optional environment setup, web chassis
-
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
Optional environment setup, macOS chassis
- Install xcode, command line utils
Running Development Environment
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.