mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 21:53:41 +00:00

thorvg is going to use catch2 framework, this is a cleanup work before introducing catch2 utc. See Catch2: https://github.com/catchorg/Catch2/tree/v2.x
26 lines
840 B
HTML
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>
|