Newt — Design Canvas Compiler
A Rust-based compiler and live canvas for the Newt UI language. Architecture B: parse source → layout → render on a wgpu canvas (S-tier stack).
Prerequisites
- Rust (1.70+): rustup
- GPU with Vulkan, Metal, or D3D12 support
Build & Run
Run with a specific .newt file:
Newt Language (UI/visual DSL)
- Variables:
let name = value;(numbers, strings, colors#RRGGBB) - Screens:
screen Main { ... }— root UI tree - Layout:
column,row,stack,centerwithgap,padding - Elements:
box,text,button,input,spacer,image - Props:
fill,stroke,radius,width,height,fontSize,content, etc.
Example:
let padding = 24;
screen Main {
column { gap: 16, padding: padding } {
box { fill: #ffffff, radius: 8, padding: 16 } {
text { content: "Hello", fontSize: 24 }
}
row { gap: 12 } {
box { fill: #e0e0e0, radius: 4 } { text { content: "A" } }
box { fill: #e0e0e0, radius: 4 } { text { content: "B" } }
}
}
}
Project layout
src/lexer.rs— tokenizersrc/parser.rs— recursive descent parsersrc/ast.rs— AST typessrc/value.rs— interpreter (eval) for expressionssrc/layout.rs— flex-like layout →LayoutNode+Rectsrc/renderer/— wgpu canvas (rects; text can be added via glyphon)src/app.rs— winit event loop, window, redrawsrc/main.rs— CLI entry, optional file path
Next steps
- Text rendering (glyphon)
- Hot-reload (notify) when the
.newtfile changes - Rounded rects in the shader
- Pan/zoom on the canvas