Skip to content

Commit

Permalink
Refactored playground
Browse files Browse the repository at this point in the history
  • Loading branch information
gammelalf committed Jun 13, 2022
1 parent 78d00d5 commit bfa19b6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 0 additions & 4 deletions playground/run.sh

This file was deleted.

12 changes: 6 additions & 6 deletions playground/index.html → wasm/playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@
ctx.lineCap = 'round';
ctx.fillStyle = "white";
ctx.fillRect(0, 0, canvas.width, canvas.height);
if (gammalg) {
if (nbezier) {
for (const {bobbles, color} of curves) {
curve = new gammalg.Curve(bobbles);
curve = new nbezier.Curve(bobbles);
curve.draw(ctx, color);
if (drawConfig.handles) curve.drawHandles(ctx, color);
if (drawConfig.ticks) curve.drawTicks(ctx, color);
Expand All @@ -108,8 +108,8 @@
}
if (curves.length === 2) {
let [a, b] = curves;
a = new gammalg.Curve(a.bobbles);
b = new gammalg.Curve(b.bobbles);
a = new nbezier.Curve(a.bobbles);
b = new nbezier.Curve(b.bobbles);
a.drawIntersections(b, ctx, "black");
}
} else {
Expand Down Expand Up @@ -159,9 +159,9 @@
</script>
<script>
(async function() {
const {default: init, ...module} = await import("/wasm/pkg/gammalg_wasm.js");
const {default: init, ...module} = await import("/pkg/nbezier_wasm.js");
await init();
window.gammalg = module;
window.nbezier = module;
})();
</script>
</body>
Expand Down
9 changes: 9 additions & 0 deletions wasm/playground/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
WASM=./pkg/nbezier_wasm.js
if [ -f "$WASM" ]; then
echo "Visit http://0.0.0.0:8000/playground/"
/usr/bin/env python3 -m http.server
else
echo "Please run from inside the wasm crate root"
echo "Make sure you have compiled it using wasm-pack --target web"
fi
File renamed without changes.

0 comments on commit bfa19b6

Please sign in to comment.