@andamento/core 0.1.0 → 0.2.0
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.
- package/dist/chunk-HBEJOXUC.cjs +10138 -0
- package/dist/chunk-HBEJOXUC.cjs.map +1 -0
- package/dist/chunk-JHWTRUDN.js +10138 -0
- package/dist/chunk-JHWTRUDN.js.map +1 -0
- package/dist/css-BG8JRNrD.d.cts +776 -0
- package/dist/css-BG8JRNrD.d.ts +776 -0
- package/dist/index.cjs +318 -10441
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -887
- package/dist/index.d.ts +20 -887
- package/dist/index.js +148 -10123
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +81 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +111 -0
- package/dist/internal.d.ts +111 -0
- package/dist/internal.js +81 -0
- package/dist/internal.js.map +1 -0
- package/package.json +11 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,486 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Conventions:
|
|
5
|
-
* - Coordinates are SVG-style (y grows downward), but all math is orientation-agnostic.
|
|
6
|
-
* - Polygons are arrays of vertices without a repeated closing vertex.
|
|
7
|
-
* - "Positive" orientation means a positive shoelace area. All internal polygons are
|
|
8
|
-
* normalized to positive orientation, so the interior is to the left of each edge
|
|
9
|
-
* in the shoelace sense and the inward normal of edge (dx, dy) is (-dy, dx).
|
|
10
|
-
* - `clipConvex` needs a convex clip polygon (the subject can be any simple polygon);
|
|
11
|
-
* `insetConvex` needs a convex polygon and `containsPolygon` a convex `outer`. Non-convex tiles are inset
|
|
12
|
-
* with `insetPolygon` (offset.ts).
|
|
13
|
-
*/
|
|
14
|
-
interface Vec {
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
}
|
|
18
|
-
type Polygon = Vec[];
|
|
19
|
-
interface Rect {
|
|
20
|
-
x: number;
|
|
21
|
-
y: number;
|
|
22
|
-
width: number;
|
|
23
|
-
height: number;
|
|
24
|
-
}
|
|
25
|
-
declare const vec: (x: number, y: number) => Vec;
|
|
26
|
-
declare const add: (a: Vec, b: Vec) => Vec;
|
|
27
|
-
declare const sub: (a: Vec, b: Vec) => Vec;
|
|
28
|
-
declare const scale: (a: Vec, s: number) => Vec;
|
|
29
|
-
declare const dot: (a: Vec, b: Vec) => number;
|
|
30
|
-
declare const cross: (a: Vec, b: Vec) => number;
|
|
31
|
-
declare const length: (a: Vec) => number;
|
|
32
|
-
/** Polygon for an axis-aligned rectangle, in positive orientation. */
|
|
33
|
-
declare function rectPolygon(x: number, y: number, width: number, height: number): Polygon;
|
|
34
|
-
/** Shoelace signed area. Positive for the library's canonical orientation. */
|
|
35
|
-
declare function signedArea(p: Polygon): number;
|
|
36
|
-
declare const area: (p: Polygon) => number;
|
|
37
|
-
declare function ensurePositive(p: Polygon): Polygon;
|
|
38
|
-
declare function centroid(p: Polygon): Vec;
|
|
39
|
-
declare function bbox(p: Polygon): Rect;
|
|
40
|
-
declare function rectsOverlap(a: Rect, b: Rect, tol?: number): boolean;
|
|
41
|
-
/** Rotate by `radians` about the coordinate origin, then translate by `offset`. */
|
|
42
|
-
declare function transform(p: Polygon, radians: number, offset: Vec): Polygon;
|
|
43
|
-
declare function isConvex(p: Polygon, tol?: number): boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Keep the part of `poly` where dot(normal, v - point) >= offset
|
|
46
|
-
* (one pass of Sutherland–Hodgman).
|
|
47
|
-
*/
|
|
48
|
-
declare function clipHalfPlane(poly: Polygon, point: Vec, normal: Vec, offset?: number): Polygon;
|
|
49
|
-
/** Remove consecutive duplicate vertices; return [] if the result has no area. */
|
|
50
|
-
declare function cleanPolygon(p: Polygon, tol?: number): Polygon;
|
|
51
|
-
/**
|
|
52
|
-
* Intersection of `subject` (any simple polygon) with a convex `clip` polygon.
|
|
53
|
-
* If a non-convex subject is cut into separate parts, they come back as one polygon
|
|
54
|
-
* joined by zero-width strips along the clip edge; use `clipPolygonToConvex` to get
|
|
55
|
-
* the parts separately.
|
|
56
|
-
*/
|
|
57
|
-
declare function clipConvex(subject: Polygon, clip: Polygon): Polygon;
|
|
58
|
-
/**
|
|
59
|
-
* Shrink a convex polygon by moving every edge inward by `distance`.
|
|
60
|
-
* Implemented as a half-plane intersection, so edges that collapse simply vanish
|
|
61
|
-
* and an over-inset polygon returns [].
|
|
62
|
-
*/
|
|
63
|
-
declare function insetConvex(poly: Polygon, distance: number): Polygon;
|
|
64
|
-
/** True if every vertex of `inner` lies inside (or on) convex polygon `outer`. */
|
|
65
|
-
declare function containsPolygon(outer: Polygon, inner: Polygon, tol?: number): boolean;
|
|
66
|
-
/** Do two polygons share a boundary segment of positive length? */
|
|
67
|
-
declare function sharesEdge(a: Polygon, b: Polygon, tol: number): boolean;
|
|
68
|
-
/** Convex hull (positive orientation) of a set of points. */
|
|
69
|
-
declare function convexHull(points: Vec[]): Polygon;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Shrink a simple polygon (convex or not) by moving every edge inward by `distance`.
|
|
73
|
-
* Returns [] if nothing is left. If the shape splits, the largest piece is returned.
|
|
74
|
-
*/
|
|
75
|
-
declare function insetPolygon(poly: Polygon, distance: number): Polygon;
|
|
76
|
-
/** Like `insetPolygon`, but every piece when a narrow neck pinches the shape apart. */
|
|
77
|
-
declare function insetPolygonPieces(poly: Polygon, distance: number): Polygon[];
|
|
78
|
-
/**
|
|
79
|
-
* Grow a simple polygon by moving every edge outward by `distance` (mitred corners;
|
|
80
|
-
* pockets narrower than 2 × distance close up). Positively oriented.
|
|
81
|
-
*/
|
|
82
|
-
declare function outsetPolygon(poly: Polygon, distance: number): Polygon;
|
|
83
|
-
/** Cut a closed outline at its self-crossings into simple loops. */
|
|
84
|
-
declare function splitSelfIntersections(poly: Polygon): Polygon[];
|
|
85
|
-
/** Ray-casting point-in-polygon test (even–odd rule). */
|
|
86
|
-
declare function pointInPolygon(pt: Vec, poly: Polygon): boolean;
|
|
87
|
-
/**
|
|
88
|
-
* Intersection of a simple polygon (convex or not) with a convex `clip` polygon, as
|
|
89
|
-
* separate pieces. Unlike `clipConvex`, a subject that the clip edge cuts into several
|
|
90
|
-
* parts comes back as several clean polygons.
|
|
91
|
-
*
|
|
92
|
-
* The subject's outline is walked edge by edge; the stretches inside the clip region form
|
|
93
|
-
* chains that enter and leave through the clip outline. Each piece is a chain followed by
|
|
94
|
-
* a walk forward along the clip outline to wherever the next chain enters (both outlines
|
|
95
|
-
* have the same orientation, so "forward" stays on the inside).
|
|
96
|
-
*/
|
|
97
|
-
declare function clipPolygonToConvex(subject: Polygon, clip: Polygon): Polygon[];
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Polygon boolean operations by overlay.
|
|
101
|
-
*
|
|
102
|
-
* Every input outline is cut at every point where it meets another, giving a set of
|
|
103
|
-
* pieces that don't cross. For each piece, a point just to its left and just to its
|
|
104
|
-
* right is tested against what the result should contain (any combination of inside /
|
|
105
|
-
* outside tests). Pieces with the result on exactly one side form the result's
|
|
106
|
-
* boundary, oriented with the result on the left, and are chained into loops.
|
|
107
|
-
*
|
|
108
|
-
* This handles holes, shapes touching at a point, and edges that run along each other,
|
|
109
|
-
* as long as features are much larger than the tolerance.
|
|
110
|
-
*/
|
|
111
|
-
/** A region with holes: `outer` is positively oriented, `holes` negatively. */
|
|
112
|
-
interface Shape {
|
|
113
|
-
outer: Polygon;
|
|
114
|
-
holes: Polygon[];
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* The boundary of `{ p : inside(p) }` among the given outlines, as shapes.
|
|
118
|
-
* `scale` is the size of the scene; tolerances are relative to it.
|
|
119
|
-
*/
|
|
120
|
-
declare function overlay(outlines: Polygon[], inside: (p: Vec) => boolean, scale: number): Shape[];
|
|
121
|
-
/**
|
|
122
|
-
* Split the plane into regions by a labeling function: each point gets a label (a number;
|
|
123
|
-
* negative for "nothing"), and every region of equal label is returned as shapes. The
|
|
124
|
-
* labels may only change across the given outlines (closed loops; pass an open polyline's
|
|
125
|
-
* segments as two-point "loops"), which are cut where they meet like `overlay`'s.
|
|
126
|
-
*/
|
|
127
|
-
declare function partition(outlines: Polygon[], label: (p: Vec) => number, scale: number): Map<number, Shape[]>;
|
|
128
|
-
/** Area of a shape (outline minus holes). */
|
|
129
|
-
declare const shapeArea: (s: Shape) => number;
|
|
130
|
-
/** Centroid of a shape, holes included. */
|
|
131
|
-
declare function shapeCentroid(s: Shape): Vec;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Andamento: tesserae laid in rows (courses) that follow guide curves, circle center points
|
|
135
|
-
* or run along the region's outline, the way mosaicists lay them.
|
|
136
|
-
*/
|
|
137
|
-
interface FlowSpec {
|
|
138
|
-
type: "flow";
|
|
139
|
-
/** Row height: the width of each tessera across its row. */
|
|
140
|
-
size: number;
|
|
141
|
-
/** Tessera length along its row, as a multiple of `size`. Defaults to 1.3. */
|
|
142
|
-
length?: number;
|
|
143
|
-
/** How much tessera lengths vary, 0 (all alike) to 0.9. Defaults to 0.3. */
|
|
144
|
-
jitter?: number;
|
|
145
|
-
/**
|
|
146
|
-
* Curves for rows to follow, in layout units: a row runs along each, and further rows
|
|
147
|
-
* parallel to it on both sides. Open polylines, or `closed` loops.
|
|
148
|
-
*/
|
|
149
|
-
guides?: {
|
|
150
|
-
points: Vec[];
|
|
151
|
-
closed?: boolean;
|
|
152
|
-
}[];
|
|
153
|
-
/** Points for rows to circle, in layout units: a round tessera, ringed by row after row. */
|
|
154
|
-
centers?: Vec[];
|
|
155
|
-
/**
|
|
156
|
-
* Rows also run along the region's outline (and round its holes), as in opus
|
|
157
|
-
* vermiculatum. Defaults to true when there are no guides or centers.
|
|
158
|
-
*/
|
|
159
|
-
followEdges?: boolean;
|
|
160
|
-
/** Seed for the deterministic random generator. Defaults to 1. */
|
|
161
|
-
seed?: number;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
interface GridSpec {
|
|
165
|
-
type: "grid";
|
|
166
|
-
/** Cell width. */
|
|
167
|
-
width: number;
|
|
168
|
-
/** Cell height. Defaults to `width` (squares). */
|
|
169
|
-
height?: number;
|
|
170
|
-
}
|
|
171
|
-
interface RunningBondSpec {
|
|
172
|
-
type: "runningBond";
|
|
173
|
-
width: number;
|
|
174
|
-
height: number;
|
|
175
|
-
/** Fraction of a brick each row is shifted by. Defaults to 0.5. */
|
|
176
|
-
offset?: number;
|
|
177
|
-
}
|
|
178
|
-
interface HerringboneSpec {
|
|
179
|
-
type: "herringbone";
|
|
180
|
-
/** Long side of each rectangle. Must be greater than `width`. */
|
|
181
|
-
length: number;
|
|
182
|
-
/** Short side of each rectangle. */
|
|
183
|
-
width: number;
|
|
184
|
-
}
|
|
185
|
-
interface BasketweaveSpec {
|
|
186
|
-
type: "basketweave";
|
|
187
|
-
/** Side of each square block (= length of each strip). */
|
|
188
|
-
length: number;
|
|
189
|
-
/** Strips per block. Defaults to 2. */
|
|
190
|
-
strips?: number;
|
|
191
|
-
}
|
|
192
|
-
interface HexagonalSpec {
|
|
193
|
-
type: "hexagonal";
|
|
194
|
-
/** Circumradius: center-to-corner distance. */
|
|
195
|
-
size: number;
|
|
196
|
-
/** "pointy" puts a corner at the top; "flat" puts an edge at the top. Defaults to "pointy". */
|
|
197
|
-
orientation?: "pointy" | "flat";
|
|
198
|
-
}
|
|
199
|
-
interface TriangularSpec {
|
|
200
|
-
type: "triangular";
|
|
201
|
-
/** Side length of each equilateral triangle. */
|
|
202
|
-
size: number;
|
|
203
|
-
}
|
|
204
|
-
interface RhombilleSpec {
|
|
205
|
-
type: "rhombille";
|
|
206
|
-
/** Side length of each rhombus. Three rhombi form a hexagon ("tumbling blocks"). */
|
|
207
|
-
size: number;
|
|
208
|
-
}
|
|
209
|
-
interface OctagonSquareSpec {
|
|
210
|
-
type: "octagonSquare";
|
|
211
|
-
/** Edge length shared by the octagons and the small squares. */
|
|
212
|
-
size: number;
|
|
213
|
-
}
|
|
214
|
-
interface TrihexagonalSpec {
|
|
215
|
-
type: "trihexagonal";
|
|
216
|
-
/** Edge length shared by the hexagons and triangles. */
|
|
217
|
-
size: number;
|
|
218
|
-
}
|
|
219
|
-
interface RhombitrihexagonalSpec {
|
|
220
|
-
type: "rhombitrihexagonal";
|
|
221
|
-
/** Edge length shared by the hexagons, squares and triangles. */
|
|
222
|
-
size: number;
|
|
223
|
-
}
|
|
224
|
-
interface CairoSpec {
|
|
225
|
-
type: "cairo";
|
|
226
|
-
/** Spacing of the underlying square grid; each pentagon is roughly this wide. */
|
|
227
|
-
size: number;
|
|
228
|
-
}
|
|
229
|
-
interface HopscotchSpec {
|
|
230
|
-
type: "hopscotch";
|
|
231
|
-
/** Side of the large squares. */
|
|
232
|
-
large: number;
|
|
233
|
-
/** Side of the small squares. Must not exceed `large`. */
|
|
234
|
-
small: number;
|
|
235
|
-
}
|
|
236
|
-
interface PinwheelSpec {
|
|
237
|
-
type: "pinwheel";
|
|
238
|
-
/** Long side of each rectangle. Must be greater than `width`. */
|
|
239
|
-
length: number;
|
|
240
|
-
/** Short side of each rectangle. The center squares have side `length - width`. */
|
|
241
|
-
width: number;
|
|
242
|
-
}
|
|
243
|
-
interface FlemishBondSpec {
|
|
244
|
-
type: "flemishBond";
|
|
245
|
-
/** Length of the long bricks (stretchers). */
|
|
246
|
-
length: number;
|
|
247
|
-
/** Course height. */
|
|
248
|
-
height: number;
|
|
249
|
-
/** Length of the short bricks (headers). Defaults to `length / 2`. */
|
|
250
|
-
header?: number;
|
|
251
|
-
}
|
|
252
|
-
interface ChevronSpec {
|
|
253
|
-
type: "chevron";
|
|
254
|
-
/** Long side of each plank. */
|
|
255
|
-
length: number;
|
|
256
|
-
/** Plank width, measured across the plank. */
|
|
257
|
-
width: number;
|
|
258
|
-
/** Plank slope in degrees from horizontal, between 0 and 90 (exclusive). Defaults to 45. */
|
|
259
|
-
angle?: number;
|
|
260
|
-
}
|
|
261
|
-
interface FishScaleSpec {
|
|
262
|
-
type: "fishScale";
|
|
263
|
-
/** Width of each scale. Scales overlap like roof shingles: rounded below, pointed on top. */
|
|
264
|
-
size: number;
|
|
265
|
-
}
|
|
266
|
-
interface VoronoiSpec {
|
|
267
|
-
type: "voronoi";
|
|
268
|
-
/** Typical cell width: about one cell per size × size area. */
|
|
269
|
-
size: number;
|
|
270
|
-
/** Rounds of Lloyd relaxation; more rounds give more even, rounder cells. Defaults to 2. */
|
|
271
|
-
relax?: number;
|
|
272
|
-
/** Seed for the deterministic random generator. Defaults to 1. */
|
|
273
|
-
seed?: number;
|
|
274
|
-
}
|
|
275
|
-
interface DelaunaySpec {
|
|
276
|
-
type: "delaunay";
|
|
277
|
-
/** Typical spacing of the triangle corners. */
|
|
278
|
-
size: number;
|
|
279
|
-
/** Rounds of Lloyd relaxation on the corners; more rounds give more even triangles. Defaults to 2. */
|
|
280
|
-
relax?: number;
|
|
281
|
-
/** Seed for the deterministic random generator. Defaults to 1. */
|
|
282
|
-
seed?: number;
|
|
283
|
-
}
|
|
284
|
-
interface AshlarSpec {
|
|
285
|
-
type: "ashlar";
|
|
286
|
-
/** Typical course (row) height. */
|
|
287
|
-
height: number;
|
|
288
|
-
/** Shortest stone. */
|
|
289
|
-
minLength: number;
|
|
290
|
-
/** Longest stone. */
|
|
291
|
-
maxLength: number;
|
|
292
|
-
/** How much course heights vary, 0–0.9, as a fraction of `height`. Defaults to 0. */
|
|
293
|
-
heightVariation?: number;
|
|
294
|
-
/** Seed for the deterministic random generator. Defaults to 1. */
|
|
295
|
-
seed?: number;
|
|
296
|
-
}
|
|
297
|
-
interface PenroseSpec {
|
|
298
|
-
type: "penrose";
|
|
299
|
-
/** Edge length of the rhombs, or the long edge of the kites and darts. */
|
|
300
|
-
size: number;
|
|
301
|
-
/**
|
|
302
|
-
* "rhombs" (P3: thick and thin rhombs, all convex) or "kitesAndDarts" (P2: convex kites
|
|
303
|
-
* and non-convex darts). Defaults to "rhombs".
|
|
304
|
-
*/
|
|
305
|
-
variant?: "rhombs" | "kitesAndDarts";
|
|
306
|
-
}
|
|
307
|
-
interface HatSpec {
|
|
308
|
-
type: "hat";
|
|
309
|
-
/** Approximate width of each hat (its widest extent). */
|
|
310
|
-
size: number;
|
|
311
|
-
}
|
|
312
|
-
interface SpectreSpec {
|
|
313
|
-
type: "spectre";
|
|
314
|
-
/** Approximate width of each spectre (its widest extent). */
|
|
315
|
-
size: number;
|
|
316
|
-
}
|
|
317
|
-
interface IsohedralSpec {
|
|
318
|
-
type: "isohedral";
|
|
319
|
-
/** Isohedral type number (see `isohedralTypes`; 81 of the 93 types). */
|
|
320
|
-
ih: number;
|
|
321
|
-
/** Approximate tile width (its widest extent). */
|
|
322
|
-
size: number;
|
|
323
|
-
/** Shape parameters moving the tile's corners; see `isohedralInfo(ih)`. Defaults per type. */
|
|
324
|
-
params?: number[];
|
|
325
|
-
/**
|
|
326
|
-
* Edge curves: "wave" (default) or "straight", or one curve per edge class (see
|
|
327
|
-
* `isohedralInfo(ih).edgeKinds`) as points strictly between (0,0) and (1,0). Curves for
|
|
328
|
-
* "S" and "U" edges describe the first half of the edge; "I" edges are always straight.
|
|
329
|
-
*/
|
|
330
|
-
edges?: "wave" | "straight" | Vec[][];
|
|
331
|
-
/**
|
|
332
|
-
* Height of the "wave" curves, as a fraction of each edge. Defaults to 0.15, lowered for
|
|
333
|
-
* the few types where that would make the tile overlap itself.
|
|
334
|
-
*/
|
|
335
|
-
amount?: number;
|
|
336
|
-
}
|
|
337
|
-
interface JigsawSpec {
|
|
338
|
-
type: "jigsaw";
|
|
339
|
-
/** Target piece size; columns and rows are chosen so pieces fit the region exactly. */
|
|
340
|
-
size: number;
|
|
341
|
-
/** Seed for tab directions and positions. Defaults to 1. */
|
|
342
|
-
seed?: number;
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* A custom repeating tiling: the motif's polygons are copied to every point i·a + j·b.
|
|
346
|
-
* Coordinates are in region units. Nothing checks that the copies fit together; use
|
|
347
|
-
* `checkPeriodic` while designing one. Polygons may be non-convex but must be simple.
|
|
348
|
-
*/
|
|
349
|
-
interface PeriodicSpec {
|
|
350
|
-
type: "periodic";
|
|
351
|
-
a: Vec;
|
|
352
|
-
b: Vec;
|
|
353
|
-
/** Tiles of one lattice cell. `protoTile` defaults to the tile's position in this list. */
|
|
354
|
-
motif: {
|
|
355
|
-
polygon: Polygon;
|
|
356
|
-
protoTile?: number;
|
|
357
|
-
}[];
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Explicit tiles, used as given (in region units): nothing is generated, and `rotation`
|
|
361
|
-
* and `origin` are ignored. The usual gap, margin, edge, rounding and neighbor handling
|
|
362
|
-
* applies. Ids default to "t0", "t1", …; given ids must be unique.
|
|
363
|
-
*/
|
|
364
|
-
interface TilesSpec {
|
|
365
|
-
type: "tiles";
|
|
366
|
-
tiles: {
|
|
367
|
-
polygon: Polygon;
|
|
368
|
-
id?: string;
|
|
369
|
-
protoTile?: number;
|
|
370
|
-
}[];
|
|
371
|
-
}
|
|
372
|
-
interface MondrianSpec {
|
|
373
|
-
type: "mondrian";
|
|
374
|
-
/** No side is cut shorter than this. */
|
|
375
|
-
minSize: number;
|
|
376
|
-
/** Cells larger than this along either side are always split further (when possible). */
|
|
377
|
-
maxSize: number;
|
|
378
|
-
/** Chance (0–1) of splitting a cell that already fits within `maxSize`. Defaults to 0.4. */
|
|
379
|
-
splitChance?: number;
|
|
380
|
-
/** Seed for the deterministic random generator. Defaults to 1. */
|
|
381
|
-
seed?: number;
|
|
382
|
-
/** Snap split positions to multiples of this value (relative to each cell). */
|
|
383
|
-
snap?: number;
|
|
384
|
-
}
|
|
385
|
-
type TilingSpec = FlowSpec | GridSpec | RunningBondSpec | HerringboneSpec | BasketweaveSpec | HexagonalSpec | TriangularSpec | RhombilleSpec | OctagonSquareSpec | TrihexagonalSpec | RhombitrihexagonalSpec | CairoSpec | HopscotchSpec | PinwheelSpec | FlemishBondSpec | ChevronSpec | FishScaleSpec | VoronoiSpec | DelaunaySpec | AshlarSpec | PenroseSpec | HatSpec | SpectreSpec | IsohedralSpec | JigsawSpec | PeriodicSpec | TilesSpec | MondrianSpec;
|
|
386
|
-
type TilingType = TilingSpec["type"];
|
|
387
|
-
declare const grid: (p: Omit<GridSpec, "type">) => GridSpec;
|
|
388
|
-
declare const runningBond: (p: Omit<RunningBondSpec, "type">) => RunningBondSpec;
|
|
389
|
-
declare const herringbone: (p: Omit<HerringboneSpec, "type">) => HerringboneSpec;
|
|
390
|
-
declare const basketweave: (p: Omit<BasketweaveSpec, "type">) => BasketweaveSpec;
|
|
391
|
-
declare const hexagonal: (p: Omit<HexagonalSpec, "type">) => HexagonalSpec;
|
|
392
|
-
declare const triangular: (p: Omit<TriangularSpec, "type">) => TriangularSpec;
|
|
393
|
-
declare const rhombille: (p: Omit<RhombilleSpec, "type">) => RhombilleSpec;
|
|
394
|
-
declare const octagonSquare: (p: Omit<OctagonSquareSpec, "type">) => OctagonSquareSpec;
|
|
395
|
-
declare const trihexagonal: (p: Omit<TrihexagonalSpec, "type">) => TrihexagonalSpec;
|
|
396
|
-
declare const rhombitrihexagonal: (p: Omit<RhombitrihexagonalSpec, "type">) => RhombitrihexagonalSpec;
|
|
397
|
-
declare const cairo: (p: Omit<CairoSpec, "type">) => CairoSpec;
|
|
398
|
-
declare const hopscotch: (p: Omit<HopscotchSpec, "type">) => HopscotchSpec;
|
|
399
|
-
declare const pinwheel: (p: Omit<PinwheelSpec, "type">) => PinwheelSpec;
|
|
400
|
-
declare const flemishBond: (p: Omit<FlemishBondSpec, "type">) => FlemishBondSpec;
|
|
401
|
-
declare const chevron: (p: Omit<ChevronSpec, "type">) => ChevronSpec;
|
|
402
|
-
declare const fishScale: (p: Omit<FishScaleSpec, "type">) => FishScaleSpec;
|
|
403
|
-
declare const hat: (p: Omit<HatSpec, "type">) => HatSpec;
|
|
404
|
-
declare const spectre: (p: Omit<SpectreSpec, "type">) => SpectreSpec;
|
|
405
|
-
declare const isohedral: (p: Omit<IsohedralSpec, "type">) => IsohedralSpec;
|
|
406
|
-
declare const jigsaw: (p: Omit<JigsawSpec, "type">) => JigsawSpec;
|
|
407
|
-
declare const voronoi: (p: Omit<VoronoiSpec, "type">) => VoronoiSpec;
|
|
408
|
-
declare const delaunay: (p: Omit<DelaunaySpec, "type">) => DelaunaySpec;
|
|
409
|
-
declare const ashlar: (p: Omit<AshlarSpec, "type">) => AshlarSpec;
|
|
410
|
-
declare const penrose: (p: Omit<PenroseSpec, "type">) => PenroseSpec;
|
|
411
|
-
declare const periodic: (p: Omit<PeriodicSpec, "type">) => PeriodicSpec;
|
|
412
|
-
declare const tiles: (p: Omit<TilesSpec, "type">) => TilesSpec;
|
|
413
|
-
declare const mondrian: (p: Omit<MondrianSpec, "type">) => MondrianSpec;
|
|
414
|
-
/** Andamento: tesserae in rows following guide curves, centers or the region's outline. See `FlowSpec`. */
|
|
415
|
-
declare const flow: (p: Omit<FlowSpec, "type">) => FlowSpec;
|
|
416
|
-
/** A tile as produced by a generator, before gap/clipping is applied. */
|
|
417
|
-
interface RawTile {
|
|
418
|
-
/** Stable identifier, unique within one generated layout. */
|
|
419
|
-
id: string;
|
|
420
|
-
polygon: Polygon;
|
|
421
|
-
/** Index of the prototile this tile is a copy of (e.g. herringbone: 0 = horizontal, 1 = vertical). */
|
|
422
|
-
protoTile: number;
|
|
423
|
-
}
|
|
424
|
-
interface GenerateContext {
|
|
425
|
-
/** Area that must be covered. */
|
|
426
|
-
region: Polygon;
|
|
427
|
-
/** Pattern rotation in degrees. */
|
|
428
|
-
rotation: number;
|
|
429
|
-
/** Where the pattern's local origin sits. */
|
|
430
|
-
origin: Vec;
|
|
431
|
-
/** Safety cap on the number of tiles generated. */
|
|
432
|
-
maxTiles: number;
|
|
433
|
-
/**
|
|
434
|
-
* For generators that can vary their tile size smoothly (Voronoi, Delaunay): the size
|
|
435
|
-
* wanted at a point, as a factor (at most 1) of the spec's size.
|
|
436
|
-
*/
|
|
437
|
-
sizeAt?: (p: Vec) => number;
|
|
438
|
-
/** The exact area to tile (outline and holes, less margin), for generators that follow it. */
|
|
439
|
-
outline?: Polygon[];
|
|
440
|
-
/** Layout units per generator unit (the pattern scale), for specs given in layout units. */
|
|
441
|
-
unit?: number;
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* A periodic tiling: a motif of prototiles repeated at every point
|
|
445
|
-
* i·a + j·b of a lattice.
|
|
446
|
-
*/
|
|
447
|
-
interface PeriodicDefinition {
|
|
448
|
-
a: Vec;
|
|
449
|
-
b: Vec;
|
|
450
|
-
motif: {
|
|
451
|
-
polygon: Polygon;
|
|
452
|
-
protoTile: number;
|
|
453
|
-
}[];
|
|
454
|
-
}
|
|
455
|
-
/** Tilings generated procedurally (seeded) rather than from a repeating motif. */
|
|
456
|
-
type ProceduralSpec = MondrianSpec | VoronoiSpec | DelaunaySpec | AshlarSpec | JigsawSpec | FlowSpec;
|
|
457
|
-
declare function periodicDefinition(spec: Exclude<TilingSpec, ProceduralSpec | PenroseSpec | HatSpec | SpectreSpec | IsohedralSpec | TilesSpec>): PeriodicDefinition;
|
|
458
|
-
/** Enumerate every lattice copy of the motif that can touch `ctx.region`. */
|
|
459
|
-
declare function generatePeriodic(def: PeriodicDefinition, ctx: GenerateContext): RawTile[];
|
|
460
|
-
/**
|
|
461
|
-
* Random recursive guillotine partition of the region's bounding box.
|
|
462
|
-
* Rotation and origin are ignored: Mondrian layouts are always axis-aligned to the region.
|
|
463
|
-
*/
|
|
464
|
-
declare function generateMondrian(spec: MondrianSpec, ctx: GenerateContext): RawTile[];
|
|
465
|
-
declare function generateTiles(spec: TilingSpec, ctx: GenerateContext): RawTile[];
|
|
466
|
-
interface PeriodicCheck {
|
|
467
|
-
/** True when no gaps, overlaps or self-intersecting tiles were found. */
|
|
468
|
-
ok: boolean;
|
|
469
|
-
/** Area of one lattice cell, |a × b|, and the motif's total area (equal for a tiling). */
|
|
470
|
-
cellArea: number;
|
|
471
|
-
motifArea: number;
|
|
472
|
-
/** Fraction of sample points covered by no tile, and by more than one. */
|
|
473
|
-
gaps: number;
|
|
474
|
-
overlaps: number;
|
|
475
|
-
/** Motif indices whose outline crosses itself. */
|
|
476
|
-
selfIntersecting: number[];
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Check a custom periodic tiling by sampling one lattice cell: every point should be
|
|
480
|
-
* covered by exactly one copy of one motif tile. Sampling can miss slivers narrower than
|
|
481
|
-
* the sample spacing (`samples` points per side, default 60).
|
|
482
|
-
*/
|
|
483
|
-
declare function checkPeriodic(spec: PeriodicSpec | PeriodicDefinition, samples?: number): PeriodicCheck;
|
|
1
|
+
import { V as Vec, R as Rect, P as Polygon, a as RawTile, G as GenerateContext, C as Cell, L as Layout, S as Shape, b as LayoutOptions, F as Feature } from './css-BG8JRNrD.js';
|
|
2
|
+
export { A as AshlarSpec, B as BasketweaveSpec, c as CairoSpec, d as CellCss, e as CellCssOptions, f as ChevronSpec, D as DelaunaySpec, E as EdgeKind, g as EdgeMode, h as FishScaleSpec, i as FlemishBondSpec, j as FlowSpec, k as GridSpec, H as HatSpec, l as HerringboneSpec, m as HexagonalSpec, n as HopscotchSpec, I as IsohedralInfo, o as IsohedralSpec, J as JigsawSpec, M as MondrianSpec, O as OctagonSquareSpec, p as PenroseSpec, q as PeriodicCheck, r as PeriodicDefinition, s as PeriodicSpec, t as PinwheelSpec, u as ProceduralSpec, v as RhombilleSpec, w as RhombitrihexagonalSpec, x as RunningBondSpec, y as SafeAreaOptions, z as SpectreSpec, T as TilesSpec, K as TilingSpec, N as TilingType, Q as TriangularSpec, U as TrihexagonalSpec, W as VoronoiSpec, X as area, Y as ashlar, Z as backdropCss, _ as basketweave, $ as bbox, a0 as boundsAspectRatio, a1 as cairo, a2 as cellCss, a3 as centroid, a4 as checkPeriodic, a5 as chevron, a6 as colorCells, a7 as createLayout, a8 as cssShapes, a9 as delaunay, aa as fishScale, ab as flemishBond, ac as flow, ad as grid, ae as hat, af as herringbone, ag as hexagonal, ah as hopscotch, ai as insetPolygon, aj as isohedral, ak as isohedralInfo, al as isohedralTypes, am as jigsaw, an as mondrian, ao as morphPolygon, ap as octagonSquare, aq as overlay, ar as penrose, as as periodic, at as periodicDefinition, au as pinwheel, av as rectPolygon, aw as regionCss, ax as rhombille, ay as rhombitrihexagonal, az as runningBond, aA as safeArea, aB as safeAreaCss, aC as spectre, aD as tiles, aE as triangular, aF as trihexagonal, aG as vec, aH as viewCss, aI as voronoi } from './css-BG8JRNrD.js';
|
|
484
3
|
|
|
485
4
|
/**
|
|
486
5
|
* Voronoi cells of `sites` within `box`: each cell is the box clipped by the
|
|
@@ -537,138 +56,6 @@ declare const penroseRhombs: SubstitutionRule;
|
|
|
537
56
|
*/
|
|
538
57
|
declare const penroseKitesAndDarts: SubstitutionRule;
|
|
539
58
|
|
|
540
|
-
/*!
|
|
541
|
-
* The "hat" aperiodic monotile (Smith, Myers, Kaplan & Goodman-Strauss, 2023), built
|
|
542
|
-
* with the H/T/P/F metatile construction.
|
|
543
|
-
*
|
|
544
|
-
* The metatile outlines, the patch rules and the supertile construction below are ported
|
|
545
|
-
* from hatviz (https://github.com/isohedral/hatviz), whose license follows:
|
|
546
|
-
*
|
|
547
|
-
* BSD 3-Clause License
|
|
548
|
-
*
|
|
549
|
-
* Copyright (c) 2023, Craig S. Kaplan
|
|
550
|
-
*
|
|
551
|
-
* Redistribution and use in source and binary forms, with or without
|
|
552
|
-
* modification, are permitted provided that the following conditions are met:
|
|
553
|
-
*
|
|
554
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
555
|
-
* list of conditions and the following disclaimer.
|
|
556
|
-
*
|
|
557
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
558
|
-
* this list of conditions and the following disclaimer in the documentation
|
|
559
|
-
* and/or other materials provided with the distribution.
|
|
560
|
-
*
|
|
561
|
-
* 3. Neither the name of the copyright holder nor the names of its
|
|
562
|
-
* contributors may be used to endorse or promote products derived from
|
|
563
|
-
* this software without specific prior written permission.
|
|
564
|
-
*
|
|
565
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
566
|
-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
567
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
568
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
569
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
570
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
571
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
572
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
573
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
574
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
575
|
-
*/
|
|
576
|
-
|
|
577
|
-
/** 2D affine transform [a, b, c, d, e, f]: x' = a·x + b·y + c, y' = d·x + e·y + f. */
|
|
578
|
-
type Affine = [number, number, number, number, number, number];
|
|
579
|
-
/** The hat: a 13-sided polykite (eight kites of a hexagonal grid). */
|
|
580
|
-
declare const HAT: Polygon;
|
|
581
|
-
/**
|
|
582
|
-
* Hat labels, by the metatile a hat belongs to: "H1" is the one reflected hat in each H
|
|
583
|
-
* metatile; the others are unreflected.
|
|
584
|
-
*/
|
|
585
|
-
type HatLabel = "H1" | "H" | "T" | "P" | "F";
|
|
586
|
-
interface HatLeaf {
|
|
587
|
-
kind: "hat";
|
|
588
|
-
label: HatLabel;
|
|
589
|
-
}
|
|
590
|
-
interface MetaTile {
|
|
591
|
-
kind: "meta";
|
|
592
|
-
/** Approximate outline of the cluster, in its own coordinates. */
|
|
593
|
-
shape: Polygon;
|
|
594
|
-
children: {
|
|
595
|
-
T: Affine;
|
|
596
|
-
geom: Geom;
|
|
597
|
-
}[];
|
|
598
|
-
}
|
|
599
|
-
type Geom = HatLeaf | MetaTile;
|
|
600
|
-
/**
|
|
601
|
-
* The H metatile at `level` (0 = the initial four-hat H), and the transform from its
|
|
602
|
-
* coordinates to those of the level-0 H it contains. Each level's H contains the previous
|
|
603
|
-
* level's H as its first child, so anchoring on the level-0 H makes every level an
|
|
604
|
-
* extension of the one before.
|
|
605
|
-
*/
|
|
606
|
-
declare function hatSupertile(level: number, chain?: number | readonly number[]): {
|
|
607
|
-
H: MetaTile;
|
|
608
|
-
toAnchor: Affine;
|
|
609
|
-
};
|
|
610
|
-
type Bounds = {
|
|
611
|
-
x0: number;
|
|
612
|
-
y0: number;
|
|
613
|
-
x1: number;
|
|
614
|
-
y1: number;
|
|
615
|
-
};
|
|
616
|
-
/** Bounds of `g`'s hats after transform T (conservative: the transformed box's box). */
|
|
617
|
-
declare function placedBounds(g: Geom, T: Affine): Bounds;
|
|
618
|
-
|
|
619
|
-
/** Tile(1,1): fourteen unit edges (two of them collinear), angles in multiples of 30°. */
|
|
620
|
-
declare const SPECTRE: Polygon;
|
|
621
|
-
type SpectreLabel = "Gamma1" | "Gamma2" | "Delta" | "Theta" | "Lambda" | "Xi" | "Pi" | "Sigma" | "Phi" | "Psi";
|
|
622
|
-
type Cluster = "Gamma" | "Delta" | "Theta" | "Lambda" | "Xi" | "Pi" | "Sigma" | "Phi" | "Psi";
|
|
623
|
-
type Node = {
|
|
624
|
-
kind: "tile";
|
|
625
|
-
label: SpectreLabel;
|
|
626
|
-
} | {
|
|
627
|
-
kind: "meta";
|
|
628
|
-
children: {
|
|
629
|
-
T: Affine;
|
|
630
|
-
node: Node;
|
|
631
|
-
}[];
|
|
632
|
-
quad: Vec[];
|
|
633
|
-
};
|
|
634
|
-
/**
|
|
635
|
-
* The supertile of type `cluster` at `level`, and the transform from its coordinates to
|
|
636
|
-
* those of the level-0 cluster at the end of the chain that follows `slot` at every level
|
|
637
|
-
* (the slot must hold the same cluster type), so every level extends the one before.
|
|
638
|
-
*/
|
|
639
|
-
declare function spectreSupertile(level: number, cluster?: Cluster, slot?: number): {
|
|
640
|
-
root: Node;
|
|
641
|
-
toAnchor: Affine;
|
|
642
|
-
};
|
|
643
|
-
|
|
644
|
-
/**
|
|
645
|
-
* How a tiling edge may be shaped:
|
|
646
|
-
* - "J": any curve.
|
|
647
|
-
* - "S": looks the same after a 180° turn (like the letter S).
|
|
648
|
-
* - "U": looks the same mirrored across its midpoint (like the letter U).
|
|
649
|
-
* - "I": straight.
|
|
650
|
-
*/
|
|
651
|
-
type EdgeKind = "J" | "S" | "U" | "I";
|
|
652
|
-
/** The isohedral types available (IH numbers; 81 of the 93 have freely shaped tiles). */
|
|
653
|
-
declare const isohedralTypes: readonly number[];
|
|
654
|
-
interface IsohedralInfo {
|
|
655
|
-
/** Number of shape parameters, which move the tile's corners. */
|
|
656
|
-
numParameters: number;
|
|
657
|
-
defaultParameters: number[];
|
|
658
|
-
/** Shape constraint of each edge class, in the order `edges` curves are given. */
|
|
659
|
-
edgeKinds: EdgeKind[];
|
|
660
|
-
/** Number of tile corners (tiling vertices). */
|
|
661
|
-
numVertices: number;
|
|
662
|
-
}
|
|
663
|
-
/** Parameters and edge constraints of an isohedral type, for building UIs. */
|
|
664
|
-
declare function isohedralInfo(ih: number): IsohedralInfo;
|
|
665
|
-
/**
|
|
666
|
-
* The prototile outline (in Tactile's coordinates) for a spec. Without an explicit
|
|
667
|
-
* `amount`, the "wave" curves start at 0.15 and are lowered until the outline doesn't
|
|
668
|
-
* cross itself (a few types with short edges or sharp corners need less).
|
|
669
|
-
*/
|
|
670
|
-
declare function isohedralPrototile(spec: Omit<IsohedralSpec, "type" | "size">): Polygon;
|
|
671
|
-
|
|
672
59
|
/**
|
|
673
60
|
* One corner of a polygon after rounding: the outline runs straight to `start`,
|
|
674
61
|
* follows a circular arc of `radius` around `center` to `end`, then continues.
|
|
@@ -700,272 +87,6 @@ declare function roundCorners(poly: Polygon, radius: number | readonly number[])
|
|
|
700
87
|
*/
|
|
701
88
|
declare function roundedPolygon(poly: Polygon, radius: number | readonly number[], maxStep?: number): Polygon;
|
|
702
89
|
|
|
703
|
-
/**
|
|
704
|
-
* How tiles at the edge of the region are treated.
|
|
705
|
-
* - "clip": cut tiles to the region outline (a full-bleed look).
|
|
706
|
-
* - "inside": keep only tiles that fit entirely inside the region.
|
|
707
|
-
* - "overflow": keep every tile that touches the region, uncut.
|
|
708
|
-
* - "window": tiles stay whole and the region is a window onto them: renderers shape,
|
|
709
|
-
* round, bevel and fill each tile as the whole tile (`Cell.tile`) and hide
|
|
710
|
-
* what falls outside the region (`Layout.view`). A cut edge is a straight
|
|
711
|
-
* line through the tile, not a new corner.
|
|
712
|
-
*/
|
|
713
|
-
type EdgeMode = "clip" | "inside" | "overflow" | "window";
|
|
714
|
-
interface LayoutOptions {
|
|
715
|
-
/**
|
|
716
|
-
* The area to tile: a rectangle or any simple polygon (convex or not; it mustn't cross
|
|
717
|
-
* itself), in your own units (cm, px, in…).
|
|
718
|
-
*/
|
|
719
|
-
region: Rect | Polygon;
|
|
720
|
-
/**
|
|
721
|
-
* Areas inside the region to leave empty: windows, doors, sockets. Rectangles or
|
|
722
|
-
* simple polygons; they may overlap each other or the region's edge. Tiles are cut
|
|
723
|
-
* around them (or skipped, with `edges: "inside"`), and `margin` applies around them too.
|
|
724
|
-
*/
|
|
725
|
-
holes?: (Rect | Polygon)[];
|
|
726
|
-
tiling: TilingSpec;
|
|
727
|
-
/** Space between neighboring tiles. Defaults to 0. */
|
|
728
|
-
gap?: number;
|
|
729
|
-
/** Empty border kept between the region outline (and any holes) and the tiles. Defaults to 0. */
|
|
730
|
-
margin?: number;
|
|
731
|
-
/** Pattern rotation in degrees (ignored by the random patterns: mondrian, voronoi, delaunay, ashlar, jigsaw). Defaults to 0. */
|
|
732
|
-
rotation?: number;
|
|
733
|
-
/**
|
|
734
|
-
* Shifts the pattern (ignored by the random patterns). For penrose this is where the
|
|
735
|
-
* ten-fold star at the pattern's center sits. Defaults to the top-left of the region.
|
|
736
|
-
*/
|
|
737
|
-
origin?: Vec;
|
|
738
|
-
/** Defaults to "clip". */
|
|
739
|
-
edges?: EdgeMode;
|
|
740
|
-
/**
|
|
741
|
-
* Drop edge tiles that end up smaller than this fraction (0–1) of a full tile,
|
|
742
|
-
* so you don't get slivers. Applies to "clip", "overflow" and "window". Defaults to 0.
|
|
743
|
-
*/
|
|
744
|
-
minFill?: number;
|
|
745
|
-
/**
|
|
746
|
-
* Round every tile corner with this radius, in region units. Corners too small
|
|
747
|
-
* for the full radius get the largest radius that fits. Defaults to 0 (sharp).
|
|
748
|
-
* Rounding is applied when rendering; `Cell.polygon`, `area` and `centroid`
|
|
749
|
-
* describe the sharp-cornered shape.
|
|
750
|
-
*/
|
|
751
|
-
cornerRadius?: number;
|
|
752
|
-
/**
|
|
753
|
-
* Scale the whole pattern (every tile size in the tiling spec) by this factor, about
|
|
754
|
-
* the pattern origin. Handy for fitting a tile count without knowing which size
|
|
755
|
-
* parameters a pattern has; see `fitCount`. Defaults to 1.
|
|
756
|
-
*/
|
|
757
|
-
tileScale?: number;
|
|
758
|
-
/**
|
|
759
|
-
* Featured tiles: groups of neighboring tiles merged into one bigger cell, e.g. for a
|
|
760
|
-
* hero image. Merging happens before the gap and edge handling, so a featured cell gets
|
|
761
|
-
* the same gap all round as any other. See `Feature`.
|
|
762
|
-
*/
|
|
763
|
-
features?: Feature[];
|
|
764
|
-
/**
|
|
765
|
-
* Vary the tile size across the region: the size wanted at each point, as a factor of the
|
|
766
|
-
* tiling's own size (1 as given, 0.5 half as big, 2 twice). Voronoi and Delaunay change
|
|
767
|
-
* size smoothly; other tilings are generated at the largest size wanted and, where tiles
|
|
768
|
-
* should be smaller, replaced by the same tiling at half the scale (again and again, down
|
|
769
|
-
* to the smallest), cut to fit. Grids and other tilings that halve exactly nest without
|
|
770
|
-
* cuts. See `radialSize`, `edgeSize` and `imageSize`.
|
|
771
|
-
*/
|
|
772
|
-
sizeAt?: (point: Vec) => number;
|
|
773
|
-
/** Safety cap on generated tiles. Defaults to 20000. */
|
|
774
|
-
maxTiles?: number;
|
|
775
|
-
}
|
|
776
|
-
/**
|
|
777
|
-
* A featured tile: `tiles` neighboring tiles merged into one cell. The group grows from
|
|
778
|
-
* a tile near `at`, adding whichever neighbor keeps it most compact (so 4 grid tiles make
|
|
779
|
-
* a 2 × 2 square, 7 hexagons a flower); several starting tiles are tried and the most
|
|
780
|
-
* compact group kept, near `at` and avoiding tiles the region edge cuts. Features don't
|
|
781
|
-
* share tiles: a later one grows among the tiles still free.
|
|
782
|
-
*/
|
|
783
|
-
interface Feature {
|
|
784
|
-
/** How many tiles to merge. Defaults to 4. Fewer are merged if the group runs out of room. */
|
|
785
|
-
tiles?: number;
|
|
786
|
-
/** Where the group starts, in region units. Defaults to the middle of the region. */
|
|
787
|
-
at?: Vec;
|
|
788
|
-
/**
|
|
789
|
-
* Exact tile ids to merge instead (from a layout without features; ids are stable).
|
|
790
|
-
* Overrides `tiles` and `at`. Tiles that aren't in the layout or are already taken are skipped.
|
|
791
|
-
*/
|
|
792
|
-
ids?: string[];
|
|
793
|
-
/**
|
|
794
|
-
* Which content item (by position) goes in this featured cell. By default featured cells
|
|
795
|
-
* take the first items, in `features` order. See `weightedLayout`.
|
|
796
|
-
*/
|
|
797
|
-
item?: number;
|
|
798
|
-
}
|
|
799
|
-
interface Cell {
|
|
800
|
-
/** Stable id derived from the tile's position in the pattern. */
|
|
801
|
-
id: string;
|
|
802
|
-
/** Position in reading order (top-to-bottom, then left-to-right). Use it to assign content to cells. */
|
|
803
|
-
index: number;
|
|
804
|
-
/** Visible shape: after gap and edge handling. */
|
|
805
|
-
polygon: Polygon;
|
|
806
|
-
/**
|
|
807
|
-
* Holes in the visible shape, when a region hole lies wholly inside the tile. Absent
|
|
808
|
-
* otherwise. `area` and `centroid` account for them.
|
|
809
|
-
*/
|
|
810
|
-
holes?: Polygon[];
|
|
811
|
-
/** The full pattern tile before gap and edge handling. */
|
|
812
|
-
original: Polygon;
|
|
813
|
-
/**
|
|
814
|
-
* With `edges: "window"`, for a cell the region outline cuts: the whole tile (after the
|
|
815
|
-
* gap), which renderers shape, round and fill, letting the region hide the rest. `polygon`
|
|
816
|
-
* is still the visible part (its largest piece, when the outline cuts the tile in two).
|
|
817
|
-
* See `cellShape` and `visibleShapes`.
|
|
818
|
-
*/
|
|
819
|
-
tile?: Polygon;
|
|
820
|
-
bbox: Rect;
|
|
821
|
-
centroid: Vec;
|
|
822
|
-
area: number;
|
|
823
|
-
/** The tile crosses the region outline (it was cut in "clip" mode, or sticks out in "overflow"). */
|
|
824
|
-
boundary: boolean;
|
|
825
|
-
/** Which prototile this is a copy of (e.g. herringbone: 0 horizontal, 1 vertical). */
|
|
826
|
-
protoTile: number;
|
|
827
|
-
/** Ids of cells that share an edge with this one in the underlying pattern. */
|
|
828
|
-
neighbors: string[];
|
|
829
|
-
/** For a featured cell: its position in `features`. Featured cells get content first. */
|
|
830
|
-
featured?: number;
|
|
831
|
-
/** For a featured cell: the content item it's for, when its feature names one (`Feature.item`). */
|
|
832
|
-
featuredItem?: number;
|
|
833
|
-
/** For a featured cell: ids of the tiles merged into it. */
|
|
834
|
-
merged?: string[];
|
|
835
|
-
}
|
|
836
|
-
interface Layout {
|
|
837
|
-
/** The region outline (before margin). */
|
|
838
|
-
region: Polygon;
|
|
839
|
-
/** The region's holes (before margin), positively oriented. */
|
|
840
|
-
holes: Polygon[];
|
|
841
|
-
/** Bounding box of the region; a good SVG viewBox. */
|
|
842
|
-
bounds: Rect;
|
|
843
|
-
/** Corner radius renderers apply to every cell (0 for sharp corners). */
|
|
844
|
-
cornerRadius: number;
|
|
845
|
-
/**
|
|
846
|
-
* With `edges: "window"`: the area tiles show in (the region less its margin and holes).
|
|
847
|
-
* Renderers hide whatever part of a tile lies outside it.
|
|
848
|
-
*/
|
|
849
|
-
view?: Shape[];
|
|
850
|
-
cells: Cell[];
|
|
851
|
-
}
|
|
852
|
-
declare function createLayout(options: LayoutOptions): Layout;
|
|
853
|
-
/**
|
|
854
|
-
* Greedy graph coloring over cell adjacency: neighboring cells get different
|
|
855
|
-
* color indices. Handy for placeholder fills. Returns one index per cell (by cell.index).
|
|
856
|
-
*/
|
|
857
|
-
declare function colorCells(layout: Layout, colors: number): number[];
|
|
858
|
-
|
|
859
|
-
/** Small, fast, seedable PRNG returning floats in [0, 1). */
|
|
860
|
-
declare function mulberry32(seed: number): () => number;
|
|
861
|
-
|
|
862
|
-
interface SafeAreaOptions {
|
|
863
|
-
/**
|
|
864
|
-
* Width / height the area must have (an image or card of known shape, say). Omit for
|
|
865
|
-
* the largest-area rectangle of any shape (for text and other content that reflows).
|
|
866
|
-
*/
|
|
867
|
-
aspect?: number;
|
|
868
|
-
/**
|
|
869
|
-
* For a cell an `edges: "window"` layout cuts: "tile" (the default) fits the whole tile,
|
|
870
|
-
* as if the region weren't there, so content near the edge is partly hidden like the
|
|
871
|
-
* tile; "visible" fits the part that shows. Other cells are the same either way.
|
|
872
|
-
*/
|
|
873
|
-
within?: "tile" | "visible";
|
|
874
|
-
}
|
|
875
|
-
/**
|
|
876
|
-
* The largest axis-aligned rectangle that fits wholly inside a cell's shape (its outline,
|
|
877
|
-
* holes and rounded corners), so content placed there isn't clipped. With `aspect`, the
|
|
878
|
-
* largest rectangle of that shape. Among equally large positions it picks the one nearest
|
|
879
|
-
* the cell's center. In layout coordinates; see `safeAreaCss` for CSS.
|
|
880
|
-
*
|
|
881
|
-
* Works for any shape, convex or not. Results are cached per cell.
|
|
882
|
-
*/
|
|
883
|
-
declare function safeArea(cell: Cell, layout: Pick<Layout, "cornerRadius" | "view">, options?: SafeAreaOptions): Rect;
|
|
884
|
-
|
|
885
|
-
/**
|
|
886
|
-
* CSS placement for one cell, as percentages of the layout bounds, so the result
|
|
887
|
-
* scales with whatever size the container is rendered at.
|
|
888
|
-
*
|
|
889
|
-
* Apply to an absolutely positioned element inside a `position: relative`
|
|
890
|
-
* container whose aspect ratio matches `layout.bounds`
|
|
891
|
-
* (see `boundsAspectRatio`). Works with any framework, or none.
|
|
892
|
-
*/
|
|
893
|
-
interface CellCss {
|
|
894
|
-
left: string;
|
|
895
|
-
top: string;
|
|
896
|
-
width: string;
|
|
897
|
-
height: string;
|
|
898
|
-
/** A `polygon(...)` clip path relative to the element's own box. */
|
|
899
|
-
clipPath: string;
|
|
900
|
-
}
|
|
901
|
-
/**
|
|
902
|
-
* `polygon(...)` for `poly`, expressed as percentages of `box`. With `holes`, it's an
|
|
903
|
-
* even–odd polygon that visits each hole from the outline's first point and comes back,
|
|
904
|
-
* so the connecting lines cancel out.
|
|
905
|
-
*/
|
|
906
|
-
declare function cssPolygon(poly: Polygon, box: Rect, precision?: number, holes?: Polygon[]): string;
|
|
907
|
-
/**
|
|
908
|
-
* `poly` with points added along its edges to make exactly `n`, keeping every original
|
|
909
|
-
* vertex, so any two shapes can be morphed point by point (CSS transitions only interpolate
|
|
910
|
-
* `polygon()` values with the same number of points). The points run the same way round
|
|
911
|
-
* for every shape and start at the corner nearest the top left of `box`, so a shape
|
|
912
|
-
* morphs into another without twisting. A polygon with more than `n` points is returned
|
|
913
|
-
* as it is.
|
|
914
|
-
*/
|
|
915
|
-
declare function resamplePolygon(poly: Polygon, n: number, box: Rect): Polygon;
|
|
916
|
-
/**
|
|
917
|
-
* `poly` with its corners rounded (by `radius`, or a radius per corner) as at least `n`
|
|
918
|
-
* points, laid out the same way whatever the radius: each corner gets a fixed number of
|
|
919
|
-
* points by how far the outline turns there (one per 10°, all on the vertex when it's sharp,
|
|
920
|
-
* spread along the arc when it's rounded), and the rest go along the edges by the sharp
|
|
921
|
-
* outline's edge lengths. So a tile morphs smoothly as its corner radius changes, as well as
|
|
922
|
-
* into other shapes (see `resamplePolygon` for the start point and direction). Shapes with
|
|
923
|
-
* too many corners for `n` (merged featured tiles, say) get more points: the next multiple
|
|
924
|
-
* of 24 that fits, so most tiles share one count and can morph into each other.
|
|
925
|
-
*/
|
|
926
|
-
declare function morphPolygon(poly: Polygon, radius: number | readonly number[], n: number, box: Rect): Polygon;
|
|
927
|
-
/** Options for `cellCss`. */
|
|
928
|
-
interface CellCssOptions {
|
|
929
|
-
/**
|
|
930
|
-
* Give every clip path this many points (see `morphPolygon`), so CSS can animate one tile
|
|
931
|
-
* shape into another. Shapes with many corners (merged featured tiles) get more, in steps
|
|
932
|
-
* of 24; cells with holes keep their own.
|
|
933
|
-
*/
|
|
934
|
-
points?: number;
|
|
935
|
-
}
|
|
936
|
-
/**
|
|
937
|
-
* `polygon(...)` for several shapes (outlines with holes) at once: an even–odd polygon
|
|
938
|
-
* that visits each extra loop from the first outline's first point and comes back.
|
|
939
|
-
*/
|
|
940
|
-
declare function cssShapes(shapes: readonly Shape[], box: Rect, precision?: number): string;
|
|
941
|
-
/**
|
|
942
|
-
* CSS placement for `cell` within `layout`, including rounded corners if the layout has
|
|
943
|
-
* them. A window cell (see `cellShape`) is placed over its whole tile and clipped to the
|
|
944
|
-
* part of it inside `layout.view`.
|
|
945
|
-
*/
|
|
946
|
-
declare function cellCss(cell: Cell, layout: Layout, precision?: number, options?: CellCssOptions): CellCss;
|
|
947
|
-
/**
|
|
948
|
-
* Placement, inside a cell's element (as positioned by `cellCss`), of a box covering the
|
|
949
|
-
* whole layout bounds. Put the same content (an image with `object-fit: cover`, say) in
|
|
950
|
-
* every cell at this placement and the cells together show it as one picture, each
|
|
951
|
-
* through its own window.
|
|
952
|
-
*/
|
|
953
|
-
declare function backdropCss(cell: Cell, layout: Layout, precision?: number): Omit<CellCss, "clipPath">;
|
|
954
|
-
/**
|
|
955
|
-
* Placement, inside a cell's element (as positioned by `cellCss`), of the cell's safe area
|
|
956
|
-
* (see `safeArea`): the largest rectangle that isn't clipped by the tile's shape.
|
|
957
|
-
*/
|
|
958
|
-
declare function safeAreaCss(cell: Cell, layout: Layout, options?: SafeAreaOptions, precision?: number): Omit<CellCss, "clipPath">;
|
|
959
|
-
/** `polygon(...)` for the layout's region, with its holes, relative to the bounds. */
|
|
960
|
-
declare function regionCss(layout: Layout, precision?: number): string;
|
|
961
|
-
/**
|
|
962
|
-
* `polygon(...)` for the area tiles show in, relative to the bounds: `layout.view` in a
|
|
963
|
-
* window layout, else the region with its holes.
|
|
964
|
-
*/
|
|
965
|
-
declare function viewCss(layout: Layout, precision?: number): string;
|
|
966
|
-
/** Value for the CSS `aspect-ratio` property of a container holding `layout`. */
|
|
967
|
-
declare function boundsAspectRatio(layout: Layout): string;
|
|
968
|
-
|
|
969
90
|
/** The shape a renderer draws for a cell, before the layout's `view` hides any of it. */
|
|
970
91
|
interface CellShape {
|
|
971
92
|
/** Sharp-cornered outline: `cell.tile` for a window cell, else `cell.polygon`. */
|
|
@@ -1021,15 +142,27 @@ interface BevelFacet {
|
|
|
1021
142
|
declare function bevelFacets(cell: Cell, layout: Pick<Layout, "cornerRadius">, options: BevelOptions): BevelFacet[];
|
|
1022
143
|
|
|
1023
144
|
type Direction = "up" | "down" | "left" | "right";
|
|
145
|
+
interface DirectionOptions {
|
|
146
|
+
/** Only land on cells this accepts (those with content, say). Others are passed over. */
|
|
147
|
+
accept?: (cell: Cell) => boolean;
|
|
148
|
+
/**
|
|
149
|
+
* The cross-axis coordinate to keep to: x when moving up or down, y when moving left or
|
|
150
|
+
* right. Pass the value from the start of a run of presses, and
|
|
151
|
+
* repeated moves zigzag along a column of a hexagon or brick tiling instead of drifting
|
|
152
|
+
* to one side. Defaults to `from`'s center.
|
|
153
|
+
*/
|
|
154
|
+
lane?: number;
|
|
155
|
+
}
|
|
1024
156
|
/**
|
|
1025
157
|
* The cell to move to from `from` in a direction, for arrow-key navigation over any tiling.
|
|
1026
158
|
*
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1029
|
-
*
|
|
1030
|
-
*
|
|
159
|
+
* Moves to a tile that shares an edge with `from` and lies ahead (its center within 60° of
|
|
160
|
+
* the direction), so no row is ever skipped; among those it takes the one nearest the
|
|
161
|
+
* `lane`. If no touching tile qualifies (at a hole, or because `accept` passes them over),
|
|
162
|
+
* it looks further: the nearest accepted cell ahead, distance from the lane counting double.
|
|
163
|
+
* Returns undefined at the edge.
|
|
1031
164
|
*/
|
|
1032
|
-
declare function cellInDirection(layout: Layout, from: Cell, direction: Direction,
|
|
165
|
+
declare function cellInDirection(layout: Layout, from: Cell, direction: Direction, options?: DirectionOptions | ((cell: Cell) => boolean)): Cell | undefined;
|
|
1033
166
|
|
|
1034
167
|
/**
|
|
1035
168
|
* Tile size across a region, as a factor of the tiling's own size at each point: 1 is the
|
|
@@ -1336,4 +469,4 @@ interface WeightedLayoutResult {
|
|
|
1336
469
|
*/
|
|
1337
470
|
declare function weightedLayout(options: LayoutOptions, weights: readonly number[], settings?: WeightedLayoutOptions): WeightedLayoutResult;
|
|
1338
471
|
|
|
1339
|
-
export { type
|
|
472
|
+
export { type BevelFacet, type BevelOptions, Cell, type CellFill, type CellShape, type ContentCells, type ContentOptions, type ContentPlacement, type CoverOptions, type Direction, type DirectionOptions, Feature, type FitOptions, type FitResult, type Focus, type GradientOptions, type HitOptions, type ImageFillOptions, Layout, LayoutOptions, type MatchOptions, type Piece, type Pixels, Polygon, Rect, type RoundedCorner, type ScreenBox, Shape, type SizeField, type SubstitutionRule, Vec, type WeightOptions, type WeightedLayoutOptions, type WeightedLayoutResult, bevelFacets, cellAt, cellInDirection, cellShape, cellsInRect, contentSlots, coverRect, delaunayTriangles, edgeSize, estimateFocus, fitCount, generateSubstitution, gradientFill, imageFill, imageSize, lightVector, loadImagePixels, matchSlots, nearestCell, objectPosition, paletteFill, penroseKitesAndDarts, penroseRhombs, protoTileFill, radialSize, randomFill, roundCorners, roundedPolygon, screenToLayout, tileSpans, visibleShapes, voronoiCells, weightedFeatures, weightedLayout };
|