@johnmorrisdotca/fuda-cards 0.9.2 → 0.11.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/LICENSE +21 -0
- package/NOTICE.md +14 -0
- package/README.md +466 -60
- package/dist/binder.d.ts +4 -6
- package/dist/binder.js +32 -23
- package/dist/card-markup.d.ts +2 -0
- package/dist/card-markup.js +59 -0
- package/dist/card-options.d.ts +131 -0
- package/dist/card-options.js +48 -0
- package/dist/card-styles.d.ts +2 -0
- package/dist/card-styles.js +314 -0
- package/dist/choice.d.ts +1 -1
- package/dist/choice.js +27 -23
- package/dist/collection-address.d.ts +8 -0
- package/dist/collection-address.js +52 -0
- package/dist/collection-binder-view.d.ts +9 -0
- package/dist/collection-binder-view.js +123 -0
- package/dist/collection-controls.d.ts +2 -0
- package/dist/collection-controls.js +143 -0
- package/dist/collection-deck.d.ts +11 -0
- package/dist/collection-deck.js +165 -0
- package/dist/collection-dialog.d.ts +2 -0
- package/dist/collection-dialog.js +28 -0
- package/dist/collection-element.d.ts +41 -63
- package/dist/collection-element.js +288 -472
- package/dist/collection-host.d.ts +5 -0
- package/dist/collection-host.js +1 -0
- package/dist/collection-icons.d.ts +3 -0
- package/dist/collection-icons.js +19 -0
- package/dist/collection-motion.d.ts +11 -0
- package/dist/collection-motion.js +72 -0
- package/dist/collection-styles.d.ts +4 -0
- package/dist/collection-styles.js +336 -0
- package/dist/collection-views.d.ts +8 -0
- package/dist/collection-views.js +8 -0
- package/dist/collection.d.ts +140 -11
- package/dist/collection.js +139 -33
- package/dist/element-define.d.ts +2 -0
- package/dist/element-define.js +3 -0
- package/dist/element.d.ts +20 -1
- package/dist/element.js +289 -98
- package/dist/index.d.ts +9 -52
- package/dist/index.js +5 -5
- package/dist/live-3d.d.ts +126 -0
- package/dist/live-3d.js +229 -0
- package/dist/materials.d.ts +117 -6
- package/dist/materials.js +191 -28
- package/dist/motion.d.ts +2 -0
- package/dist/motion.js +4 -0
- package/dist/pile-card.js +138 -91
- package/dist/pile.d.ts +61 -8
- package/dist/pile.js +89 -29
- package/dist/stack.d.ts +42 -6
- package/dist/stack.js +28 -3
- package/dist/version.d.ts +11 -0
- package/dist/version.js +11 -0
- package/dist/wear.d.ts +147 -9
- package/dist/wear.js +273 -89
- package/dist/zoom.d.ts +1 -1
- package/dist/zoom.js +73 -42
- package/docs/API.md +783 -0
- package/docs/collection-displays.md +1 -1
- package/docs/guides/accessibility-and-theming.md +62 -0
- package/docs/guides/architecture.md +53 -0
- package/docs/guides/binder-and-piles.md +83 -0
- package/docs/guides/bundlers.md +60 -0
- package/docs/guides/card-element.md +65 -0
- package/docs/guides/collections.md +86 -0
- package/docs/guides/embed-in-an-iframe.md +39 -0
- package/docs/guides/frameworks.md +132 -0
- package/docs/guides/getting-started.md +96 -0
- package/docs/guides/html-and-cdn.md +69 -0
- package/docs/guides/ja/accessibility-and-theming.md +62 -0
- package/docs/guides/ja/architecture.md +53 -0
- package/docs/guides/ja/binder-and-piles.md +83 -0
- package/docs/guides/ja/bundlers.md +60 -0
- package/docs/guides/ja/card-element.md +65 -0
- package/docs/guides/ja/collections.md +86 -0
- package/docs/guides/ja/embed-in-an-iframe.md +39 -0
- package/docs/guides/ja/frameworks.md +132 -0
- package/docs/guides/ja/getting-started.md +96 -0
- package/docs/guides/ja/html-and-cdn.md +69 -0
- package/docs/guides/ja/live-3d.md +75 -0
- package/docs/guides/ja/materials-and-stacks.md +73 -0
- package/docs/guides/ja/motion-and-spin.md +73 -0
- package/docs/guides/ja/troubleshooting.md +60 -0
- package/docs/guides/ja/typescript-and-node.md +45 -0
- package/docs/guides/ja/upgrading.md +56 -0
- package/docs/guides/ja/wear.md +63 -0
- package/docs/guides/live-3d.md +75 -0
- package/docs/guides/materials-and-stacks.md +73 -0
- package/docs/guides/motion-and-spin.md +73 -0
- package/docs/guides/troubleshooting.md +60 -0
- package/docs/guides/typescript-and-node.md +45 -0
- package/docs/guides/upgrading.md +56 -0
- package/docs/guides/wear.md +63 -0
- package/docs/live-3d.md +59 -0
- package/package.json +81 -11
package/docs/API.md
ADDED
|
@@ -0,0 +1,783 @@
|
|
|
1
|
+
# @johnmorrisdotca/fuda-cards API reference
|
|
2
|
+
|
|
3
|
+
Every export of @johnmorrisdotca/fuda-cards 0.11.0, one section for each entry point, written by `pnpm docs:api` from the built declarations. Do not edit it by hand: `pnpm docs:check` fails when it is out of date. The guides are in [docs/guides](guides/getting-started.md).
|
|
4
|
+
|
|
5
|
+
## `@johnmorrisdotca/fuda-cards`
|
|
6
|
+
|
|
7
|
+
17 values and 15 types.
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import { cardAttributes, cardFinishes, cardMaterial, cardMaterials, cardVariants, DEFAULT_CARD_THICKNESS_MM, mmPerPoint, stackHeightMm, stackLayout, stackPresets, VERSION, wearLayout, wearLevels, wearOutline, wearOverlaySvg, wearPreset, wearPresets } from '@johnmorrisdotca/fuda-cards';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### cardAttributes
|
|
14
|
+
|
|
15
|
+
*function*. The attributes of a `<fuda-card>` for these options, ready to set one by one (`element.setAttribute(name, value)`): names are the
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
function cardAttributes(options: CardOptions): Record<string, string>;
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### cardFinishes
|
|
22
|
+
|
|
23
|
+
*constant*. The two finishes, foil and matte.
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
const cardFinishes: readonly CardFinish[];
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### cardMaterial
|
|
30
|
+
|
|
31
|
+
*function*. The material with this id.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
function cardMaterial(id: string | null | undefined): CardMaterial | undefined;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### cardMaterials
|
|
38
|
+
|
|
39
|
+
*constant*. Every material the package knows, each with a thickness and the page it was read from. `docs/materials.md` lists them with their sources.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
const cardMaterials: readonly CardMaterial[];
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### cardVariants
|
|
46
|
+
|
|
47
|
+
*constant*. The three looks, in the order the studio offers them.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
const cardVariants: readonly CardVariant[];
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### DEFAULT_CARD_THICKNESS_MM
|
|
54
|
+
|
|
55
|
+
*constant*. The thickness of a card that names no material or thickness: a playing card's black-core stock, 13 pt, 0.325 mm
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
const DEFAULT_CARD_THICKNESS_MM = 0.325;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### mmPerPoint
|
|
62
|
+
|
|
63
|
+
*constant*. One thousandth of an inch ("pt" in card and paper trade talk) in millimetres, 0.0254: a 13 pt card is 13 × 0.0254 mm.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
const mmPerPoint = 0.0254;
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### stackHeightMm
|
|
70
|
+
|
|
71
|
+
*function*. The height of a stack of cards, in millimetres: the count times the thickness of one, to a thousandth of a millimetre.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
function stackHeightMm(count: number, thicknessMm: number): number;
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### stackLayout
|
|
78
|
+
|
|
79
|
+
*function*. Where the cards of a stack lie, from neat to messy, the same every time for the same seed: the cards under the top one, bottom first, at most
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
function stackLayout(count: number, options?: StackLayoutOptions): StackPlace[];
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### stackPresets
|
|
86
|
+
|
|
87
|
+
*constant*. The usual sizes of a stack of cards, each with where the number comes from.
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
const stackPresets: readonly StackPreset[];
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### VERSION
|
|
94
|
+
|
|
95
|
+
*constant*. The version of this package, the same as `package.json`'s (a test holds the two together).
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const VERSION = "0.11.0";
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### wearLayout
|
|
102
|
+
|
|
103
|
+
*function*. Where every mark of a card lies. A pure function of the levels and the seed: no DOM, nothing at random, so the same seed lays the same marks every time.
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
function wearLayout(levels: WearLevels, seed?: number): WearFeatures;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### wearLevels
|
|
110
|
+
|
|
111
|
+
*function*. The levels a card's wear asks for: the grade's or the number's, with any level named on its own laid over them.
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
function wearLevels(options: WearOptions): WearLevels | null;
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### wearOutline
|
|
118
|
+
|
|
119
|
+
*function*. The outline of a face as an SVG path in the 250 by 350 box, corners as worn.
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
function wearOutline(features: WearFeatures, face?: "front" | "back"): string;
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### wearOverlaySvg
|
|
126
|
+
|
|
127
|
+
*function*. The SVG laid over one face: whitening, folds, creases, scratches, specks, stain and toning. Markup only, no script.
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
function wearOverlaySvg(features: WearFeatures, face?: "front" | "back"): string;
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### wearPreset
|
|
134
|
+
|
|
135
|
+
*function*. The grade with this id.
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
function wearPreset(id: string | null | undefined): WearPreset | undefined;
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### wearPresets
|
|
142
|
+
|
|
143
|
+
*constant*. The seven grades, from perfect to damaged. The names are the plain grading terms; the numbers are this package's reading of them (docs/wear.md).
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
const wearPresets: readonly WearPreset[];
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### CardFinish
|
|
150
|
+
|
|
151
|
+
*type*. A card's finish: foil catches the light and shows a rainbow in its frame, matte does not.
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
type CardFinish = "foil" | "matte";
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### CardMaterial
|
|
158
|
+
|
|
159
|
+
*interface*. A card material: a stock or a metal with a thickness read from a maker or a standard, and the colour its edge is drawn in.
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
interface CardMaterial {
|
|
163
|
+
id: string;
|
|
164
|
+
name: string;
|
|
165
|
+
group: CardMaterialGroup;
|
|
166
|
+
/** Thickness of one card in millimetres. */
|
|
167
|
+
thicknessMm: number;
|
|
168
|
+
/** The colour of the card's edge (a look, not a measurement). */
|
|
169
|
+
edge: string;
|
|
170
|
+
source: CardMaterialSource;
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### CardMaterialGroup
|
|
175
|
+
|
|
176
|
+
*type*. The kind of stock a material is: plain paper card, plastic, a thick trading-card stock or metal.
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
type CardMaterialGroup = "paper" | "plastic" | "thick-card" | "metal";
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### CardMaterialSource
|
|
183
|
+
|
|
184
|
+
*interface*. Where a number was read: the maker's or the standard's page, and what it says there.
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
interface CardMaterialSource {
|
|
188
|
+
label: string;
|
|
189
|
+
url: string;
|
|
190
|
+
/** What the source says, in short. */
|
|
191
|
+
says: string;
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### CardOptions
|
|
196
|
+
|
|
197
|
+
*interface*. Every setting of `<fuda-card>` as an object. `cardAttributes(options)` turns it into the element's attributes, so the same object
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
interface CardOptions {
|
|
201
|
+
title?: string;
|
|
202
|
+
category?: string;
|
|
203
|
+
subtitle?: string;
|
|
204
|
+
description?: string;
|
|
205
|
+
number?: string;
|
|
206
|
+
rarity?: string;
|
|
207
|
+
variant?: CardVariant;
|
|
208
|
+
finish?: CardFinish;
|
|
209
|
+
/** Card thickness in millimetres at the 63 mm wide card size; overrides the material's. Default 0.325, 0 for a flat card. */
|
|
210
|
+
thickness?: number;
|
|
211
|
+
/** A material's id (see `cardMaterials`): its sourced thickness and edge colour. */
|
|
212
|
+
material?: string;
|
|
213
|
+
/** How many cards the stack holds (1 to 1000); the stack is that many times the card's thickness high. Default 1, one card. */
|
|
214
|
+
stack?: number;
|
|
215
|
+
/** From 0 (squared up) to 1 (very messy) for the cards under the top one. Default 0.3. */
|
|
216
|
+
stackMessiness?: number;
|
|
217
|
+
/** The stack's seed: the same seed lays the same stack the same way. Default 1. */
|
|
218
|
+
stackSeed?: number;
|
|
219
|
+
/** How many cards under the top one are laid out nudged and turned, at most 52. Default 10. */
|
|
220
|
+
stackDepth?: number;
|
|
221
|
+
/** A card that is not perfect: a preset's id (`mint`, `near-mint`, `lightly-played`, `moderately-played`, `heavily-played`, `damaged`) or a number from 0 to 1. Default: perfect, nothing drawn. */
|
|
222
|
+
wear?: string | number;
|
|
223
|
+
/** The wear's seed: the same seed draws the same marks the same way. Default 1. */
|
|
224
|
+
wearSeed?: number;
|
|
225
|
+
/** One level of the wear on its own, from 0 to 1, over the preset's. */
|
|
226
|
+
wearCorners?: number;
|
|
227
|
+
wearEdges?: number;
|
|
228
|
+
wearSurface?: number;
|
|
229
|
+
wearCreases?: number;
|
|
230
|
+
/** The card shows its back. */
|
|
231
|
+
flipped?: boolean;
|
|
232
|
+
motion?: "still" | "pan";
|
|
233
|
+
/** The picture is moving now (needs `motion: "pan"`). */
|
|
234
|
+
playing?: boolean;
|
|
235
|
+
/** `focus`: the card in focus animates its art (needs `motion: 'pan'`); never with reduced motion. */
|
|
236
|
+
autoplay?: "focus";
|
|
237
|
+
panDirection?: "down" | "up";
|
|
238
|
+
panLoop?: "alternate" | "restart";
|
|
239
|
+
cardSpin?: "center" | "corner";
|
|
240
|
+
cardSpinDirection?: "normal" | "reverse";
|
|
241
|
+
cardSpinPaused?: boolean;
|
|
242
|
+
/** The page turns the card with `--fuda-yaw` and `--fuda-tilt` instead of the built-in spin. */
|
|
243
|
+
cardView?: boolean;
|
|
244
|
+
/** `open`: a stack of more than one card fans open. */
|
|
245
|
+
fan?: "open";
|
|
246
|
+
/** How many cards are on the pile beside the stack. */
|
|
247
|
+
takenOff?: number;
|
|
248
|
+
/** How a card taken off lands: `face-up` or turned over (`face-down`). */
|
|
249
|
+
deckLand?: "face-up" | "face-down";
|
|
250
|
+
/** `off` ends every move at once. */
|
|
251
|
+
animate?: "on" | "off";
|
|
252
|
+
/** How long a move takes: `slow`, `normal` or `quick`. */
|
|
253
|
+
speed?: "slow" | "normal" | "quick";
|
|
254
|
+
/** The three buttons under a stack: Fan, Take a card off and Put it back. */
|
|
255
|
+
pileControls?: boolean;
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### CardVariant
|
|
260
|
+
|
|
261
|
+
*type*. A card's look: classic gold, silver sport or cosmic violet.
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
type CardVariant = "classic" | "sport" | "cosmic";
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### CornerKind
|
|
268
|
+
|
|
269
|
+
*type*. How a corner is worn: sharp, softened, rounded, chipped or folded.
|
|
270
|
+
|
|
271
|
+
```ts
|
|
272
|
+
type CornerKind = "sharp" | "soft" | "rounded" | "chipped" | "dog-eared";
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### StackLayoutOptions
|
|
276
|
+
|
|
277
|
+
*interface*. How a stack is laid out: how messy, from which seed and how many cards deep.
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
interface StackLayoutOptions {
|
|
281
|
+
/** From 0 (squared up) to 1 (very messy). Unless said, 0.3. */
|
|
282
|
+
messiness?: number;
|
|
283
|
+
/** The stack's own seed: the same seed lays the same stack the same way. Unless said, 1. */
|
|
284
|
+
seed?: number;
|
|
285
|
+
/** How many cards under the top one are laid out at most, so a stack of 52 costs no more than one of 11. Unless said, 10. */
|
|
286
|
+
depth?: number;
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### StackPlace
|
|
291
|
+
|
|
292
|
+
*interface*. Where one card of a stack lies, as the stack's layout says: how far it is nudged across and down, in card widths, and how far it is turned.
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
interface StackPlace {
|
|
296
|
+
/** Across, in card widths from where a square card lies. */
|
|
297
|
+
x: number;
|
|
298
|
+
/** Down, in card widths. */
|
|
299
|
+
y: number;
|
|
300
|
+
/** Turn in degrees. */
|
|
301
|
+
rotate: number;
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### StackPreset
|
|
306
|
+
|
|
307
|
+
*interface*. A count of cards for a stack, with where the number comes from: a deck of 52, a Pokémon deck of 60, a booster pack of about 10.
|
|
308
|
+
|
|
309
|
+
```ts
|
|
310
|
+
interface StackPreset {
|
|
311
|
+
id: string;
|
|
312
|
+
name: string;
|
|
313
|
+
count: number;
|
|
314
|
+
source: CardMaterialSource;
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### WearCorner
|
|
319
|
+
|
|
320
|
+
*interface*. One corner of a worn card: how it is worn and how far the damage reaches.
|
|
321
|
+
|
|
322
|
+
```ts
|
|
323
|
+
interface WearCorner {
|
|
324
|
+
kind: CornerKind;
|
|
325
|
+
/** How far the damage reaches along each edge, in units of a 250 by 350 card. */
|
|
326
|
+
size: number;
|
|
327
|
+
/** Jagged points of a chip, in the corner's own frame. */
|
|
328
|
+
jag: number[];
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### WearFeatures
|
|
333
|
+
|
|
334
|
+
*interface*. Every mark of a worn card: its corners, its centring, and the creases, scratches, specks and stain of each face.
|
|
335
|
+
|
|
336
|
+
```ts
|
|
337
|
+
interface WearFeatures {
|
|
338
|
+
levels: WearLevels;
|
|
339
|
+
/** Top left, top right, bottom right, bottom left of the front. */
|
|
340
|
+
corners: WearCorner[];
|
|
341
|
+
/** The print's shift off centre in pixels at 300 wide: x and y. */
|
|
342
|
+
centering: {
|
|
343
|
+
x: number;
|
|
344
|
+
y: number;
|
|
345
|
+
};
|
|
346
|
+
front: WearFace;
|
|
347
|
+
back: WearFace;
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### WearLevels
|
|
352
|
+
|
|
353
|
+
*interface*. How much of each kind of wear, from 0 (none) to 1 (the worst the preset names).
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
interface WearLevels {
|
|
357
|
+
corners: number;
|
|
358
|
+
edges: number;
|
|
359
|
+
surface: number;
|
|
360
|
+
creases: number;
|
|
361
|
+
/** Yellowing and darkened borders with age. */
|
|
362
|
+
toning: number;
|
|
363
|
+
/** How far the print sits off centre. */
|
|
364
|
+
centering: number;
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### WearOptions
|
|
369
|
+
|
|
370
|
+
*interface*. What a card asks of its wear: a grade or a number, a seed, and any level on its own.
|
|
371
|
+
|
|
372
|
+
```ts
|
|
373
|
+
interface WearOptions {
|
|
374
|
+
/** A preset's id, or a number from 0 to 1 for all the levels at once. */
|
|
375
|
+
wear?: string | number | null;
|
|
376
|
+
/** The seed: the same seed lays the same marks the same way. Unless said, 1. */
|
|
377
|
+
seed?: number;
|
|
378
|
+
/** Overrides of one level each, from 0 to 1. */
|
|
379
|
+
corners?: number;
|
|
380
|
+
edges?: number;
|
|
381
|
+
surface?: number;
|
|
382
|
+
creases?: number;
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### WearPreset
|
|
387
|
+
|
|
388
|
+
*interface*. A grading term with the levels it stands for and what it means in a few words.
|
|
389
|
+
|
|
390
|
+
```ts
|
|
391
|
+
interface WearPreset {
|
|
392
|
+
id: string;
|
|
393
|
+
name: string;
|
|
394
|
+
levels: WearLevels;
|
|
395
|
+
/** What the condition term means in grading language, in a few words. */
|
|
396
|
+
says: string;
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
## `@johnmorrisdotca/fuda-cards/element`
|
|
401
|
+
|
|
402
|
+
1 value and 0 types.
|
|
403
|
+
|
|
404
|
+
```js
|
|
405
|
+
import { FudaCard } from '@johnmorrisdotca/fuda-cards/element';
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### FudaCard
|
|
409
|
+
|
|
410
|
+
*class*. `<fuda-card>`: a collectible card frame around a picture you give it (or a live 3D view), drawn with a true thickness, an edge, a back, foil or matte,
|
|
411
|
+
|
|
412
|
+
```ts
|
|
413
|
+
class FudaCard extends HTMLElement {
|
|
414
|
+
static observedAttributes: string[];
|
|
415
|
+
private focused;
|
|
416
|
+
private hushed;
|
|
417
|
+
private focusedAtPress?;
|
|
418
|
+
constructor();
|
|
419
|
+
/** The light follows the pointer over the card: a foil card shows its sheen where the pointer is (see `--fuda-sheen-x` and `--fuda-sheen-y`). */
|
|
420
|
+
private watchLight;
|
|
421
|
+
/** With `autoplay="focus"` the card in focus animates its art; leaving it (pointer, keyboard or a tap elsewhere) stops it. */
|
|
422
|
+
private watchFocus;
|
|
423
|
+
/** Put this card in focus (or out of it); the card that had focus is put out, so only one is ever in focus. */
|
|
424
|
+
setFocused(on: boolean): void;
|
|
425
|
+
/** True while the art moves: `playing` is set, or the card is in focus with `autoplay="focus"` and the person has not paused it. Never autoplays with reduced motion. */
|
|
426
|
+
get isMoving(): boolean;
|
|
427
|
+
private toggleMotion;
|
|
428
|
+
/** The art stays invisible until the card has a size on screen and every slotted image has loaded, so it never shows outside the frame. */
|
|
429
|
+
private watchArt;
|
|
430
|
+
/** The front is hidden while `--fuda-yaw` has turned the back toward the reader. */
|
|
431
|
+
private watchFacing;
|
|
432
|
+
connectedCallback(): void;
|
|
433
|
+
disconnectedCallback(): void;
|
|
434
|
+
attributeChangedCallback(name: string): void;
|
|
435
|
+
/** Millimetres thick: the `thickness` attribute, else the `material`'s, else the playing-card stock's 0.325 (`DEFAULT_CARD_THICKNESS_MM`). */
|
|
436
|
+
get cardThicknessMm(): number;
|
|
437
|
+
/** How many cards the stack holds: the `stack` attribute as a whole number from 1 (one card) to 1000. */
|
|
438
|
+
get stackCount(): number;
|
|
439
|
+
/** Height of the stack in millimetres: the count times a card's thickness. */
|
|
440
|
+
get stackHeight(): number;
|
|
441
|
+
/** How many cards are still in the stack: `stack` less the `taken-off` ones (at least one stays). */
|
|
442
|
+
get heldCount(): number;
|
|
443
|
+
/** True while the stack is fanned open (`fan="open"`, with more than one card). */
|
|
444
|
+
get fanOpen(): boolean;
|
|
445
|
+
/** How far the pile reaches beyond the card's own box, in card widths: an open fan and the pile of cards taken off. It is zero until a pile feature is used. Pages use it to fit the view; `fuda-pile` is sent when it changes. */
|
|
446
|
+
pileBounds: {
|
|
447
|
+
left: number;
|
|
448
|
+
right: number;
|
|
449
|
+
top: number;
|
|
450
|
+
bottom: number;
|
|
451
|
+
};
|
|
452
|
+
/** Take the top card (or `count` cards) off the stack: it flies to a pile at the stack's side and lands as `deck-land` says. At least one card stays. */
|
|
453
|
+
takeOff(count?: number): void;
|
|
454
|
+
/** Bring the card (or `count` cards) back from the pile onto the stack. */
|
|
455
|
+
putBack(count?: number): void;
|
|
456
|
+
pileUsed: boolean;
|
|
457
|
+
private pileModule?;
|
|
458
|
+
/** Fanning, the pile of cards taken off and the controls are drawn by a module that is loaded only when a stack asks for them; a card without them never loads it. */
|
|
459
|
+
private applyPile;
|
|
460
|
+
private wearKey;
|
|
461
|
+
private wearToken;
|
|
462
|
+
private wearModule?;
|
|
463
|
+
/** Wear (an imperfect card) is drawn by a module that is loaded only when a card asks for it; a perfect card never loads it. */
|
|
464
|
+
private applyWear;
|
|
465
|
+
/** The wear the card is drawn with: a preset's id, a number, or an empty string when it is perfect. */
|
|
466
|
+
get wear(): string;
|
|
467
|
+
set wear(value: string);
|
|
468
|
+
private stillsKey;
|
|
469
|
+
/** The cards under the top one that are laid out nudged and turned; the rest of the stack is one block with a line for each card on its edge. */
|
|
470
|
+
private drawStills;
|
|
471
|
+
render(): void;
|
|
472
|
+
}
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
## `@johnmorrisdotca/fuda-cards/element/define`
|
|
476
|
+
|
|
477
|
+
0 values and 0 types.
|
|
478
|
+
|
|
479
|
+
```js
|
|
480
|
+
import { /* types only */ } from '@johnmorrisdotca/fuda-cards/element/define';
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
## `@johnmorrisdotca/fuda-cards/live-3d`
|
|
484
|
+
|
|
485
|
+
1 value and 5 types.
|
|
486
|
+
|
|
487
|
+
```js
|
|
488
|
+
import { createLiveCards } from '@johnmorrisdotca/fuda-cards/live-3d';
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
### createLiveCards
|
|
492
|
+
|
|
493
|
+
*function*. Make the live cards of a page. Nothing 3D is loaded until a card is first in focus (or a card with no picture of its own comes near the view and needs its still made).
|
|
494
|
+
|
|
495
|
+
```ts
|
|
496
|
+
function createLiveCards<T extends ThreeLike = ThreeLike>(options: LiveCardsOptions<T>): LiveCards<T>;
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
### AddOptions
|
|
500
|
+
|
|
501
|
+
*interface*. What a card brings when it is added: the picture it already has.
|
|
502
|
+
|
|
503
|
+
```ts
|
|
504
|
+
interface AddOptions {
|
|
505
|
+
/** A picture the card already has (an `<img>` of its own), kept until the card is in focus. With one, the card costs no 3D code until then. */
|
|
506
|
+
still?: HTMLImageElement;
|
|
507
|
+
}
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
### LiveCards
|
|
511
|
+
|
|
512
|
+
*interface*. The live cards of a page: add a card, put one in focus, let go. Only the card in focus turns in 3D, on the page's one WebGL context; the others stay pictures.
|
|
513
|
+
|
|
514
|
+
```ts
|
|
515
|
+
interface LiveCards<T extends ThreeLike = ThreeLike> {
|
|
516
|
+
/** Make a card live on focus: a `<fuda-card>` or any element with a size. Gives back the function that takes it off again. */
|
|
517
|
+
add(card: HTMLElement, item: LiveItem<T>, options?: AddOptions): () => void;
|
|
518
|
+
/** Put this card in focus: it takes the context, and the card that had it freezes to a picture at its last angle. False if it did not go live (another took it, reduced motion, no WebGL). */
|
|
519
|
+
focus(card: HTMLElement): Promise<boolean>;
|
|
520
|
+
/** No card in focus: the live one freezes to a picture and nothing draws. */
|
|
521
|
+
blur(): void;
|
|
522
|
+
/** The card in focus, if any. */
|
|
523
|
+
readonly focused: HTMLElement | undefined;
|
|
524
|
+
/** The shared renderer's own figures; undefined until it has been needed. */
|
|
525
|
+
readonly stats: RendererStats | undefined;
|
|
526
|
+
/** The shared renderer; undefined until it has been needed. */
|
|
527
|
+
readonly renderer: SharedRenderer<T> | undefined;
|
|
528
|
+
/** Take every card off and let go of the renderer. */
|
|
529
|
+
dispose(): void;
|
|
530
|
+
}
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
### LiveCardsOptions
|
|
534
|
+
|
|
535
|
+
*interface*. How the live cards behave: the shared renderer's options (kazoku-ui's), and how long a turn takes, how long the pointer rests before a card goes live and how far ahead a still is made.
|
|
536
|
+
|
|
537
|
+
```ts
|
|
538
|
+
interface LiveCardsOptions<T extends ThreeLike = ThreeLike> extends Omit<SharedRendererOptions<T>, "scheduler" | "assets" | "clock" | "document"> {
|
|
539
|
+
/** Seconds for one turn of the card in focus (12). 0 does not turn it. */
|
|
540
|
+
turnSeconds?: number;
|
|
541
|
+
/** How long the pointer has to rest on a card before it goes live, in milliseconds (150), so moving the pointer across a page of cards starts nothing. A press or the keyboard does not wait. */
|
|
542
|
+
dwellMs?: number;
|
|
543
|
+
/** How far outside the view a card with no picture of its own gets its still made, in pixels (300). */
|
|
544
|
+
lookAheadPx?: number;
|
|
545
|
+
}
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
### LiveItem
|
|
549
|
+
|
|
550
|
+
*interface*. What a card shows in 3D: a key (items with the same key share their pictures) and a scene made from shared assets (`assets.acquire`).
|
|
551
|
+
|
|
552
|
+
```ts
|
|
553
|
+
interface LiveItem<T extends ThreeLike = ThreeLike> {
|
|
554
|
+
key: string;
|
|
555
|
+
build(context: BuildContext<T>): LiveScene | Promise<LiveScene>;
|
|
556
|
+
}
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
### LiveScene
|
|
560
|
+
|
|
561
|
+
*interface*. A scene for a card: kazoku-ui's scene, with `object`, the thing that turns about its upright axis while the card is in focus.
|
|
562
|
+
|
|
563
|
+
```ts
|
|
564
|
+
interface LiveScene extends Scene3D {
|
|
565
|
+
object?: {
|
|
566
|
+
rotation: {
|
|
567
|
+
y: number;
|
|
568
|
+
};
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
## `@johnmorrisdotca/fuda-cards/collection`
|
|
574
|
+
|
|
575
|
+
10 values and 6 types.
|
|
576
|
+
|
|
577
|
+
```js
|
|
578
|
+
import { collectionKinds, collectionViewAliases, collectionViews, deckLandings, fanLayout, isCard, movePage, normalizeLanding, parseCollection, randomDrawIndex } from '@johnmorrisdotca/fuda-cards/collection';
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
### collectionKinds
|
|
582
|
+
|
|
583
|
+
*constant*. The two kinds of item, `card` and `object`.
|
|
584
|
+
|
|
585
|
+
```ts
|
|
586
|
+
const collectionKinds: ReadonlyArray<CollectionKind>;
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
### collectionViewAliases
|
|
590
|
+
|
|
591
|
+
*constant*. Display names that earlier versions accepted and that now open another display, so a page that sets them keeps working.
|
|
592
|
+
|
|
593
|
+
```ts
|
|
594
|
+
const collectionViewAliases: Readonly<Record<string, CollectionView>>;
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
### collectionViews
|
|
598
|
+
|
|
599
|
+
*constant*. The ten displays, in the order the buttons show them, each with the label on its button. `jukebox` and `tower` were two more names for the deck's pile of cards (no real counterpart for cards, and the same drawing), so they are no longer offered; see {@link collectionViewAliases}.
|
|
600
|
+
|
|
601
|
+
```ts
|
|
602
|
+
const collectionViews: ReadonlyArray<{
|
|
603
|
+
id: CollectionView;
|
|
604
|
+
label: string;
|
|
605
|
+
}>;
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
### deckLandings
|
|
609
|
+
|
|
610
|
+
*constant*. The two ways a card can land, with the label on each button: `face-up` (still facing up) and `face-down` (turned over sideways on the way).
|
|
611
|
+
|
|
612
|
+
```ts
|
|
613
|
+
const deckLandings: ReadonlyArray<{
|
|
614
|
+
id: "face-up" | "face-down";
|
|
615
|
+
label: string;
|
|
616
|
+
}>;
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
### fanLayout
|
|
620
|
+
|
|
621
|
+
*function*. Where the cards of a fan lie: each card turns eleven degrees more than the one before, up to 110 degrees from the first to the last, centred on the pile.
|
|
622
|
+
|
|
623
|
+
```ts
|
|
624
|
+
function fanLayout(count: number, seed?: number, step?: number): FanPlace[];
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
### isCard
|
|
628
|
+
|
|
629
|
+
*constant*. Whether an item is a card: anything that does not say it is an object. Only a card turns, has a back and lands turned over.
|
|
630
|
+
|
|
631
|
+
```ts
|
|
632
|
+
const isCard: (card: Pick<CollectionCard, "kind">) => boolean;
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
### movePage
|
|
636
|
+
|
|
637
|
+
*function*. The first card of the page that is `delta` pages away, wrapping round at either end.
|
|
638
|
+
|
|
639
|
+
```ts
|
|
640
|
+
function movePage(index: number, length: number, pageSize: number, delta: number): number;
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
### normalizeLanding
|
|
644
|
+
|
|
645
|
+
*function*. The landing a value means: `face-down` (also `upside-down` and `turned-over`) is turned over; anything else is still facing up.
|
|
646
|
+
|
|
647
|
+
```ts
|
|
648
|
+
function normalizeLanding(value: string | null | undefined): "face-up" | "face-down";
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
### parseCollection
|
|
652
|
+
|
|
653
|
+
*function*. Check a collection and make it the shape the element draws: an array of cards, or an object with a `cards` array. A card without an id is numbered by its place.
|
|
654
|
+
|
|
655
|
+
```ts
|
|
656
|
+
function parseCollection(input: unknown): CollectionCard[];
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
### randomDrawIndex
|
|
660
|
+
|
|
661
|
+
*function*. Choose a card whose name contains the filter, avoiding the current card when another match exists.
|
|
662
|
+
|
|
663
|
+
```ts
|
|
664
|
+
function randomDrawIndex(cards: CollectionCard[], current: number, filter: string, random?: () => number): number | null;
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
### CollectionCard
|
|
668
|
+
|
|
669
|
+
*interface*. One item of a collection: an id, a name, the front's picture, optionally the back's, its kind and its metadata.
|
|
670
|
+
|
|
671
|
+
```ts
|
|
672
|
+
interface CollectionCard {
|
|
673
|
+
id: string;
|
|
674
|
+
name: string;
|
|
675
|
+
image: string;
|
|
676
|
+
backImage?: string;
|
|
677
|
+
kind?: CollectionKind;
|
|
678
|
+
metadata?: CollectionMetadata;
|
|
679
|
+
}
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
### CollectionKind
|
|
683
|
+
|
|
684
|
+
*type*. What an item is. A `card` (the default, so every collection written before this field existed is still cards) is a flat, thin card with a back: it
|
|
685
|
+
|
|
686
|
+
```ts
|
|
687
|
+
type CollectionKind = "card" | "object";
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
### CollectionMetadata
|
|
691
|
+
|
|
692
|
+
*interface*. What a collector writes about a card: its set, year, number, edition, condition, grade, quantity and notes. All optional; `year` and `quantity` are whole numbers.
|
|
693
|
+
|
|
694
|
+
```ts
|
|
695
|
+
interface CollectionMetadata {
|
|
696
|
+
set?: string;
|
|
697
|
+
year?: number;
|
|
698
|
+
number?: string;
|
|
699
|
+
edition?: string;
|
|
700
|
+
condition?: string;
|
|
701
|
+
grade?: string;
|
|
702
|
+
quantity?: number;
|
|
703
|
+
notes?: string;
|
|
704
|
+
}
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
### CollectionView
|
|
708
|
+
|
|
709
|
+
*type*. The name of a display of `<fuda-collection>`: the `view` attribute's values. `jukebox` and `tower` are older names that open the deck (see
|
|
710
|
+
|
|
711
|
+
```ts
|
|
712
|
+
type CollectionView = "deck" | "rolodex" | "binder" | "case" | "jukebox" | "random" | "story" | "wall" | "tower" | "spotlight" | "atlas" | "fan";
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
### DeckLanding
|
|
716
|
+
|
|
717
|
+
*type*. How a card taken off a pile lands on the pile at its side: still facing up, or turned over sideways (as a person turns a card, like a
|
|
718
|
+
|
|
719
|
+
```ts
|
|
720
|
+
type DeckLanding = "face-up" | "face-down" | "upside-down";
|
|
721
|
+
```
|
|
722
|
+
|
|
723
|
+
### FanPlace
|
|
724
|
+
|
|
725
|
+
*interface*. Where one card of a fan lies, first card on the left when open and on top when closed. `angle`, `x` and `y` are the open fan, spread like a hand
|
|
726
|
+
|
|
727
|
+
```ts
|
|
728
|
+
interface FanPlace {
|
|
729
|
+
angle: number;
|
|
730
|
+
x: number;
|
|
731
|
+
y: number;
|
|
732
|
+
closedAngle: number;
|
|
733
|
+
closedX: number;
|
|
734
|
+
closedY: number;
|
|
735
|
+
}
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
## `@johnmorrisdotca/fuda-cards/collection-element`
|
|
739
|
+
|
|
740
|
+
1 value and 1 type.
|
|
741
|
+
|
|
742
|
+
```js
|
|
743
|
+
import { FudaCollection } from '@johnmorrisdotca/fuda-cards/collection-element';
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
### FudaCollection
|
|
747
|
+
|
|
748
|
+
*class*. `<fuda-collection>`: a whole collection in one of ten displays (a deck, a rolodex, binder pages, a display case, a random draw, a story scroll, a gallery wall,
|
|
749
|
+
|
|
750
|
+
```ts
|
|
751
|
+
class FudaCollection extends HTMLElement {
|
|
752
|
+
private liveSetup;
|
|
753
|
+
private liveOff;
|
|
754
|
+
static get observedAttributes(): string[];
|
|
755
|
+
set cards(value: CollectionCard[]);
|
|
756
|
+
get cards(): CollectionCard[];
|
|
757
|
+
/** Live 3D: the card in focus turns in 3D on the page's one WebGL context, and every other card stays its picture. Nothing 3D loads until a card is focused. */
|
|
758
|
+
set live(value: CollectionLive | null);
|
|
759
|
+
get live(): CollectionLive | null;
|
|
760
|
+
/** The cards are drawn again on every move, so their live views are made again too: the pictures stay in the shared cache. */
|
|
761
|
+
private attachLive;
|
|
762
|
+
/** The card on top of the deck, or the first card of the page or fan (counting from 0). */
|
|
763
|
+
get position(): number;
|
|
764
|
+
connectedCallback(): void;
|
|
765
|
+
disconnectedCallback(): void;
|
|
766
|
+
attributeChangedCallback(name: string): void;
|
|
767
|
+
/** The first card of an opening of the binder: the right-hand page's first card, or the left-hand page's when the right-hand page is past the end. */
|
|
768
|
+
private spreadFirst;
|
|
769
|
+
/** `fan` changed: when a pile is on screen, move its cards to or from the fan in place (animated) and fit the view to it. Returns false when there is no pile to move. */
|
|
770
|
+
private setFan;
|
|
771
|
+
}
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
### CollectionLive
|
|
775
|
+
|
|
776
|
+
*interface*. Live 3D in a collection's cards: the shared cards from `createLiveCards` and the 3D item of a card, if it has one. See docs/live-3d.md.
|
|
777
|
+
|
|
778
|
+
```ts
|
|
779
|
+
interface CollectionLive {
|
|
780
|
+
cards: LiveCards<never>;
|
|
781
|
+
item(card: CollectionCard): LiveItem<never> | undefined;
|
|
782
|
+
}
|
|
783
|
+
```
|