Permalink
Browse files

Add a html page that loads and runs the wasm bin

Sadly, `println!` is a no-op and `panic!` doesn't show any custom
messages (but it does actually show an error which is the important
part), so the debugging may be a bit rough.

But we are able to call Rust code from the browser and vice versa.
  • Loading branch information...
tomassedovic committed Dec 13, 2017
1 parent d9589d9 commit 2b3bd82bac354cca37eef672bd435c9f97b1e595
Showing with 25 additions and 0 deletions.
  1. +25 −0 index.html
@@ -0,0 +1,25 @@
<body>
</body>
<script>
var width = 80;
var height = 60;
var squareSize = 10;
var c = document.createElement('canvas');
c.width = width*squareSize;
c.height = height*squareSize;
document.body.append(c);
var ctx = c.getContext('2d');
ctx.textAlign = "center";
ctx.font = '12px arial';
fetch('target/wasm32-unknown-unknown/release/dose-response.wasm')
.then(response => response.arrayBuffer())
.then(bytes => WebAssembly.instantiate(bytes, {
env: {
}
}))
.then(results => {
console.log("The game has finished.");
});
</script>

0 comments on commit 2b3bd82

Please sign in to comment.