mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-28 07:51:07 +00:00
This commit migrates all our examples to using `wasm-pack build` to compile their code and run `wasm-bindgen`. This should make it a bit easier to understand the examples as there's less to follow during the build step. Webpack projects are all using `@wasm-tool/wasm-pack-plugin` as well so the build step is simple `npm run serve`. Other examples which retain `build.sh` are just using `wasm-pack build` now
19 lines
670 B
JavaScript
19 lines
670 B
JavaScript
import('./pkg/julia_set')
|
|
.then(wasm => {
|
|
const canvas = document.getElementById('drawing');
|
|
const ctx = canvas.getContext('2d');
|
|
|
|
const realInput = document.getElementById('real');
|
|
const imaginaryInput = document.getElementById('imaginary');
|
|
const renderBtn = document.getElementById('render');
|
|
|
|
renderBtn.addEventListener('click', () => {
|
|
const real = parseFloat(realInput.value) || 0;
|
|
const imaginary = parseFloat(imaginaryInput.value) || 0;
|
|
wasm.draw(ctx, 600, 600, real, imaginary);
|
|
});
|
|
|
|
wasm.draw(ctx, 600, 600, -0.15, 0.65);
|
|
})
|
|
.catch(console.error);
|