Skip to content

Instantly share code, notes, and snippets.

@bjfish
Created Apr 25, 2018
Embed
What would you like to do?
Wasm Memory Visualization
<html><head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/two.js/0.6.0/two.js"></script>
</head>
<body>
<div id="main"></div>
<script>
var two = new Two({ height: 1000, width: 1200
}).appendTo(document.getElementById("main"));
var padHeight = 100;
var padWidth = 100;
var columns = 64;
var width = 25;
var height = 25;
var array = new Uint8Array([1,2,0,4,5,0,7,8,1,2,0,4, 0, 2]);
for (var i = 0; i < 10; i++) {
var rect = two.makeRectangle(((i % columns) * height) + padWidth, (Math.floor(i / columns) * height) + padHeight, width ,height);
rect.fill = array[i] > 0 ? 'green': 'gray';
}
two.update();
</script>
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment