-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
64 lines (42 loc) · 1.27 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<html>
<body>
<textarea id="output_area" style="width:100%; height:50%"></textarea>
<script>
function output(text) {
document.getElementById("output_area").append(text + "\n\n");
}
function pointer() {
var x = event.clientX; // Get the horizontal coordinate
var y = event.clientY; // Get the vertical coordinate
var coor = "X coords: " + x + ", Y coords: " + y;
multiplycursor = Module.cwrap('multiply', 'number', ['number', 'number']);
output(multiplycursor(x, y));
}
var Module = {
'print': function (text) {
output("print\n" + text);
},
'printErr': function (text) {
output("printErr\n" + text);
},
onRuntimeInitialized: function() {
Module._multiply;
}
};
</script>
<script src="multiply.js"></script>
<script>
var importObject = {
imports: { imported_func: arg => console.log(arg) }
};
fetch('multiply.wasm').then(response =>
response.arrayBuffer()
).then(bytes =>
WebAssembly.instantiate(bytes, importObject)
).then(results => {
results.instance.exports.exported_func();
});
</script>
<input type="button" style="height:50%;width:100%" value="Button Text" onClick="pointer()"/>
</body>
</html>