Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try again with proper build #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ if (Test-Path $dist/index.js) {
Remove-Item dist/index.js
}

em++ -O3 -std=c++20 (ls wasm/*.c) -s WASM=1 -s "ALLOW_MEMORY_GROWTH=1" -s "SINGLE_FILE=1" -o dist/temp.js
em++ -O3 -std=c++20 (ls wasm/*.c) -s WASM=1 -s "ALLOW_MEMORY_GROWTH=1" -s "SINGLE_FILE=1" -s "MODULARIZE=1" -s "EXPORT_ES6=1" -o dist/temp.js
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

cd $DIR && rm -f lib/*

cd $DIR && em++ -O3 -std=gnu++20 wasm/*.c --post-js src/potrace.js -s WASM=1 -s EXPORTED_FUNCTIONS='["_start"]' -s "ALLOW_MEMORY_GROWTH=1" -s "SINGLE_FILE=1" -o dist/temp.js
cd $DIR && em++ -O3 -std=gnu++20 wasm/*.c --post-js src/potrace.js -s WASM=1 -s EXPORTED_FUNCTIONS='["_start"]' -s "ALLOW_MEMORY_GROWTH=1" -s "SINGLE_FILE=1" -s "MODULARIZE=1" -s "EXPORT_ES6=1" -o dist/temp.js
13 changes: 8 additions & 5 deletions demo/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { potrace, init } from '../dist/index.js';
import potraceModule from '../dist/index.js';

(async () => {
const Module = await potraceModule();
// @connorjclark Unsure about the next two lines.
await Module.ready;
const potrace = Module._start;

const pre1 = document.querySelector('#pre1');
const pre2 = document.querySelector('#pre2');
const pre3 = document.querySelector('#pre3');
Expand All @@ -13,8 +18,6 @@ import { potrace, init } from '../dist/index.js';
const blob1 = await fetch('./logo.png').then((response) => response.blob());
const blob2 = await fetch('./avatar.jpg').then((response) => response.blob());

await init();

potrace(blob1, {
turdsize: 2,
turnpolicy: 4,
Expand All @@ -25,8 +28,8 @@ import { potrace, init } from '../dist/index.js';
extractcolors: true,
posterizelevel: 2,
posterizationalgorithm: 0, // 0: simple, 1: interpolation
}).then((svg) => {
div1.innerHTML = svg;
}) .then((svg) => {
=div1.innerHTML = svg;
svg = svg.replaceAll('><', '>\n<');
pre1.textContent = svg + '\n\n(' + svg.length + ')';
});
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

Loading