thorvg/test/wasm_test.html
Shinwoo Kim 1e030004ed wasm test: update sample index.html
Update index.html according to updated wasm interface.
Missed chance to update index.html during review.
2020-10-15 15:09:10 +09:00

26 lines
840 B
HTML

<!doctype html>
<html>
<canvas id="thorvg" width="320" height="320"></canvas>
<script>
var Module = {
onRuntimeInitialized: function() {
class SvgViewer {
constructor() {
var thorvg = new Module.ThorvgWasm();
this.canvas = document.getElementById("thorvg");
var context = this.canvas.getContext('2d');
thorvg.load("", this.canvas.width, this.canvas.height);
var buffer = thorvg.render();
var clampedBuffer = Uint8ClampedArray.from(buffer);
var imageData = new ImageData(clampedBuffer, this.canvas.width, this.canvas.height);
context.putImageData(imageData, 0, 0);
}
}
var instance = new SvgViewer();
}
};
</script>
<script src="thorvg-wasm.js"></script>
</html>