@harmonics/lattice-ui 0.0.0-stage → 0.4.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.
@@ -0,0 +1,31 @@
1
+ import { defineLatticeFace, LatticeFace } from "./face";
2
+ import { defineLatticeIcon, LatticeIcon } from "./icon";
3
+ import { defineLatticeShape, LatticeShape } from "./shape";
4
+ import { defineShearsPad, ShearsPadElement, type StrokeDetail } from "./shears";
5
+ import { defineHexSky, HexSky } from "./sky";
6
+ export { FACES } from "../faceLattice";
7
+ export type { Part } from "../hexes";
8
+ export { FACE_TAG, MOODS } from "./face";
9
+ export { ICON_NAMES, ICON_TAG, type IconName } from "./icon";
10
+ export { SHAPE_TAG } from "./shape";
11
+ export { SHAPE_NAMES, type ShapeName, TONES } from "./shapes";
12
+ export { SHEARS_TAG, type StrokePoint } from "./shears";
13
+ export { SKY_TAG } from "./sky";
14
+ export { defineHexSky, defineLatticeFace, defineLatticeIcon, defineLatticeShape, defineShearsPad, HexSky, LatticeFace, LatticeIcon, LatticeShape, ShearsPadElement, type StrokeDetail, };
15
+ /** Register every element once; a second call, or a call on a server, does nothing. */
16
+ export declare function defineLatticeElements(): void;
17
+ declare global {
18
+ interface HTMLElementTagNameMap {
19
+ "lattice-face": LatticeFace;
20
+ "hex-sky": HexSky;
21
+ "lattice-shape": LatticeShape;
22
+ "shears-pad": ShearsPadElement;
23
+ "lattice-icon": LatticeIcon;
24
+ }
25
+ interface HTMLElementEventMap {
26
+ stroke: CustomEvent<StrokeDetail>;
27
+ strokeend: CustomEvent<{
28
+ points: StrokeDetail["points"];
29
+ }>;
30
+ }
31
+ }
@@ -0,0 +1,29 @@
1
+ import type { Part } from "../hexes";
2
+ import { LatticeElement } from "./host";
3
+ import { type ShapeName } from "./shapes";
4
+ export declare const SHAPE_TAG = "lattice-shape";
5
+ export declare class LatticeShape extends LatticeElement {
6
+ static readonly observedAttributes: string[];
7
+ private readonly shapeSignal;
8
+ private readonly partsSignal;
9
+ private readonly toneSignal;
10
+ private readonly liftSignal;
11
+ private readonly scaleSignal;
12
+ private readonly labelSignal;
13
+ get shape(): ShapeName;
14
+ set shape(name: string);
15
+ /** The parts drawn: those given, or the shape's. */
16
+ get parts(): Part[];
17
+ set parts(parts: unknown);
18
+ get tone(): number;
19
+ set tone(tone: number | string);
20
+ get lift(): number;
21
+ set lift(lift: number | string);
22
+ get scale(): number;
23
+ set scale(scale: number | string);
24
+ get label(): string;
25
+ set label(label: string);
26
+ attributeChangedCallback(name: string, _: string | null, value: string | null): void;
27
+ }
28
+ /** Register `<lattice-shape>` once; a second call, or a call on a server, does nothing. */
29
+ export declare const defineLatticeShape: () => void;
@@ -0,0 +1,45 @@
1
+ import { type FlatFace, type Part } from "../hexes";
2
+ /** The woods a part can be cut from: 0 to 4 the tree's, 5 to 7 its fruit (FRUIT in hexes.ts). */
3
+ export declare const TONES = 8;
4
+ /** Each ready-made shape, in one wood. */
5
+ export declare const SHAPES: {
6
+ /** One cell. */
7
+ cell: (tone: number) => Part[];
8
+ /** Two cells side by side. */
9
+ pair: (tone: number) => Part[];
10
+ /** Three cells in a row. */
11
+ line: (tone: number) => Part[];
12
+ /** A cell and the six round it. */
13
+ flower: (tone: number) => Part[];
14
+ /** One triangle. */
15
+ triangle: (tone: number) => Part[];
16
+ /** Two triangles sharing a side. */
17
+ diamond: (tone: number) => Part[];
18
+ /** Three triangles in a strip. */
19
+ trapezoid: (tone: number) => Part[];
20
+ /** Four triangles: a triangle twice the size. */
21
+ "big-triangle": (tone: number) => Part[];
22
+ /** Six triangles round a corner: a hexagon that can stand off the cells. */
23
+ hexagon: (tone: number) => Part[];
24
+ };
25
+ export type ShapeName = keyof typeof SHAPES;
26
+ export declare const SHAPE_NAMES: ShapeName[];
27
+ /** A wood, kept to the ones there are. */
28
+ export declare const toneOf: (tone: number) => number;
29
+ /**
30
+ * Parts from anything a page may hand over (a property, or JSON in an attribute): each a cell
31
+ * `{kind: "cell", at: {q, r}}` or a triangle `{kind: "tri", at: {i, j, k}}`, with an optional
32
+ * `tone`. Whatever is not one is left out.
33
+ */
34
+ export declare function partsFrom(value: unknown, tone: number): Part[];
35
+ /** A shape drawn on its own: its faces, its seams, and the box round them with `pad` to spare. */
36
+ export declare function drawingOf(parts: Part[], lift: number, pad?: number): {
37
+ faces: FlatFace[];
38
+ seams: string;
39
+ box: {
40
+ x: number;
41
+ y: number;
42
+ width: number;
43
+ height: number;
44
+ };
45
+ };
@@ -0,0 +1,20 @@
1
+ import { LatticeElement } from "./host";
2
+ export declare const SHEARS_TAG = "shears-pad";
3
+ /** A point in the element's own pixels, from its top-left. */
4
+ export type StrokePoint = {
5
+ x: number;
6
+ y: number;
7
+ };
8
+ export interface StrokeDetail {
9
+ points: StrokePoint[];
10
+ fresh: boolean;
11
+ }
12
+ export declare class ShearsPadElement extends LatticeElement {
13
+ static readonly observedAttributes: string[];
14
+ private readonly disabledSignal;
15
+ get disabled(): boolean;
16
+ set disabled(disabled: boolean | string | null);
17
+ attributeChangedCallback(_: string, __: string | null, value: string | null): void;
18
+ }
19
+ /** Register `<shears-pad>` once; a second call, or a call on a server, does nothing. */
20
+ export declare const defineShearsPad: () => void;
@@ -0,0 +1,20 @@
1
+ import { LatticeElement } from "./host";
2
+ export declare const SKY_TAG = "hex-sky";
3
+ export declare class HexSky extends LatticeElement {
4
+ static readonly observedAttributes: string[];
5
+ private readonly kindSignal;
6
+ private readonly scaleSignal;
7
+ private readonly xSignal;
8
+ private readonly ySignal;
9
+ get kind(): "sky" | "earth";
10
+ set kind(kind: string);
11
+ get scale(): number;
12
+ set scale(scale: number | string);
13
+ get x(): number;
14
+ set x(x: number | string);
15
+ get y(): number;
16
+ set y(y: number | string);
17
+ attributeChangedCallback(name: string, _: string | null, value: string | null): void;
18
+ }
19
+ /** Register `<hex-sky>` once; a second call, or a call on a server, does nothing. */
20
+ export declare const defineHexSky: () => void;
@@ -0,0 +1,46 @@
1
+ import type { HexSky, IconName, LatticeFace, LatticeIcon, LatticeShape, Part, ShapeName, ShearsPadElement, StrokeDetail, StrokePoint } from "./index";
2
+ declare module "solid-js" {
3
+ namespace JSX {
4
+ interface IntrinsicElements {
5
+ "lattice-face": JSX.HTMLAttributes<LatticeFace> & {
6
+ mood?: LatticeFace["mood"];
7
+ expression?: string;
8
+ pulse?: number | string;
9
+ still?: boolean;
10
+ size?: number | string;
11
+ label?: string;
12
+ decorative?: boolean;
13
+ };
14
+ "hex-sky": JSX.HTMLAttributes<HexSky> & {
15
+ kind?: "sky" | "earth";
16
+ scale?: number | string;
17
+ x?: number | string;
18
+ y?: number | string;
19
+ };
20
+ "lattice-shape": JSX.HTMLAttributes<LatticeShape> & {
21
+ shape?: ShapeName;
22
+ parts?: string;
23
+ tone?: number | string;
24
+ lift?: number | string;
25
+ scale?: number | string;
26
+ label?: string;
27
+ };
28
+ "shears-pad": JSX.HTMLAttributes<ShearsPadElement> & {
29
+ disabled?: boolean;
30
+ };
31
+ "lattice-icon": JSX.HTMLAttributes<LatticeIcon> & {
32
+ name?: IconName;
33
+ label?: string;
34
+ };
35
+ }
36
+ interface ExplicitProperties {
37
+ parts: Part[] | string;
38
+ }
39
+ interface CustomEvents {
40
+ stroke: CustomEvent<StrokeDetail>;
41
+ strokeend: CustomEvent<{
42
+ points: StrokePoint[];
43
+ }>;
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,56 @@
1
+ export type Point = {
2
+ x: number;
3
+ y: number;
4
+ };
5
+ export declare const SQ3: number;
6
+ export declare const ring: (ps: Point[]) => string;
7
+ /** Every hexagon here is this far from its middle to each corner. */
8
+ export declare const R = 120;
9
+ /** What a triangle is: plate, or part of a feature. The stylesheet colours each. */
10
+ export type Ink = "plate" | "ink" | "glint" | "blush" | "tear" | "tongue";
11
+ export interface Tri {
12
+ corners: Point[];
13
+ /** Its middle, as a share of R: the face is described in those units. */
14
+ mid: Point;
15
+ /** Its top-left corner on the lattice, and which way it points (0 right, 1 left). */
16
+ i: number;
17
+ j: number;
18
+ k: 0 | 1;
19
+ }
20
+ /** How far a point (in units of R) is from another, as a pointy-top hexagon measures it. */
21
+ export declare function hexD(p: Point, c?: Point): number;
22
+ /** The hexagon's triangles, `n` to a side. */
23
+ export declare function trianglesOf(n: number): Tri[];
24
+ type Region = (p: Point) => boolean;
25
+ /** A face: its layers, in order; a triangle takes the last one it falls in. */
26
+ export type Face = [Ink, Region][];
27
+ export interface Expression {
28
+ name: string;
29
+ /** What it does while it idles, in a word. */
30
+ idle: string;
31
+ at: (t: number) => Face;
32
+ }
33
+ export declare const FACES: Expression[];
34
+ /** What each triangle of a lattice is, for a face. */
35
+ export declare const inkOf: (face: Face, tri: Tri, n: number) => Ink;
36
+ /** How a face is lit. */
37
+ export type Depth = "flat" | "raised" | "carved" | "cubes";
38
+ export type Shade = "top" | "left" | "right";
39
+ /**
40
+ * Every triangle's ink and shade for a face at depth `n`:
41
+ * - raised, every feature stands a step or two off the plate, its sides below it in shade;
42
+ * - carved, every feature is cut into the plate, its far wall showing inside its top edge;
43
+ * - cubes, every feature is built of cubes seen from above: each triangle shaded by which third
44
+ * of its hexagon of the lattice it is in, as three diamonds make a cube.
45
+ */
46
+ export declare function shadedOf(face: Face, n: number, depth: Depth): {
47
+ inks: Ink[];
48
+ shades: Shade[];
49
+ };
50
+ /** The paths of a lattice, one per ink and shade. */
51
+ export declare function paths(tris: Tri[], inks: Ink[], shades?: Shade[]): {
52
+ ink: Ink;
53
+ shade: Shade;
54
+ d: string;
55
+ }[];
56
+ export {};
@@ -0,0 +1,370 @@
1
+ /** A cell of the lattice, by axial coordinates. */
2
+ export interface Hex {
3
+ q: number;
4
+ r: number;
5
+ }
6
+ /** A corner of the triangle grid. */
7
+ export interface Corner {
8
+ i: number;
9
+ j: number;
10
+ }
11
+ /** A triangle: the corner at its top-left, and which way it points (0 right, 1 left). */
12
+ export interface Tri extends Corner {
13
+ k: 0 | 1;
14
+ }
15
+ /** One part of a piece: a cell or a triangle, and the wood it is cut from. */
16
+ export type Part = {
17
+ kind: "cell";
18
+ at: Hex;
19
+ tone: number;
20
+ } | {
21
+ kind: "tri";
22
+ at: Tri;
23
+ tone: number;
24
+ };
25
+ /**
26
+ * A piece: its parts, side by side, and the corner it turns about. A piece with a cell turns about
27
+ * a cell's centre, so its cells stay on cells; the corner is chosen when the piece is made, glued
28
+ * or split, and moves with it, so a turn and its opposite always undo each other.
29
+ */
30
+ export interface Piece {
31
+ id: string;
32
+ parts: Part[];
33
+ pivot: Corner;
34
+ }
35
+ /** The top-left of a cell's box on the screen, where its prism is drawn from. */
36
+ export declare function boxOf(hex: Hex): {
37
+ x: number;
38
+ y: number;
39
+ };
40
+ /** Where a corner of the triangle grid is on the screen. */
41
+ export declare function cornerOf(corner: Corner): {
42
+ x: number;
43
+ y: number;
44
+ };
45
+ /** A triangle's three corners, as grid corners: clockwise from its top-left. */
46
+ export declare function cornersOf(tri: Tri): [Corner, Corner, Corner];
47
+ /** The cell under a point on the screen: the nearest cell centre, by cube rounding. */
48
+ export declare function hexAt(x: number, y: number): Hex;
49
+ /** The corner of the triangle grid nearest a point on the screen. */
50
+ export declare function cornerAt(x: number, y: number): Corner;
51
+ /** The corner at a cell's centre. */
52
+ export declare function centreOf(hex: Hex): Corner;
53
+ /** The six triangles of a cell, centre to corners. */
54
+ export declare function trisOf(hex: Hex): Tri[];
55
+ /** The part of the sky on the screen, in the sky's own coordinates: zoomed, it is not the screen's. */
56
+ export interface Area {
57
+ left: number;
58
+ top: number;
59
+ right: number;
60
+ bottom: number;
61
+ }
62
+ /** The sky a screen `width` by `height` shows unzoomed. */
63
+ export declare const screenArea: (width: number, height: number) => Area;
64
+ /** The triangles one part covers: a cell's six, or the triangle itself. */
65
+ export declare const trisOfPart: (part: Part) => Tri[];
66
+ /** The triangles a piece covers. */
67
+ export declare function covered(piece: Piece): Tri[];
68
+ /** The bottom of a piece's lowest corner on the screen: pieces are drawn in that order. */
69
+ export declare function bottomOf(piece: Piece): number;
70
+ /**
71
+ * Whether `piece` may stand where it is: every triangle whole on the screen (`width` by
72
+ * `height`), and none of them taken by another piece or by a cell kept clear.
73
+ */
74
+ export declare function fits(piece: Piece, pieces: Piece[], area: Area, clear?: Hex[]): boolean;
75
+ /** The piece moved by `delta`: every part and its pivot. A piece with a cell moves only whole cells. */
76
+ export declare function moved(piece: Piece, delta: Corner): Piece;
77
+ /** The piece a piece was moved from, first of all, and how far on the screen: itself, if none. */
78
+ export declare function slidOf(piece: Piece): {
79
+ from: Piece;
80
+ dx: number;
81
+ dy: number;
82
+ };
83
+ /** The whole-cell step nearest a move of (dx, dy) on the screen. */
84
+ export declare function cellStep(dx: number, dy: number): Corner;
85
+ /** The step a pointer's move of (dx, dy) on the screen comes to: the nearest one the piece can take. */
86
+ export declare function snapDelta(piece: Piece, dx: number, dy: number): Corner;
87
+ /**
88
+ * How the slots pull, as parts of a piece's unit (a cell across, or a triangle's side): how far a
89
+ * slot reaches, how near catches and holds, how far a held piece must be tugged to come free (more
90
+ * than catches it, so it never flickers at the edge), and how far it leans in before it is caught.
91
+ */
92
+ export declare const MAGNET: {
93
+ readonly reach: 0.5;
94
+ readonly capture: 0.3;
95
+ readonly release: 0.5;
96
+ readonly lean: 0.6;
97
+ };
98
+ /** Where a carried piece is drawn, and the slot it would land in. */
99
+ export interface Magnet {
100
+ /** The slot: the step from where the piece was lifted. */
101
+ step: Corner;
102
+ /** Where to draw it, as a move from where it was lifted, on the screen. */
103
+ x: number;
104
+ y: number;
105
+ /** How hard the slot pulls, 0 to 1: 1 while held. */
106
+ pull: number;
107
+ /** The slot it is held in, to hand back on the next move; none while it only leans. */
108
+ held: Corner | undefined;
109
+ }
110
+ /**
111
+ * A carried piece moved (dx, dy) by the pointer since it was lifted, and held in `held` before:
112
+ * where it is drawn and where it would land. Near a slot it leans in; nearer, the slot catches it
113
+ * and it is drawn there exactly; it stays caught until it is tugged past `MAGNET.release`.
114
+ */
115
+ export declare function magnetOf(piece: Piece, dx: number, dy: number, held?: Corner): Magnet;
116
+ /**
117
+ * The click into a slot: keyframes (Web Animations) that bring a piece from `from` (how far it is
118
+ * off, on the screen) to rest, passing it by `overshoot` of the way and settling back.
119
+ */
120
+ export declare function snapFrames(from: {
121
+ x: number;
122
+ y: number;
123
+ }, overshoot?: number): {
124
+ transform: string;
125
+ offset: number;
126
+ easing?: string;
127
+ }[];
128
+ /** How the arrow keys step a piece: a cell, or a triangle's side, in each direction. */
129
+ export declare function stepFor(piece: Piece, key: string): Corner | undefined;
130
+ /** The piece turned `turns` sixths clockwise (negative: anticlockwise) about its pivot. */
131
+ export declare function turned(piece: Piece, turns: number): Piece;
132
+ /** Where a piece turns on the screen. */
133
+ export declare const pivotPoint: (piece: Piece) => {
134
+ x: number;
135
+ y: number;
136
+ };
137
+ /** A piece of these parts, with its pivot chosen. */
138
+ export declare const pieceOf: (id: string, parts: Part[]) => Piece;
139
+ /** Whether two pieces share a side: touching at a corner is not touching. The smaller is walked. */
140
+ export declare const touching: (a: Piece, b: Piece) => boolean;
141
+ /** The sides two pieces share, each as its two corners on the screen. */
142
+ export declare function sharedSides(a: Piece, b: Piece): [{
143
+ x: number;
144
+ y: number;
145
+ }, {
146
+ x: number;
147
+ y: number;
148
+ }][];
149
+ /** The sides shared between a piece's own parts, on the screen: where it is glued. */
150
+ export declare function seamsOf(piece: Piece): [{
151
+ x: number;
152
+ y: number;
153
+ }, {
154
+ x: number;
155
+ y: number;
156
+ }][];
157
+ /** `piece` glued to every piece it touches: one piece, its parts each keeping their wood. */
158
+ export declare function glued(piece: Piece, others: Piece[]): {
159
+ piece: Piece;
160
+ absorbed: string[];
161
+ };
162
+ /**
163
+ * One part pulled off a piece: that part as a piece of its own, then what is left, as one piece or
164
+ * several if the part held them together.
165
+ */
166
+ export declare function pulledOff(piece: Piece, index: number, id: () => string): Piece[];
167
+ /** A piece broken into its units, each a piece of its own. */
168
+ export declare const apart: (piece: Piece, id: () => string) => Piece[];
169
+ /**
170
+ * The nearest place `piece` fits, searching outward from where it is, ring by ring, up to `rings`
171
+ * steps away; undefined when nothing that near fits.
172
+ */
173
+ export declare function nearestFit(piece: Piece, pieces: Piece[], area: Area, clear?: Hex[], rings?: number,
174
+ /** A further test a place must pass: to stand clear of other pieces, say. */
175
+ also?: (at: Piece) => boolean): Piece | undefined;
176
+ /** How far a step moves a piece on the screen. */
177
+ export declare const stepOnScreen: (delta: Corner) => {
178
+ x: number;
179
+ y: number;
180
+ };
181
+ /** The parts of `piece` that cannot stand where they are: off the screen, or on something taken. */
182
+ export declare function blockedParts(piece: Piece, pieces: Piece[], area: Area, clear?: Hex[]): Set<number>;
183
+ /** A piece's outer edge, as the sides on the screen that no other part of it shares. */
184
+ export declare function outlineOf(piece: Piece): [{
185
+ x: number;
186
+ y: number;
187
+ }, {
188
+ x: number;
189
+ y: number;
190
+ }][];
191
+ /**
192
+ * The pieces, every one on the screen and none overlapping, as near as can be to where they stood.
193
+ * Pieces that touch move together, by the same step, so a built thing stays whole. The biggest
194
+ * groups claim their room first; a group that is off the screen, or now overlaps one placed before
195
+ * it, is shifted by as much as it overhangs and then to the nearest place it fits. A group with
196
+ * nowhere to go stays where it was.
197
+ */
198
+ export declare function intoView(pieces: Piece[], area: Area, clear?: Hex[],
199
+ /** Pieces that stay where they are, as the tree does: the others keep clear of them. */
200
+ fixed?: Piece[]): Piece[];
201
+ /** A new cell, or a new triangle, standing on the cell under a point. */
202
+ export declare function unitAt(kind: "cell" | "tri", x: number, y: number, tone: number, id: string): Piece;
203
+ /** A clump of leaves, as an ellipse: its middle, its two radii, and how dry it is (0 to 1). */
204
+ type Clump = [number, number, number, number, number];
205
+ /** A stretch of wood: a line, with its width at either end. */
206
+ type Limb = [number, number, number, number, number, number];
207
+ /** What a tree is grown from, in its own pixels from the foot. */
208
+ export interface Growth {
209
+ /** Where each group's limb ends, in the groups' order: its branches hang there. */
210
+ ends: {
211
+ x: number;
212
+ y: number;
213
+ }[];
214
+ limbs: Limb[];
215
+ clumps: Clump[];
216
+ /** Things done lately, harvested on the ground: good, bitter, or not yet tasted. */
217
+ fruit: (boolean | undefined)[];
218
+ /** Things cut lately, lying as mulch at the trunk's foot, away from the harvest. */
219
+ mulch: number;
220
+ /** A face on the trunk: its low hollow, where the face is, is filled in. */
221
+ face: boolean;
222
+ }
223
+ /** How the tree is doing, as far as its shape shows it. Each list is per group, in order. */
224
+ export interface Shape {
225
+ /** How stale what each carries is, 0 (fresh) to 1 (all stale): its leaves yellow and thin. */
226
+ stale?: number[];
227
+ /** How far past what its root can carry each is, as a share of it: its limb droops. */
228
+ over?: number[];
229
+ /** The last group grows from no root: suckers from the trunk's foot, not a limb of the crown. */
230
+ wild?: boolean;
231
+ /** Each feeds the person: its limb puts out fresh leaves where it bends and where it ends. */
232
+ soul?: boolean[];
233
+ fruit?: (boolean | undefined)[];
234
+ mulch?: number;
235
+ face?: boolean;
236
+ }
237
+ /**
238
+ * A tree for groups that carry `counts` branches each, in order: a limb each, their ends fanned
239
+ * evenly left to right and highest in the middle, each limb thicker the more it carries and ending
240
+ * in a clump of leaves the size of what hangs there. Its `shape` says how it is doing: a limb past
241
+ * what its root can carry droops on wood too thin for it, and the trunk thins with the heaviest;
242
+ * a stale group's leaves yellow and thin; branches with no root grow as suckers from the foot; a
243
+ * tree with nothing on it is bare limbs, and one with no roots a sprout.
244
+ */
245
+ export declare function growthFor(counts: number[], shape?: Shape): Growth;
246
+ /**
247
+ * The tones of fruit, past the five woods: drawn at full strength, not as a wash like the wood, so
248
+ * a harvest reads on the ground (styles.css).
249
+ */
250
+ export declare const FRUIT: {
251
+ readonly good: 5;
252
+ readonly bitter: 6;
253
+ readonly untasted: 7;
254
+ };
255
+ /**
256
+ * Where the nth thing done lies in the harvest, left of the trunk: a row of eight, then the next
257
+ * row up. The olive is this triangle and the one across its upright side.
258
+ */
259
+ export declare function harvestSpot(n: number, foot?: {
260
+ x: number;
261
+ y: number;
262
+ }): Tri;
263
+ /** The tones of mulch, past the fruit's: walnut and ochre at full strength, turn about. */
264
+ export declare const MULCH: readonly [8, 9];
265
+ /**
266
+ * The triangles `n` things cut lately lie on, as a heap at the trunk's foot: those nearest its
267
+ * middle first, flatter than tall, so a few make a mound and many a wider one.
268
+ */
269
+ export declare function mulchSpots(n: number, foot?: {
270
+ x: number;
271
+ y: number;
272
+ }): Tri[];
273
+ /** How many set-aside things stand on the ground as saplings; the rest wait behind the last. */
274
+ export declare const SAPLINGS_SHOWN = 5;
275
+ /**
276
+ * The cells `n` set-aside things stand on as saplings: a row on the ground right of the mulch,
277
+ * side by side, out from the trunk; never more than `SAPLINGS_SHOWN`.
278
+ */
279
+ export declare function saplingSpots(n: number, foot?: {
280
+ x: number;
281
+ y: number;
282
+ }): Hex[];
283
+ /** Where the tree's foot stands on the sky when the page does not say: a laptop's screen. */
284
+ export declare const FOOT: {
285
+ x: number;
286
+ y: number;
287
+ };
288
+ /** A point of the tree, from its foot in its own pixels, on the sky. */
289
+ export declare const skyOf: (p: {
290
+ x: number;
291
+ y: number;
292
+ }, foot?: {
293
+ x: number;
294
+ y: number;
295
+ }) => {
296
+ x: number;
297
+ y: number;
298
+ };
299
+ /** How far the crown reaches to either side, on the sky. */
300
+ export declare function crownSpan(growth: Growth, foot?: {
301
+ x: number;
302
+ y: number;
303
+ }): {
304
+ left: number;
305
+ right: number;
306
+ };
307
+ /** An olive tree: its crown, its trunk and its ground, three pieces of cells and triangles. */
308
+ export declare function oliveTree(id: () => string, foot?: {
309
+ x: number;
310
+ y: number;
311
+ }, growth?: Growth): Piece[];
312
+ /** Two cells and two triangles, loose on the sky's top-left, so there is something to glue at once. */
313
+ export declare function startingPieces(id: () => string): Piece[];
314
+ /**
315
+ * The cells each root's branches stand on, `counts[k]` of them round the end of limb k, in
316
+ * reading order: top row first, left to right, so a root's list reads as its cells do. A root
317
+ * that carries more than `held[k]` packs only that many; the rest hang below the cluster, one under
318
+ * another with sky between, outside what the limb holds up.
319
+ */
320
+ export declare function clustersOf(growth: Growth, counts: number[], foot?: {
321
+ x: number;
322
+ y: number;
323
+ }, held?: (number | undefined)[]): Hex[][];
324
+ /** A cell's six triangles in reading order: clockwise, from the one at its upper right. */
325
+ export declare function stepTris(hex: Hex): Tri[];
326
+ /** One merged face of a flat piece: every side face of one shade, or every top, of one wood. */
327
+ export interface FlatFace {
328
+ tone: number;
329
+ kind: "shade" | "shadow" | "top";
330
+ d: string;
331
+ }
332
+ /** A piece standing `lift` off the sky as merged paths, side faces first, and its glued seams. */
333
+ export declare function flatFaces(piece: Piece, lift: number): {
334
+ faces: FlatFace[];
335
+ seams: string;
336
+ };
337
+ type Pt = {
338
+ x: number;
339
+ y: number;
340
+ };
341
+ /**
342
+ * Whether a stroke goes clean through a closed outline: in at one side and out at another. A
343
+ * stroke that only grazes a corner, or stops inside, does not.
344
+ */
345
+ export declare function crossesRing(stroke: Pt[], ring: Pt[]): boolean;
346
+ /** Whether a stroke, as points on the sky, goes clean through a cell standing `lift` off it. */
347
+ export declare function crossesCell(stroke: Pt[], hex: Hex, lift?: number): boolean;
348
+ /** Whether a stroke crosses a line of points anywhere. */
349
+ export declare function crossesLine(stroke: Pt[], line: Pt[]): boolean;
350
+ /** What the face shows. */
351
+ export type Mood = "happy" | "content" | "asleep" | "sad" | "distressed" | "puzzled" | "relieved";
352
+ /** The tree's state, as the model reads it, as a face. `over` is how far past it can carry, 0–1+. */
353
+ export declare function moodOf(kind: "bare" | "planted" | "overrun" | "lofty" | "withering" | "bearing" | "steady", over?: number): Mood;
354
+ /** Where the plate stands: its middle, on a cell's centre, so its sides lie on the lattice. */
355
+ export declare function faceCentre(foot?: {
356
+ x: number;
357
+ y: number;
358
+ }): {
359
+ x: number;
360
+ y: number;
361
+ };
362
+ /** The plate's six corners, clockwise from its top. */
363
+ export declare function plateOf(foot?: {
364
+ x: number;
365
+ y: number;
366
+ }): {
367
+ x: number;
368
+ y: number;
369
+ }[];
370
+ export {};
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@harmonics/lattice-ui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.4.0",
4
+ "description": "The Harmonics tree's look as Custom Elements: a lattice face, the hexagon sky, raised lattice shapes, a shears cut gesture and two marks. Any page, any framework.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": [
8
+ "./dist/define.js"
9
+ ],
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/types/elements/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./define": {
16
+ "types": "./dist/types/elements/define.d.ts",
17
+ "default": "./dist/define.js"
18
+ },
19
+ "./hexes": {
20
+ "types": "./dist/types/elements/hexes.d.ts",
21
+ "default": "./dist/hexes.js"
22
+ },
23
+ "./react": {
24
+ "types": "./react.d.ts"
25
+ },
26
+ "./solid": {
27
+ "types": "./dist/types/elements/solid.d.ts"
28
+ },
29
+ "./package.json": "./package.json"
30
+ },
31
+ "files": [
32
+ "dist/*.js",
33
+ "dist/types",
34
+ "react.d.ts",
35
+ "README.md",
36
+ "CHANGELOG.md",
37
+ "LICENSE"
38
+ ],
39
+ "keywords": [
40
+ "custom-elements",
41
+ "web-components",
42
+ "hexagon",
43
+ "lattice",
44
+ "svg"
45
+ ],
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/Blankenship-Daniel/harmonics.git",
49
+ "directory": "packages/lattice-ui/kit"
50
+ }
51
+ }