@arraypress/covers 1.4.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,137 @@
1
+ /**
2
+ * The `construction` layer.
3
+ *
4
+ * @module layers/construction
5
+ */
6
+
7
+ import { attrs, num } from '@logomarks/image-effects/svg';
8
+ import { toHex } from '@logomarks/image-effects/color';
9
+ import { len } from '@logomarks/image-effects/length';
10
+ import { wrap } from './util.js';
11
+ import { markGuides } from './guides.js';
12
+ import { layerBox, fitMark, markPaths } from './mark-draw.js';
13
+
14
+ /**
15
+ * `construction` — a mark drawn over its own construction, as a
16
+ * construction sheet draws it: a light dashed square grid behind (its
17
+ * cells a fraction of the mark's size, centred on it), the mark's bounding
18
+ * box, a centre cross, the circles inscribed in its box and round its
19
+ * outline, the circles its curves are drawn on (each centre marked) and
20
+ * the lines its straight edges lie on, run across the box, all dashed in
21
+ * one thin accent. The guides are read from the mark's own paths
22
+ * (`markGuides`). Where the mark covers them they show faintly over it.
23
+ *
24
+ * Options: `markup` (512 grid), `x`, `y`, `width`, `height` (the box the
25
+ * sheet fills; default the canvas), `size` (the share of the box's
26
+ * shorter side the mark's longest side takes, 0.6), `grid` (cells across
27
+ * the mark's longest side, 8; 0 none), `circles` and `lines` (the most of
28
+ * each, 6), `color` (the guides; default the accent), `gridColor`
29
+ * (default `color`), `gridOpacity` (0.3), `markColor` (default `text`;
30
+ * `'none'` leaves the mark out), `over` (the guides' opacity over the
31
+ * mark, 0.4), `stroke` (px, `'0.15vmin'`).
32
+ *
33
+ * @param {any} layer
34
+ * @param {import('../layers.js').RenderContext} ctx
35
+ * @returns {import('../layers.js').Markup}
36
+ *
37
+ * @example
38
+ * { type: 'construction', markup: mark, x: 24, y: 60, width: 352, height: 380, color: '#3b82f6', markColor: '#f4f4f2' }
39
+ */
40
+ export function construction(layer, ctx) {
41
+ const g = markGuides(layer.markup, { circles: layer.circles ?? 6, lines: layer.lines ?? 6 });
42
+ if (!g) return { defs: '', body: '' };
43
+ const area = layerBox(layer, ctx);
44
+ const fit = fitMark(g.box, area, layer.size ?? 0.6);
45
+ const { k } = fit;
46
+ const X = (/** @type {number} */ x) => x * k + fit.dx;
47
+ const Y = (/** @type {number} */ y) => y * k + fit.dy;
48
+ const color = layer.color ? toHex(layer.color) : ctx.palette.accent;
49
+ const sw = len(layer.stroke, ctx.canvas, '0.15vmin');
50
+ const dash = `${num(sw * 6)} ${num(sw * 4)}`;
51
+ const line = (/** @type {Record<string, any>} */ a) => `<path${attrs({ fill: 'none', ...a })}/>`;
52
+
53
+ // The box, its centre and the mark's longest side, canvas units.
54
+ const bx = X(g.box.x), by = Y(g.box.y), bw = g.box.width * k, bh = g.box.height * k;
55
+ const cx = bx + bw / 2, cy = by + bh / 2;
56
+ const side = Math.max(bw, bh);
57
+ const { x: ax, y: ay, width: aw, height: ah } = area;
58
+
59
+ // The grid: cells of side / grid, lines through the mark's centre.
60
+ let grid = '';
61
+ const cells = Math.round(layer.grid ?? 8);
62
+ if (cells > 0) {
63
+ const u = side / cells;
64
+ let d = '';
65
+ for (let x = cx - Math.floor((cx - ax) / u) * u; x <= ax + aw + 1e-6; x += u) d += `M${num(x)} ${num(ay)}V${num(ay + ah)}`;
66
+ for (let y = cy - Math.floor((cy - ay) / u) * u; y <= ay + ah + 1e-6; y += u) d += `M${num(ax)} ${num(y)}H${num(ax + aw)}`;
67
+ grid = line({ d, stroke: layer.gridColor ? toHex(layer.gridColor) : color, 'stroke-width': num(sw * 0.8, 3), 'stroke-dasharray': `${num(sw * 3)} ${num(sw * 3)}`, opacity: num(layer.gridOpacity ?? 0.3, 3) });
68
+ }
69
+
70
+ // Keylines: the box (solid), the centre cross and the inscribed and circumscribed circles (dashed, lighter).
71
+ let keys = line({ d: `M${num(bx)} ${num(by)}h${num(bw)}v${num(bh)}h${num(-bw)}Z`, stroke: color, 'stroke-width': num(sw, 3) });
72
+ keys += line({ d: `M${num(ax)} ${num(cy)}H${num(ax + aw)}M${num(cx)} ${num(ay)}V${num(ay + ah)}`, stroke: color, 'stroke-width': num(sw, 3), 'stroke-dasharray': dash, opacity: 0.6 });
73
+ keys += line({ d: circlePath(cx, cy, g.inscribed * k) + circlePath(cx, cy, g.circumscribed * k), stroke: color, 'stroke-width': num(sw, 3), 'stroke-dasharray': dash, opacity: 0.6 });
74
+
75
+ // The mark's own circles, each centre marked, and its edges' lines across the box.
76
+ let d = '';
77
+ let ticks = '';
78
+ const t = sw * 4;
79
+ for (const c of g.circles) {
80
+ const [x, y] = [X(c.cx), Y(c.cy)];
81
+ d += circlePath(x, y, c.r * k);
82
+ ticks += `M${num(x - t)} ${num(y)}h${num(2 * t)}M${num(x)} ${num(y - t)}v${num(2 * t)}`;
83
+ }
84
+ let lines = '';
85
+ for (const l of g.lines) {
86
+ const seg = clipLine(X(l.x), Y(l.y), Math.cos(l.angle), Math.sin(l.angle), area);
87
+ if (seg) lines += `M${num(seg[0])} ${num(seg[1])}L${num(seg[2])} ${num(seg[3])}`;
88
+ }
89
+ let guides = keys;
90
+ if (d) guides += line({ d, stroke: color, 'stroke-width': num(sw, 3), 'stroke-dasharray': dash });
91
+ if (lines) guides += line({ d: lines, stroke: color, 'stroke-width': num(sw, 3), 'stroke-dasharray': dash, opacity: 0.75 });
92
+ if (ticks) guides += line({ d: ticks, stroke: color, 'stroke-width': num(sw, 3) });
93
+
94
+ const clip = `${ctx.id}k`;
95
+ const maskId = `${ctx.id}m`;
96
+ let defs = `<clipPath id="${clip}"><rect${attrs({ x: ax, y: ay, width: aw, height: ah })}/></clipPath>`;
97
+ let body = `${grid}${guides}`;
98
+ const markColor = layer.markColor === 'none' ? null : layer.markColor ? toHex(layer.markColor) : ctx.palette.text;
99
+ if (markColor) {
100
+ const paths = markPaths(layer.markup, fit).map((p) => `<path${attrs({ d: p.d, 'fill-rule': p.evenodd ? 'evenodd' : undefined })}/>`).join('');
101
+ body += `<g fill="${markColor}">${paths}</g>`;
102
+ const over = layer.over ?? 0.4;
103
+ if (over > 0) {
104
+ defs += `<mask id="${maskId}" maskUnits="userSpaceOnUse"${attrs({ x: ax, y: ay, width: aw, height: ah })}><g fill="#fff">${paths}</g></mask>`;
105
+ body += `<g mask="url(#${maskId})" opacity="${num(over, 3)}">${guides}</g>`;
106
+ }
107
+ }
108
+ return { defs, body: wrap(layer, `<g clip-path="url(#${clip})">${body}</g>`) };
109
+ }
110
+
111
+ /**
112
+ * A circle as path data (two arcs), so circles share one path.
113
+ *
114
+ * @param {number} cx @param {number} cy @param {number} r
115
+ * @returns {string}
116
+ */
117
+ function circlePath(cx, cy, r) {
118
+ return `M${num(cx - r)} ${num(cy)}a${num(r)} ${num(r)} 0 1 0 ${num(2 * r)} 0a${num(r)} ${num(r)} 0 1 0 ${num(-2 * r)} 0Z`;
119
+ }
120
+
121
+ /**
122
+ * The part of the line through (x, y) along (ux, uy) inside a box
123
+ * (Liang–Barsky), or null when it misses.
124
+ *
125
+ * @param {number} x @param {number} y @param {number} ux @param {number} uy
126
+ * @param {{ x: number, y: number, width: number, height: number }} box
127
+ * @returns {number[] | null} `[x1, y1, x2, y2]`.
128
+ */
129
+ function clipLine(x, y, ux, uy, box) {
130
+ let t0 = -Infinity, t1 = Infinity;
131
+ for (const [p, q] of [[-ux, x - box.x], [ux, box.x + box.width - x], [-uy, y - box.y], [uy, box.y + box.height - y]]) {
132
+ if (Math.abs(p) < 1e-12) { if (q < 0) return null; continue; }
133
+ const r = q / p;
134
+ if (p < 0) t0 = Math.max(t0, r); else t1 = Math.min(t1, r);
135
+ }
136
+ return t0 < t1 ? [x + ux * t0, y + uy * t0, x + ux * t1, y + uy * t1] : null;
137
+ }
@@ -0,0 +1,38 @@
1
+ // A mark's construction, read from its paths.
2
+
3
+ /** A circle the mark's curves are drawn on. */
4
+ export interface GuideCircle {
5
+ cx: number;
6
+ cy: number;
7
+ r: number;
8
+ /** How much of it the mark draws, radians. */
9
+ sweep: number;
10
+ }
11
+
12
+ /** A line the mark's straight edges lie on. */
13
+ export interface GuideLine {
14
+ /** Radians, 0–π. */
15
+ angle: number;
16
+ /** A point on it. */
17
+ x: number;
18
+ y: number;
19
+ /** The mark's edges on it, in total. */
20
+ length: number;
21
+ }
22
+
23
+ /** A mark's construction, in its own (512 grid) units. */
24
+ export interface MarkGuides {
25
+ /** Its real bounds. */
26
+ box: { x: number; y: number; width: number; height: number };
27
+ /** The radius of the circle in its box. */
28
+ inscribed: number;
29
+ /** The radius of the circle round its outline, from the box's centre. */
30
+ circumscribed: number;
31
+ /** Its curves' circles, the most drawn first. */
32
+ circles: GuideCircle[];
33
+ /** Its straight edges' lines, the longest first. */
34
+ lines: GuideLine[];
35
+ }
36
+
37
+ /** Read a mark's construction (null when it draws nothing); at most `circles` and `lines` of each (6). */
38
+ export function markGuides(markup: string, options?: { circles?: number; lines?: number }): MarkGuides | null;
@@ -0,0 +1,212 @@
1
+ /**
2
+ * A mark's construction, read from its paths: the circles its curves are
3
+ * drawn on and the lines its straight edges lie on, for a construction
4
+ * sheet.
5
+ *
6
+ * @module layers/guides
7
+ */
8
+
9
+ import { shapes, bounds, outlinePoints, arcOf, bezierAt } from '@logomarks/core/svg';
10
+
11
+ /**
12
+ * @typedef {object} GuideCircle
13
+ * @property {number} cx @property {number} cy @property {number} r
14
+ * @property {number} sweep - How much of it the mark draws, radians (2π: all of it).
15
+ */
16
+
17
+ /**
18
+ * @typedef {object} GuideLine
19
+ * @property {number} angle - Radians, 0–π.
20
+ * @property {number} x @property {number} y - A point on it (the middle of its longest edge).
21
+ * @property {number} length - The mark's edges on it, in total.
22
+ */
23
+
24
+ /**
25
+ * @typedef {object} MarkGuides
26
+ * @property {{ x: number, y: number, width: number, height: number }} box - Its real bounds.
27
+ * @property {number} inscribed - The radius of the circle in its box, round the box's centre.
28
+ * @property {number} circumscribed - The radius of the circle round its outline, from the box's centre.
29
+ * @property {GuideCircle[]} circles - Its curves' circles, the most drawn first.
30
+ * @property {GuideLine[]} lines - Its straight edges' lines, the longest first.
31
+ */
32
+
33
+ /** Read marks, by markup and counts. @type {Map<string, MarkGuides>} */
34
+ const cache = new Map();
35
+
36
+ /**
37
+ * Read a mark's construction. A curve counts as part of a circle when
38
+ * its points lie on the circle through its ends and middle (an arc, or a
39
+ * Bézier drawn round one); curves on the same circle are added up, and
40
+ * a circle is kept when the mark draws a good share of it (50° or more)
41
+ * and it isn't a small corner round. Straight edges on the same line are
42
+ * added up the same way, and lines along the box's own sides left out.
43
+ *
44
+ * @param {string} markup - The mark's paths (512 grid).
45
+ * @param {{ circles?: number, lines?: number }} [options] - The most of each kept (6 and 6).
46
+ * @returns {MarkGuides | null} Null when it draws nothing.
47
+ *
48
+ * @example
49
+ * markGuides('<circle cx="256" cy="256" r="200"/>').circles; // [{ cx: 256, cy: 256, r: 200, sweep: 6.28… }]
50
+ */
51
+ export function markGuides(markup, { circles = 6, lines = 6 } = {}) {
52
+ const key = `${circles}|${lines}|${markup}`;
53
+ if (cache.has(key)) return /** @type {MarkGuides} */ (cache.get(key));
54
+ const filled = shapes(String(markup ?? ''));
55
+ if (!filled.length) return null;
56
+ const b = bounds(filled);
57
+ if (!(b.w > 0 && b.h > 0)) return null;
58
+ const box = { x: b.x, y: b.y, width: b.w, height: b.h };
59
+ const size = Math.max(b.w, b.h);
60
+ const cx = b.x + b.w / 2;
61
+ const cy = b.y + b.h / 2;
62
+
63
+ /** @type {GuideCircle[]} */
64
+ const arcs = [];
65
+ /** @type {{ x1: number, y1: number, x2: number, y2: number }[]} */
66
+ const edges = [];
67
+ let far = 0;
68
+ for (const s of filled) {
69
+ for (const [x, y] of outlinePoints(s.segs)) far = Math.max(far, Math.hypot(x - cx, y - cy));
70
+ let x = 0, y = 0, sx = 0, sy = 0;
71
+ for (const seg of s.segs) {
72
+ switch (seg[0]) {
73
+ case 'M': x = sx = seg[1]; y = sy = seg[2]; break;
74
+ case 'L': edges.push({ x1: x, y1: y, x2: seg[1], y2: seg[2] }); x = seg[1]; y = seg[2]; break;
75
+ case 'C': fitCurve([[x, y], [seg[1], seg[2]], [seg[3], seg[4]], [seg[5], seg[6]]], arcs); x = seg[5]; y = seg[6]; break;
76
+ case 'Q': fitCurve([[x, y], [seg[1], seg[2]], [seg[3], seg[4]]], arcs); x = seg[3]; y = seg[4]; break;
77
+ case 'A': {
78
+ const a = arcOf(x, y, seg.slice(1));
79
+ if (a && Math.abs(a.rx - a.ry) <= 0.01 * Math.max(a.rx, a.ry)) arcs.push({ cx: a.cx, cy: a.cy, r: (a.rx + a.ry) / 2, sweep: Math.abs(a.sweep) });
80
+ x = seg[6]; y = seg[7];
81
+ break;
82
+ }
83
+ case 'Z': edges.push({ x1: x, y1: y, x2: sx, y2: sy }); x = sx; y = sy; break;
84
+ }
85
+ }
86
+ }
87
+
88
+ const guides = {
89
+ box,
90
+ inscribed: Math.min(b.w, b.h) / 2,
91
+ circumscribed: far,
92
+ circles: circleGuides(arcs, size).slice(0, Math.max(0, circles)),
93
+ lines: lineGuides(edges, box).slice(0, Math.max(0, lines)),
94
+ };
95
+ if (cache.size > 200) cache.clear();
96
+ cache.set(key, guides);
97
+ return guides;
98
+ }
99
+
100
+ /**
101
+ * The circle a curve is drawn round, added to `arcs` when its quarter
102
+ * points lie on it too (within half a unit, or 1% of its radius).
103
+ *
104
+ * @param {number[][]} P - A quadratic's 3 points or a cubic's 4.
105
+ * @param {GuideCircle[]} arcs
106
+ */
107
+ function fitCurve(P, arcs) {
108
+ const p0 = P[0];
109
+ const p1 = /** @type {number[]} */ (bezierAt(/** @type {any} */ (P), 0.5));
110
+ const p2 = P[P.length - 1];
111
+ const c = circleThrough(p0, p1, p2);
112
+ if (!c) return;
113
+ const tol = Math.max(0.5, c.r * 0.01);
114
+ for (const u of [0.25, 0.75]) {
115
+ const [x, y] = bezierAt(/** @type {any} */ (P), u);
116
+ if (Math.abs(Math.hypot(x - c.cx, y - c.cy) - c.r) > tol) return;
117
+ }
118
+ const turn = (/** @type {number[]} */ a, /** @type {number[]} */ b) => {
119
+ const ux = a[0] - c.cx, uy = a[1] - c.cy, vx = b[0] - c.cx, vy = b[1] - c.cy;
120
+ return Math.abs(Math.atan2(ux * vy - uy * vx, ux * vx + uy * vy));
121
+ };
122
+ arcs.push({ ...c, sweep: turn(p0, p1) + turn(p1, p2) });
123
+ }
124
+
125
+ /**
126
+ * The circle through three points, or null when they're (nearly) on a line.
127
+ *
128
+ * @param {number[]} a @param {number[]} b @param {number[]} c
129
+ * @returns {{ cx: number, cy: number, r: number } | null}
130
+ */
131
+ function circleThrough(a, b, c) {
132
+ const d = 2 * (a[0] * (b[1] - c[1]) + b[0] * (c[1] - a[1]) + c[0] * (a[1] - b[1]));
133
+ if (Math.abs(d) < 1e-6) return null;
134
+ const A = a[0] ** 2 + a[1] ** 2, B = b[0] ** 2 + b[1] ** 2, C = c[0] ** 2 + c[1] ** 2;
135
+ const cx = (A * (b[1] - c[1]) + B * (c[1] - a[1]) + C * (a[1] - b[1])) / d;
136
+ const cy = (A * (c[0] - b[0]) + B * (a[0] - c[0]) + C * (b[0] - a[0])) / d;
137
+ return { cx, cy, r: Math.hypot(a[0] - cx, a[1] - cy) };
138
+ }
139
+
140
+ /**
141
+ * Arcs on the same circle added up (centres and radii within 3 units or
142
+ * 3%); kept when the mark draws 50° or more of it and its radius is 4%
143
+ * to 120% of the mark's size; the most drawn (by length) first.
144
+ *
145
+ * @param {GuideCircle[]} arcs
146
+ * @param {number} size - The mark's longest side.
147
+ * @returns {GuideCircle[]}
148
+ */
149
+ function circleGuides(arcs, size) {
150
+ /** @type {(GuideCircle & { w: number })[]} */
151
+ const groups = [];
152
+ for (const a of arcs) {
153
+ const near = Math.max(3, a.r * 0.03);
154
+ const g = groups.find((o) => Math.hypot(o.cx - a.cx, o.cy - a.cy) <= near && Math.abs(o.r - a.r) <= near);
155
+ if (!g) { groups.push({ ...a, w: a.sweep }); continue; }
156
+ // A sweep-weighted mean, so the long arcs set the circle.
157
+ const w = g.w + a.sweep;
158
+ g.cx = (g.cx * g.w + a.cx * a.sweep) / w;
159
+ g.cy = (g.cy * g.w + a.cy * a.sweep) / w;
160
+ g.r = (g.r * g.w + a.r * a.sweep) / w;
161
+ g.w = w;
162
+ g.sweep = Math.min(2 * Math.PI, g.sweep + a.sweep);
163
+ }
164
+ return groups
165
+ .filter((g) => g.sweep >= (50 * Math.PI) / 180 && g.r >= size * 0.04 && g.r <= size * 1.2)
166
+ .sort((p, q) => q.sweep * q.r - p.sweep * p.r || p.cx - q.cx || p.cy - q.cy)
167
+ .map(({ cx, cy, r, sweep }) => ({ cx, cy, r, sweep }));
168
+ }
169
+
170
+ /**
171
+ * Edges on the same line added up (within 0.75° and 1.5 units); kept
172
+ * when 8% of the mark's size or longer in total and not along a side of
173
+ * its box; the longest first.
174
+ *
175
+ * @param {{ x1: number, y1: number, x2: number, y2: number }[]} edges
176
+ * @param {{ x: number, y: number, width: number, height: number }} box
177
+ * @returns {GuideLine[]}
178
+ */
179
+ function lineGuides(edges, box) {
180
+ const size = Math.max(box.width, box.height);
181
+ /** @type {(GuideLine & { rho: number, best: number })[]} */
182
+ const groups = [];
183
+ for (const e of edges) {
184
+ const length = Math.hypot(e.x2 - e.x1, e.y2 - e.y1);
185
+ if (length < size * 0.02) continue;
186
+ let angle = Math.atan2(e.y2 - e.y1, e.x2 - e.x1);
187
+ if (angle < 0) angle += Math.PI;
188
+ if (angle >= Math.PI - 1e-9) angle -= Math.PI;
189
+ const x = (e.x1 + e.x2) / 2, y = (e.y1 + e.y2) / 2;
190
+ const rho = -Math.sin(angle) * x + Math.cos(angle) * y;
191
+ const g = groups.find((o) => {
192
+ const da = Math.abs(o.angle - angle);
193
+ const parallel = Math.min(da, Math.PI - da) < 0.013;
194
+ // Across 0 and π the line's normal flips, so its offset does too.
195
+ const apart = da < 0.013 ? Math.abs(o.rho - rho) : Math.abs(o.rho + rho);
196
+ return parallel && apart <= 1.5;
197
+ });
198
+ if (!g) { groups.push({ angle, x, y, length, rho, best: length }); continue; }
199
+ g.length += length;
200
+ if (length > g.best) { g.best = length; g.x = x; g.y = y; }
201
+ }
202
+ const onSide = (/** @type {GuideLine} */ l) => {
203
+ const flat = Math.min(l.angle, Math.PI - l.angle) < 0.013;
204
+ const upright = Math.abs(l.angle - Math.PI / 2) < 0.013;
205
+ return (flat && (Math.abs(l.y - box.y) < 1.5 || Math.abs(l.y - box.y - box.height) < 1.5))
206
+ || (upright && (Math.abs(l.x - box.x) < 1.5 || Math.abs(l.x - box.x - box.width) < 1.5));
207
+ };
208
+ return groups
209
+ .filter((g) => g.length >= size * 0.08 && !onSide(g))
210
+ .sort((p, q) => q.length - p.length || p.angle - q.angle || p.rho - q.rho)
211
+ .map(({ angle, x, y, length }) => ({ angle, x, y, length }));
212
+ }
@@ -20,5 +20,11 @@ export { marks, sheetGrid } from './marks.js';
20
20
  export type { MarksLayer } from './marks.js';
21
21
  export { markGeometry } from './mark-geometry.js';
22
22
  export type { MarkGeometry } from './mark-geometry.js';
23
+ export { outline } from './outline.js';
24
+ export type { OutlineLayer } from './outline.js';
25
+ export { construction } from './construction.js';
26
+ export type { ConstructionLayer } from './construction.js';
27
+ export { markGuides } from './guides.js';
28
+ export type { MarkGuides, GuideCircle, GuideLine } from './guides.js';
23
29
  export { expandRepeat } from './repeat.js';
24
30
  export type { RepeatLayer } from './repeat.js';
@@ -15,4 +15,7 @@ export { texture } from './texture.js';
15
15
  export { mosaic, mosaicGrid } from './mosaic.js';
16
16
  export { marks, sheetGrid } from './marks.js';
17
17
  export { markGeometry } from './mark-geometry.js';
18
+ export { outline } from './outline.js';
19
+ export { construction } from './construction.js';
20
+ export { markGuides } from './guides.js';
18
21
  export { expandRepeat } from './repeat.js';
@@ -0,0 +1,21 @@
1
+ // Isolines of a sampled field, and a mark's signed distance field.
2
+ import type { MarkGeometry } from './mark-geometry.js';
3
+
4
+ /** A signed distance field over a mark: positive outside, negative inside, mark units. */
5
+ export interface DistanceField {
6
+ values: Float32Array;
7
+ width: number;
8
+ height: number;
9
+ /** The mark point of the first sample. */
10
+ x0: number;
11
+ y0: number;
12
+ /** Mark units between samples. */
13
+ step: number;
14
+ }
15
+
16
+ /** A mark's signed distance field over its box plus `reach`, `samples` across its longest side (500); exact near `levels`, where lines will be traced. */
17
+ export function distanceField(geo: MarkGeometry, reach: number, levels?: number[], samples?: number): DistanceField;
18
+ /** Where a field (row by row, `w` × `h`) crosses `level`: polylines of `[column, row]`, closed ones ending on their first point. */
19
+ export function isolines(f: ArrayLike<number>, w: number, h: number, level: number): number[][][];
20
+ /** A polyline simplified within `tol` and smoothed (two rounds of Chaikin, corners rounded by at most `round`), as path data. */
21
+ export function smoothLine(pts: number[][], tol?: number, round?: number): string;