Incorporo-user commited on
Commit
d5d0fa2
·
verified ·
1 Parent(s): e469b24

Native transparency by default; harmonization held to the traced boundary (v=11)

Browse files
index.html CHANGED
@@ -187,7 +187,7 @@ footer .v{margin-left:auto}
187
  <button class="primary" id="go" disabled>Trace</button>
188
  <span class="status mono" id="status">loading the tracer…</span>
189
  </div>
190
- <p class="note" style="margin:2px 0 12px">Repeated shapes are harmonized by default &mdash; fewer paths and smaller SVGs; on very fine line art this can visibly shift geometry (CLI opt-out: <code class="mono">--no-harmonize</code>).</p>
191
 
192
  <div class="viewer empty" id="viewer"><span>Your input and the vector result appear here side by side. Scroll to zoom, drag to pan; both sides move together.</span></div>
193
  <div class="tools" id="livetools" hidden></div>
@@ -379,7 +379,7 @@ for (const b of document.querySelectorAll("#presets button")) b.addEventListener
379
 
380
  let worker = null;
381
  function makeWorker(){
382
- const url = A.workerUrl || "./worker.js?v=8";
383
  try { worker = new Worker(url, { type: "module" }); } catch (e) { worker = null; return; }
384
  worker.onmessage = (e) => {
385
  const m = e.data;
@@ -432,7 +432,7 @@ for (const n of ["365retailmarkets","adamo","1075thefan"]){
432
  const b = el("button", "", n); b.addEventListener("click", async () => { const r = await fetch(asset(n)); const bl = await r.blob(); pick(new File([bl], n + ".png", {type:"image/png"})); });
433
  $("samples").appendChild(b);
434
  }
435
- function options(){ return { precision:+$("precision").value, min_area:+$("min_area").value, colors:+$("colors").value, merge:+$("merge").value, max_dim:+$("max_dim").value, time_budget:+$("time_budget").value, no_background:$("no_background").checked, minify:$("minify").checked, margin:+$("margin").value, content_units:$("content_units").checked }; }
436
  function start(){ $("go").disabled = true; const t0 = performance.now(); live && live.busy(true, "Tracing…"); timer = setInterval(() => live && live.busy(true, `Tracing… ${((performance.now()-t0)/1000).toFixed(1)} s`), 100); }
437
  function finish(){ $("go").disabled = false; clearInterval(timer); live && live.busy(false); }
438
  $("go").addEventListener("click", () => {
 
187
  <button class="primary" id="go" disabled>Trace</button>
188
  <span class="status mono" id="status">loading the tracer…</span>
189
  </div>
190
+ <p class="note" style="margin:2px 0 12px">Repeated shapes are harmonized by default &mdash; a copy is redrawn from the shared geometry only where that stays within 0.1&nbsp;px of what was traced and saves parameters (CLI opt-out: <code class="mono">--no-harmonize</code>).</p>
191
 
192
  <div class="viewer empty" id="viewer"><span>Your input and the vector result appear here side by side. Scroll to zoom, drag to pan; both sides move together.</span></div>
193
  <div class="tools" id="livetools" hidden></div>
 
379
 
380
  let worker = null;
381
  function makeWorker(){
382
+ const url = A.workerUrl || "./worker.js?v=11";
383
  try { worker = new Worker(url, { type: "module" }); } catch (e) { worker = null; return; }
384
  worker.onmessage = (e) => {
385
  const m = e.data;
 
432
  const b = el("button", "", n); b.addEventListener("click", async () => { const r = await fetch(asset(n)); const bl = await r.blob(); pick(new File([bl], n + ".png", {type:"image/png"})); });
433
  $("samples").appendChild(b);
434
  }
435
+ function options(){ return { precision:+$("precision").value, min_area:+$("min_area").value, colors:+$("colors").value, merge:+$("merge").value, max_dim:+$("max_dim").value, time_budget:+$("time_budget").value, no_background:$("no_background").checked, minify:$("minify").checked, margin:+$("margin").value, content_units:$("content_units").checked, cutout:$("no_background").checked }; }
436
  function start(){ $("go").disabled = true; const t0 = performance.now(); live && live.busy(true, "Tracing…"); timer = setInterval(() => live && live.busy(true, `Tracing… ${((performance.now()-t0)/1000).toFixed(1)} s`), 100); }
437
  function finish(){ $("go").disabled = false; clearInterval(timer); live && live.busy(false); }
438
  $("go").addEventListener("click", () => {
pkg-threads/inkvec_wasm.d.ts CHANGED
@@ -19,9 +19,11 @@ export function threads_available(): boolean;
19
  * defaults 0.1, 2, 64, 0.035 when unsure; the merge default is
20
  * `inkvec_trace::color::DEFAULT_MERGE_DISTANCE`); `max_dim` and `time_budget` bound the
21
  * work; `no_background`, `minify`, `margin`, `content_units` shape the output. `max_dim = 0`
22
- * means no cap.
 
 
23
  */
24
- export function trace(bytes: Uint8Array, precision: number, min_area: number, colors: number, merge: number, max_dim: number, time_budget: number, no_background: boolean, minify: boolean, margin: number, content_units: boolean): string;
25
 
26
  /**
27
  * The tracer's version, for the page footer.
@@ -45,7 +47,7 @@ export interface InitOutput {
45
  readonly __wbg_wbg_rayon_poolbuilder_free: (a: number, b: number) => void;
46
  readonly initThreadPool: (a: number) => any;
47
  readonly threads_available: () => number;
48
- readonly trace: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number, number, number];
49
  readonly version: () => [number, number];
50
  readonly wbg_rayon_poolbuilder_build: (a: number) => void;
51
  readonly wbg_rayon_poolbuilder_numThreads: (a: number) => number;
 
19
  * defaults 0.1, 2, 64, 0.035 when unsure; the merge default is
20
  * `inkvec_trace::color::DEFAULT_MERGE_DISTANCE`); `max_dim` and `time_budget` bound the
21
  * work; `no_background`, `minify`, `margin`, `content_units` shape the output. `max_dim = 0`
22
+ * means no cap. `cutout` is `--cutout`: an input's transparency is carried into the SVG
23
+ * (holes stay holes, a flat wash keeps its opacity); it changes nothing for an opaque
24
+ * input.
25
  */
26
+ export function trace(bytes: Uint8Array, precision: number, min_area: number, colors: number, merge: number, max_dim: number, time_budget: number, no_background: boolean, minify: boolean, margin: number, content_units: boolean, cutout: boolean): string;
27
 
28
  /**
29
  * The tracer's version, for the page footer.
 
47
  readonly __wbg_wbg_rayon_poolbuilder_free: (a: number, b: number) => void;
48
  readonly initThreadPool: (a: number) => any;
49
  readonly threads_available: () => number;
50
+ readonly trace: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => [number, number, number, number];
51
  readonly version: () => [number, number];
52
  readonly wbg_rayon_poolbuilder_build: (a: number) => void;
53
  readonly wbg_rayon_poolbuilder_numThreads: (a: number) => number;
pkg-threads/inkvec_wasm.js CHANGED
@@ -31,7 +31,9 @@ export function threads_available() {
31
  * defaults 0.1, 2, 64, 0.035 when unsure; the merge default is
32
  * `inkvec_trace::color::DEFAULT_MERGE_DISTANCE`); `max_dim` and `time_budget` bound the
33
  * work; `no_background`, `minify`, `margin`, `content_units` shape the output. `max_dim = 0`
34
- * means no cap.
 
 
35
  * @param {Uint8Array} bytes
36
  * @param {number} precision
37
  * @param {number} min_area
@@ -43,15 +45,16 @@ export function threads_available() {
43
  * @param {boolean} minify
44
  * @param {number} margin
45
  * @param {boolean} content_units
 
46
  * @returns {string}
47
  */
48
- export function trace(bytes, precision, min_area, colors, merge, max_dim, time_budget, no_background, minify, margin, content_units) {
49
  let deferred3_0;
50
  let deferred3_1;
51
  try {
52
  const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
53
  const len0 = WASM_VECTOR_LEN;
54
- const ret = wasm.trace(ptr0, len0, precision, min_area, colors, merge, max_dim, time_budget, no_background, minify, margin, content_units);
55
  var ptr2 = ret[0];
56
  var len2 = ret[1];
57
  if (ret[3]) {
 
31
  * defaults 0.1, 2, 64, 0.035 when unsure; the merge default is
32
  * `inkvec_trace::color::DEFAULT_MERGE_DISTANCE`); `max_dim` and `time_budget` bound the
33
  * work; `no_background`, `minify`, `margin`, `content_units` shape the output. `max_dim = 0`
34
+ * means no cap. `cutout` is `--cutout`: an input's transparency is carried into the SVG
35
+ * (holes stay holes, a flat wash keeps its opacity); it changes nothing for an opaque
36
+ * input.
37
  * @param {Uint8Array} bytes
38
  * @param {number} precision
39
  * @param {number} min_area
 
45
  * @param {boolean} minify
46
  * @param {number} margin
47
  * @param {boolean} content_units
48
+ * @param {boolean} cutout
49
  * @returns {string}
50
  */
51
+ export function trace(bytes, precision, min_area, colors, merge, max_dim, time_budget, no_background, minify, margin, content_units, cutout) {
52
  let deferred3_0;
53
  let deferred3_1;
54
  try {
55
  const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
56
  const len0 = WASM_VECTOR_LEN;
57
+ const ret = wasm.trace(ptr0, len0, precision, min_area, colors, merge, max_dim, time_budget, no_background, minify, margin, content_units, cutout);
58
  var ptr2 = ret[0];
59
  var len2 = ret[1];
60
  if (ret[3]) {
pkg-threads/inkvec_wasm_bg.wasm CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:48381fa26e59e2f6ebf832b59ccfd384b3f08d2c371c1edf7d824fdaeb023815
3
- size 3036282
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b3ccebb870dc2387ecd1308736326103be62f5bd2b16a7bc6231ee5036f59d39
3
+ size 3228020
pkg-threads/inkvec_wasm_bg.wasm.d.ts CHANGED
@@ -3,7 +3,7 @@
3
  export const __wbg_wbg_rayon_poolbuilder_free: (a: number, b: number) => void;
4
  export const initThreadPool: (a: number) => any;
5
  export const threads_available: () => number;
6
- export const trace: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number, number, number];
7
  export const version: () => [number, number];
8
  export const wbg_rayon_poolbuilder_build: (a: number) => void;
9
  export const wbg_rayon_poolbuilder_numThreads: (a: number) => number;
 
3
  export const __wbg_wbg_rayon_poolbuilder_free: (a: number, b: number) => void;
4
  export const initThreadPool: (a: number) => any;
5
  export const threads_available: () => number;
6
+ export const trace: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => [number, number, number, number];
7
  export const version: () => [number, number];
8
  export const wbg_rayon_poolbuilder_build: (a: number) => void;
9
  export const wbg_rayon_poolbuilder_numThreads: (a: number) => number;
pkg-threads/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.js CHANGED
@@ -51,7 +51,7 @@ waitForMsgType(self, 'wasm_bindgen_worker_init').then(async ({ init, receiver })
51
  // OTOH, even though it can't be inlined, it should be still reasonably
52
  // cheap since the requested file is already in cache (it was loaded by
53
  // the main thread).
54
- const pkg = await import('../../../inkvec_wasm.js?v=8');
55
  await pkg.default(init);
56
  postMessage({ type: 'wasm_bindgen_worker_ready' });
57
  pkg.wbg_rayon_start_worker(receiver);
 
51
  // OTOH, even though it can't be inlined, it should be still reasonably
52
  // cheap since the requested file is already in cache (it was loaded by
53
  // the main thread).
54
+ const pkg = await import('../../../inkvec_wasm.js?v=11');
55
  await pkg.default(init);
56
  postMessage({ type: 'wasm_bindgen_worker_ready' });
57
  pkg.wbg_rayon_start_worker(receiver);
pkg/inkvec_wasm.d.ts CHANGED
@@ -17,9 +17,11 @@ export function threads_available(): boolean;
17
  * defaults 0.1, 2, 64, 0.035 when unsure; the merge default is
18
  * `inkvec_trace::color::DEFAULT_MERGE_DISTANCE`); `max_dim` and `time_budget` bound the
19
  * work; `no_background`, `minify`, `margin`, `content_units` shape the output. `max_dim = 0`
20
- * means no cap.
 
 
21
  */
22
- export function trace(bytes: Uint8Array, precision: number, min_area: number, colors: number, merge: number, max_dim: number, time_budget: number, no_background: boolean, minify: boolean, margin: number, content_units: boolean): string;
23
 
24
  /**
25
  * The tracer's version, for the page footer.
@@ -31,7 +33,7 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
31
  export interface InitOutput {
32
  readonly memory: WebAssembly.Memory;
33
  readonly threads_available: () => number;
34
- readonly trace: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number, number, number];
35
  readonly version: () => [number, number];
36
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
37
  readonly __wbindgen_malloc: (a: number, b: number) => number;
 
17
  * defaults 0.1, 2, 64, 0.035 when unsure; the merge default is
18
  * `inkvec_trace::color::DEFAULT_MERGE_DISTANCE`); `max_dim` and `time_budget` bound the
19
  * work; `no_background`, `minify`, `margin`, `content_units` shape the output. `max_dim = 0`
20
+ * means no cap. `cutout` is `--cutout`: an input's transparency is carried into the SVG
21
+ * (holes stay holes, a flat wash keeps its opacity); it changes nothing for an opaque
22
+ * input.
23
  */
24
+ export function trace(bytes: Uint8Array, precision: number, min_area: number, colors: number, merge: number, max_dim: number, time_budget: number, no_background: boolean, minify: boolean, margin: number, content_units: boolean, cutout: boolean): string;
25
 
26
  /**
27
  * The tracer's version, for the page footer.
 
33
  export interface InitOutput {
34
  readonly memory: WebAssembly.Memory;
35
  readonly threads_available: () => number;
36
+ readonly trace: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => [number, number, number, number];
37
  readonly version: () => [number, number];
38
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
39
  readonly __wbindgen_malloc: (a: number, b: number) => number;
pkg/inkvec_wasm.js CHANGED
@@ -20,7 +20,9 @@ export function threads_available() {
20
  * defaults 0.1, 2, 64, 0.035 when unsure; the merge default is
21
  * `inkvec_trace::color::DEFAULT_MERGE_DISTANCE`); `max_dim` and `time_budget` bound the
22
  * work; `no_background`, `minify`, `margin`, `content_units` shape the output. `max_dim = 0`
23
- * means no cap.
 
 
24
  * @param {Uint8Array} bytes
25
  * @param {number} precision
26
  * @param {number} min_area
@@ -32,15 +34,16 @@ export function threads_available() {
32
  * @param {boolean} minify
33
  * @param {number} margin
34
  * @param {boolean} content_units
 
35
  * @returns {string}
36
  */
37
- export function trace(bytes, precision, min_area, colors, merge, max_dim, time_budget, no_background, minify, margin, content_units) {
38
  let deferred3_0;
39
  let deferred3_1;
40
  try {
41
  const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
42
  const len0 = WASM_VECTOR_LEN;
43
- const ret = wasm.trace(ptr0, len0, precision, min_area, colors, merge, max_dim, time_budget, no_background, minify, margin, content_units);
44
  var ptr2 = ret[0];
45
  var len2 = ret[1];
46
  if (ret[3]) {
 
20
  * defaults 0.1, 2, 64, 0.035 when unsure; the merge default is
21
  * `inkvec_trace::color::DEFAULT_MERGE_DISTANCE`); `max_dim` and `time_budget` bound the
22
  * work; `no_background`, `minify`, `margin`, `content_units` shape the output. `max_dim = 0`
23
+ * means no cap. `cutout` is `--cutout`: an input's transparency is carried into the SVG
24
+ * (holes stay holes, a flat wash keeps its opacity); it changes nothing for an opaque
25
+ * input.
26
  * @param {Uint8Array} bytes
27
  * @param {number} precision
28
  * @param {number} min_area
 
34
  * @param {boolean} minify
35
  * @param {number} margin
36
  * @param {boolean} content_units
37
+ * @param {boolean} cutout
38
  * @returns {string}
39
  */
40
+ export function trace(bytes, precision, min_area, colors, merge, max_dim, time_budget, no_background, minify, margin, content_units, cutout) {
41
  let deferred3_0;
42
  let deferred3_1;
43
  try {
44
  const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
45
  const len0 = WASM_VECTOR_LEN;
46
+ const ret = wasm.trace(ptr0, len0, precision, min_area, colors, merge, max_dim, time_budget, no_background, minify, margin, content_units, cutout);
47
  var ptr2 = ret[0];
48
  var len2 = ret[1];
49
  if (ret[3]) {
pkg/inkvec_wasm_bg.wasm CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:f20be44f61e2270d8687e517fb79a05a9f9702e49499afbb11cbbcbeb47c2b9e
3
- size 2997588
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:91885871972c755a6086c08c8d6ad67439814fc2dd200bb2d186a4df135ab05f
3
+ size 3189650
pkg/inkvec_wasm_bg.wasm.d.ts CHANGED
@@ -2,7 +2,7 @@
2
  /* eslint-disable */
3
  export const memory: WebAssembly.Memory;
4
  export const threads_available: () => number;
5
- export const trace: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number, number, number];
6
  export const version: () => [number, number];
7
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
8
  export const __wbindgen_malloc: (a: number, b: number) => number;
 
2
  /* eslint-disable */
3
  export const memory: WebAssembly.Memory;
4
  export const threads_available: () => number;
5
+ export const trace: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => [number, number, number, number];
6
  export const version: () => [number, number];
7
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
8
  export const __wbindgen_malloc: (a: number, b: number) => number;
worker.js CHANGED
@@ -15,7 +15,7 @@
15
  // import alone busts the JavaScript and never the WebAssembly — the wrong way round, since
16
  // the bindings rarely change and the wasm changes on every build. Bump it when `pkg/` or
17
  // `pkg-threads/` is rebuilt.
18
- const V = "v=8";
19
 
20
  const isolated = typeof crossOriginIsolated !== "undefined" && crossOriginIsolated;
21
 
@@ -63,7 +63,8 @@ onmessage = async (e) => {
63
  const t0 = performance.now();
64
  try {
65
  const svg = mod.trace(bytes, o.precision, o.min_area, o.colors, o.merge, o.max_dim,
66
- o.time_budget, o.no_background, o.minify, o.margin, o.content_units);
 
67
  postMessage({ type: "done", id, svg, ms: performance.now() - t0 });
68
  } catch (err) {
69
  postMessage({ type: "error", id, error: String(err) });
 
15
  // import alone busts the JavaScript and never the WebAssembly — the wrong way round, since
16
  // the bindings rarely change and the wasm changes on every build. Bump it when `pkg/` or
17
  // `pkg-threads/` is rebuilt.
18
+ const V = "v=11";
19
 
20
  const isolated = typeof crossOriginIsolated !== "undefined" && crossOriginIsolated;
21
 
 
63
  const t0 = performance.now();
64
  try {
65
  const svg = mod.trace(bytes, o.precision, o.min_area, o.colors, o.merge, o.max_dim,
66
+ o.time_budget, o.no_background, o.minify, o.margin, o.content_units,
67
+ o.cutout);
68
  postMessage({ type: "done", id, svg, ms: performance.now() - t0 });
69
  } catch (err) {
70
  postMessage({ type: "error", id, error: String(err) });