Skip to content

Basic infrastructure for integrating xilem_web - #131

Draft
raphlinus wants to merge 4 commits into
mainfrom
xilem_web
Draft

raphlinus wants to merge 4 commits into
mainfrom
xilem_web

Conversation

@raphlinus

Copy link
Copy Markdown
Contributor

This adds a very basic xilem-web integration into the blog. Currently I'm using wasm-pack --target web to build the wasm, then copying rust_demo{.js,_bg.wasm} into static/rust. These steps would be done by CI.

Note that the Vello web demo is a bit similar. It uses wasm-bindgen directly, and that might be more lightweight; in this case, it's likely wasm-pack is a pretty thin layer around it.

This branch currently has no interesting content. The plan is to import the interactive demo from raphlinus/fast-stroke, along with nicer UI for controlling the experiments (currently, my main workflow is editing the code).

This is basically the wasm-pack demo.
Embeds xilem_web into the blog, does counter demo.
The idea is that these should be generated by CI, but that's not in place just yet.
This should build the WASM for the Rust code, but hasn't been validated. At least the check build should work on PR upload.
@raphlinus

Copy link
Copy Markdown
Contributor Author

Ok, I've now added CI, which does successfully build the wasm, but the deployment is not tested. It looks like wasm-bindgen is sufficient, I don't think the wasm-pack wrapper is actually needed.

raphlinus added a commit that referenced this pull request Sep 21, 2026
Adds a wiki page comparing four squircle constructions, with an embedded
xilem_web demo for exploring them, following the approach prototyped in #131.

Demos live in a crates/ workspace, matching the layout already used on the
log-aesthetic branch.
Each is a cdylib exporting start(id), which wasm-bindgen packages into
static/rust/ for the page to import and mount.
Each also has a bin target so `trunk serve` still works for local iteration
against that same entry point; site builds pass --lib, so it is never compiled
in CI.

crates/build.sh is what both the deploy workflow and local use beside
`zola serve` run, so the two cannot drift.
It builds only the crates that declare a cdylib, so native tools that share
this workspace are never compiled for wasm.

The tester is ported from a standalone prototype, with the formatting reworked
for embedding: the radios and the zoom toggle are labelled, the curvature
profile moved out of the shape's coordinate space into its own panel, the SVGs
carry a viewBox instead of fixed pixel sizes so they reflow, and stroke colors
come from CSS custom properties so the demo follows the site's light and dark
themes.

Two fixes to the ported math:

Superellipse::curvature_profile swept only a half quadrant, while the other
constructions sweep a full one, so selecting it silently halved the plot's arc
length axis.

render_profile now drops non-finite samples and breaks the polyline across the
gap.
At the bottom of the gauge range the Figma corner collapses to a cubic whose
first three control points coincide, making its curvature 0/0, and a single NaN
makes a browser reject the whole SVG path.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant