AngelScript-based scripting engine for TrussC Web Playground.
TrussSketch powers tcScript, a browser-based creative coding playground. Write C++-like script code and see it run instantly in WebAssembly.
float hue = 0.0f;
void setup() {
logNotice("Hello from TrussSketch!");
}
void update() {
hue += 0.005f;
if (hue > 1.0f) hue = 0.0f;
}
void draw() {
clear(1.0f);
for (int i = 0; i < 8; i++) {
float angle = TAU * float(i) / 8.0f + getElapsedTimef();
float x = getWindowWidth() / 2.0f + cos(angle) * 120.0f;
float y = getWindowHeight() / 2.0f + sin(angle) * 120.0f;
setColorHSB(fmod(hue + float(i) * 0.125f, 1.0f), 0.7f, 0.9f);
drawCircle(x, y, 25.0f);
}
}
void mousePressed(float x, float y, int button) {
logNotice("Click at " + x + ", " + y);
}- Instant feedback: Edit code and click Run to see changes immediately
- Zero server load: Everything runs client-side in WebAssembly
- Chromebook friendly: Works on low-spec devices
- Share your creations: Generate URLs to share your sketches
- CMake 3.20+
- Emscripten SDK (for Web builds)
- TrussC library
./build-web.commandOr manually:
mkdir build-web && cd build-web
emcmake cmake ..
cmake --build .Output files land in bin/:
TrussSketch.jsTrussSketch.wasm
After building, deploy both files to Cloudflare R2:
cd bin
wrangler r2 object put trussc-wasm/sketch/TrussSketch.wasm --file TrussSketch.wasm --remote
wrangler r2 object put trussc-wasm/sketch/TrussSketch.js --file TrussSketch.js --remotemkdir build-macos && cd build-macos
cmake ..
cmake --build .See the online reference: trussc.org/tcscript/reference/
The full TrussC C++ API reference lives at trussc.org/reference/.
TrussSketch/
├── src/
│ ├── main.cpp # Entry point, Emscripten exports
│ ├── tcApp.cpp/h # TrussC app with script lifecycle
│ └── tcScriptHost.cpp/h # AngelScript wrapper with TrussC bindings
├── testScript/ # Sample .tcs scripts used for local testing
├── CMakeLists.txt
├── ROADMAP.md # Planned features
└── README.md
AngelScript itself is pulled in via CMake FetchContent (see CMakeLists.txt), so there is no vendored script engine in the source tree.
The API reference is generated from TrussC/docs/api-definition.yaml:
cd ../docs/scripts
node generate-docs.jsThis generates tcscript-api.js for the web playground's autocomplete and reference page,
and fills the auto-generated C++ API index in TrussC/docs/FOR_AI_ASSISTANT.md.
MIT License - see TrussC for details.