A collection of examples of how WebAssembly can be used with Angular
14 |
15 |
16 |
18 | Home 19 | 20 | GitHub 22 | 23 | Twitter 25 |
26 |This example shows how you can render 3D graphics using WebGL and manipulate it on the fly.
5 |This example allows you to convert simple bitmaps to ASCII art.
5 |{{ output }}44 |
5 | Just start clicking randomly on the page. This example binds to window click directly in the C code by using 6 | Emscripten's library. The C code uses printf, which I have overloaded to add items to the list instead of 7 | printing them to the console (default behavior). 8 |
9 |5 | This example shows the "raw" communication between JavaScript and WebAssembly without using Emscripten's glue 6 | code. Inspired by 7 | devlucky, the example demonstrates the performance difference between JavaScript and WebAssembly when calculating 13 | Fibonacci series using three different implementations: loop, recursion, memoization. 14 |
15 | 16 |69 | | Loop | 70 |Recursive | 71 |Memoization | 72 |
---|---|---|---|
{{ result.name }} | 77 |81 | {{ result[func] | humanizeTime }} {{ fastDiff(result, func) }} 82 | | 83 |
5 | This example shows how to pass complex data between JavaScript and WebAssembly. It uses Emscripten's 6 | embind 12 | to make a C++ struct available to JavaScript. 13 |
14 |94 | I have the very unique ID {{ record.id }} generated as a hash of my data. 95 |
96 |5 | A simple 6 | Proof of Work system 7 | (similar to the one used in bitcoin). You need to provide an input string and the required number of leading 8 | zeros. The program tries to find a nonce (by appending random numbers to your input string), whose SHA-256 hash 9 | will have the same number of leading zeros. Beware, the more leading zeros you require, the more time it will 10 | take, the more memory will be needed. You can set the required leading zeros to 3 and see what happens :-) It 11 | could be unstable for higher number of leading zeros. 12 |
13 |Leading zeros | 59 |Iterations | 60 |Time taken | 61 |
---|---|---|
{{ item.leadingZeros }} | 66 |{{ item.iterations }} | 67 |{{ item.timeTaken | humanizeTime }} | 68 |
This example allows you to convert text to ASCII art on the fly.
5 |39 | {{ output }} 40 |41 |