@johnmorrisdotca/fuda-cards 0.4.0 → 0.6.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/README.md +25 -7
- package/dist/choice.d.ts +38 -0
- package/dist/choice.js +77 -0
- package/dist/collection-element.d.ts +19 -0
- package/dist/collection-element.js +225 -23
- package/dist/collection.d.ts +17 -1
- package/dist/collection.js +23 -1
- package/dist/element.d.ts +8 -0
- package/dist/element.js +27 -2
- package/dist/index.d.ts +11 -0
- package/dist/index.js +1 -0
- package/dist/stack.d.ts +2 -0
- package/dist/stack.js +1 -1
- package/dist/wear.d.ts +104 -0
- package/dist/wear.js +268 -0
- package/dist/zoom.d.ts +7 -0
- package/dist/zoom.js +16 -4
- package/docs/collection-displays.md +8 -1
- package/docs/wear.md +66 -0
- package/package.json +2 -1
package/dist/collection.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { stackLayout } from './stack.js';
|
|
1
2
|
export const collectionViews = [
|
|
2
3
|
{ id: 'deck', label: 'Overlapping Deck' }, { id: 'rolodex', label: 'Rolodex' }, { id: 'binder', label: 'Binder Pages' },
|
|
3
4
|
{ id: 'case', label: 'Convention Display Case' }, { id: 'jukebox', label: 'Jukebox Carousel' }, { id: 'random', label: 'Random Draw' },
|
|
4
5
|
{ id: 'story', label: 'Vertical Story Scroll' }, { id: 'wall', label: 'Sliding Gallery Wall' }, { id: 'tower', label: 'Flip Tower' },
|
|
5
|
-
{ id: 'spotlight', label: 'Spotlight Carousel' }, { id: 'atlas', label: 'Infinite Card Atlas' }
|
|
6
|
+
{ id: 'spotlight', label: 'Spotlight Carousel' }, { id: 'atlas', label: 'Infinite Card Atlas' }, { id: 'fan', label: 'Fan of Cards' }
|
|
6
7
|
];
|
|
7
8
|
export function parseCollection(value) {
|
|
8
9
|
if (value && typeof value === 'object' && !Array.isArray(value) && 'cards' in value)
|
|
@@ -62,3 +63,24 @@ export function movePage(index, length, pageSize, delta) {
|
|
|
62
63
|
const page = Math.floor(index / pageSize);
|
|
63
64
|
return (((page + delta) % pages + pages) % pages) * pageSize;
|
|
64
65
|
}
|
|
66
|
+
export const deckLandings = [
|
|
67
|
+
{ id: 'face-up', label: 'Still facing up' }, { id: 'upside-down', label: 'Upside down' }, { id: 'face-down', label: 'Face down' }
|
|
68
|
+
];
|
|
69
|
+
export function fanLayout(count, seed = 1) {
|
|
70
|
+
const n = Math.max(0, Math.floor(count));
|
|
71
|
+
if (!n)
|
|
72
|
+
return [];
|
|
73
|
+
const spread = Math.min(110, 11 * (n - 1)), step = n > 1 ? spread / (n - 1) : 0;
|
|
74
|
+
const nudge = stackLayout(n, { messiness: 0.25, seed, depth: n });
|
|
75
|
+
return Array.from({ length: n }, (_, i) => {
|
|
76
|
+
const under = i >= 1 ? nudge[i - 1] : undefined;
|
|
77
|
+
return {
|
|
78
|
+
angle: Math.round((-spread / 2 + i * step) * 100) / 100,
|
|
79
|
+
x: Math.round((i - (n - 1) / 2) * 0.34 * 1000) / 1000,
|
|
80
|
+
y: 0,
|
|
81
|
+
closedAngle: under ? under.rotate / 3 : 0,
|
|
82
|
+
closedX: under ? under.x : 0,
|
|
83
|
+
closedY: under ? under.y : 0
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}
|
package/dist/element.d.ts
CHANGED
|
@@ -22,6 +22,14 @@ export declare class FudaCard extends HTMLElement {
|
|
|
22
22
|
get stackCount(): number;
|
|
23
23
|
/** Height of the stack in millimetres: the count times a card's thickness. */
|
|
24
24
|
get stackHeight(): number;
|
|
25
|
+
private wearKey;
|
|
26
|
+
private wearToken;
|
|
27
|
+
private wearModule?;
|
|
28
|
+
/** 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. */
|
|
29
|
+
private applyWear;
|
|
30
|
+
/** The wear the card is drawn with: a preset's id, a number, or an empty string when it is perfect. */
|
|
31
|
+
get wear(): string;
|
|
32
|
+
set wear(value: string);
|
|
25
33
|
private stillsKey;
|
|
26
34
|
/** 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. */
|
|
27
35
|
private drawStills;
|
package/dist/element.js
CHANGED
|
@@ -11,7 +11,7 @@ const reducedMotion = () => typeof matchMedia === 'function' && matchMedia('(pre
|
|
|
11
11
|
document.addEventListener('pointerdown', event => { if (focusedCard && !event.composedPath().includes(focusedCard))
|
|
12
12
|
focusedCard.setFocused(false); }, true);
|
|
13
13
|
export class FudaCard extends HTMLElement {
|
|
14
|
-
static observedAttributes = ['title', 'category', 'subtitle', 'description', 'number', 'rarity', 'motion', 'playing', 'thickness', 'autoplay', 'material', 'stack', 'stack-messiness', 'stack-seed', 'stack-depth'];
|
|
14
|
+
static observedAttributes = ['title', 'category', 'subtitle', 'description', 'number', 'rarity', 'motion', 'playing', 'thickness', 'autoplay', 'material', 'stack', 'stack-messiness', 'stack-seed', 'stack-depth', 'wear', 'wear-seed', 'wear-corners', 'wear-edges', 'wear-surface', 'wear-creases'];
|
|
15
15
|
focused = false;
|
|
16
16
|
hushed = false;
|
|
17
17
|
focusedAtPress;
|
|
@@ -97,6 +97,31 @@ export class FudaCard extends HTMLElement {
|
|
|
97
97
|
get stackCount() { const n = Math.floor(Number.parseFloat(this.getAttribute('stack') ?? '')); return n >= 1 ? Math.min(1000, n) : 1; }
|
|
98
98
|
/** Height of the stack in millimetres: the count times a card's thickness. */
|
|
99
99
|
get stackHeight() { return stackHeightMm(this.stackCount, this.cardThicknessMm); }
|
|
100
|
+
wearKey = '';
|
|
101
|
+
wearToken = 0;
|
|
102
|
+
wearModule;
|
|
103
|
+
/** 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. */
|
|
104
|
+
applyWear() {
|
|
105
|
+
const num = (name) => { const v = this.getAttribute(name); return v === null || v.trim() === '' ? undefined : Number(v); };
|
|
106
|
+
const key = ['wear', 'wear-seed', 'wear-corners', 'wear-edges', 'wear-surface', 'wear-creases'].map(n => this.getAttribute(n) ?? '').join('|');
|
|
107
|
+
const w = this.getAttribute('wear') ?? '', asked = (w !== '' && w !== 'perfect' && w !== '0') || ['wear-corners', 'wear-edges', 'wear-surface', 'wear-creases'].some(n => this.hasAttribute(n));
|
|
108
|
+
if (key === this.wearKey || (!asked && !this.wearModule))
|
|
109
|
+
return;
|
|
110
|
+
this.wearKey = key;
|
|
111
|
+
const token = ++this.wearToken;
|
|
112
|
+
const draw = (m) => { if (token !== this.wearToken || !this.shadowRoot)
|
|
113
|
+
return; this.wearModule = m; m.applyWear(this.shadowRoot, { wear: this.getAttribute('wear'), seed: num('wear-seed'), corners: num('wear-corners'), edges: num('wear-edges'), surface: num('wear-surface'), creases: num('wear-creases') }); this.dispatchEvent(new CustomEvent('fuda-wear', { detail: { key } })); };
|
|
114
|
+
if (this.wearModule)
|
|
115
|
+
draw(this.wearModule);
|
|
116
|
+
else
|
|
117
|
+
void import('./wear.js').then(draw);
|
|
118
|
+
}
|
|
119
|
+
/** The wear the card is drawn with: a preset's id, a number, or an empty string when it is perfect. */
|
|
120
|
+
get wear() { return this.getAttribute('wear') ?? ''; }
|
|
121
|
+
set wear(value) { if (value)
|
|
122
|
+
this.setAttribute('wear', value);
|
|
123
|
+
else
|
|
124
|
+
this.removeAttribute('wear'); }
|
|
100
125
|
stillsKey = '';
|
|
101
126
|
/** 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. */
|
|
102
127
|
drawStills(card, count) {
|
|
@@ -121,7 +146,7 @@ export class FudaCard extends HTMLElement {
|
|
|
121
146
|
else
|
|
122
147
|
card.style.removeProperty('--edge');
|
|
123
148
|
this.drawStills(card, count);
|
|
124
|
-
} const button = this.shadowRoot?.querySelector('.motion-button'); if (button) {
|
|
149
|
+
} this.applyWear(); const button = this.shadowRoot?.querySelector('.motion-button'); if (button) {
|
|
125
150
|
button.hidden = this.getAttribute('motion') !== 'pan';
|
|
126
151
|
const active = this.isMoving;
|
|
127
152
|
this.toggleAttribute('moving', active);
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,15 @@ export interface CardOptions {
|
|
|
22
22
|
stackSeed?: number;
|
|
23
23
|
/** How many cards under the top one are laid out nudged and turned, at most 52. Default 10. */
|
|
24
24
|
stackDepth?: number;
|
|
25
|
+
/** 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. */
|
|
26
|
+
wear?: string | number;
|
|
27
|
+
/** The wear's seed: the same seed draws the same marks the same way. Default 1. */
|
|
28
|
+
wearSeed?: number;
|
|
29
|
+
/** One level of the wear on its own, from 0 to 1, over the preset's. */
|
|
30
|
+
wearCorners?: number;
|
|
31
|
+
wearEdges?: number;
|
|
32
|
+
wearSurface?: number;
|
|
33
|
+
wearCreases?: number;
|
|
25
34
|
flipped?: boolean;
|
|
26
35
|
motion?: 'still' | 'pan';
|
|
27
36
|
playing?: boolean;
|
|
@@ -39,3 +48,5 @@ export { cardMaterials, cardMaterial, stackPresets, stackHeightMm, mmPerPoint }
|
|
|
39
48
|
export type { CardMaterial, CardMaterialGroup, CardMaterialSource, StackPreset } from './materials.js';
|
|
40
49
|
export { stackLayout } from './stack.js';
|
|
41
50
|
export type { StackPlace, StackLayoutOptions } from './stack.js';
|
|
51
|
+
export { wearPresets, wearPreset, wearLevels, wearLayout, wearOutline, wearOverlaySvg } from './wear.js';
|
|
52
|
+
export type { WearPreset, WearLevels, WearOptions, WearFeatures, WearCorner, CornerKind } from './wear.js';
|
package/dist/index.js
CHANGED
|
@@ -2,3 +2,4 @@ export const cardVariants = ['classic', 'sport', 'cosmic'];
|
|
|
2
2
|
export const cardFinishes = ['foil', 'matte'];
|
|
3
3
|
export { cardMaterials, cardMaterial, stackPresets, stackHeightMm, mmPerPoint } from './materials.js';
|
|
4
4
|
export { stackLayout } from './stack.js';
|
|
5
|
+
export { wearPresets, wearPreset, wearLevels, wearLayout, wearOutline, wearOverlaySvg } from './wear.js';
|
package/dist/stack.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface StackLayoutOptions {
|
|
|
21
21
|
/** 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. */
|
|
22
22
|
depth?: number;
|
|
23
23
|
}
|
|
24
|
+
/** A stream of numbers in [0, 1) fixed by a seed (mulberry32). */
|
|
25
|
+
export declare function seededRandom(seed: number): () => number;
|
|
24
26
|
/**
|
|
25
27
|
* The cards under the top one of a stack of `count`, bottom first: the top `depth` of them, as the top card is the live one
|
|
26
28
|
* and lies square. A card's place depends on its number from the bottom, so a card put on top moves none of those under it.
|
package/dist/stack.js
CHANGED
package/dist/wear.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/** How much of each kind of wear, from 0 (none) to 1 (the worst the preset names). */
|
|
2
|
+
export interface WearLevels {
|
|
3
|
+
corners: number;
|
|
4
|
+
edges: number;
|
|
5
|
+
surface: number;
|
|
6
|
+
creases: number;
|
|
7
|
+
/** Yellowing and darkened borders with age. */
|
|
8
|
+
toning: number;
|
|
9
|
+
/** How far the print sits off centre. */
|
|
10
|
+
centering: number;
|
|
11
|
+
}
|
|
12
|
+
export interface WearPreset {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
levels: WearLevels;
|
|
16
|
+
/** What the condition term means in grading language, in a few words. */
|
|
17
|
+
says: string;
|
|
18
|
+
}
|
|
19
|
+
/** From perfect to damaged. The names are the plain grading terms; the numbers are this package's reading of them (docs/wear.md). */
|
|
20
|
+
export declare const wearPresets: readonly WearPreset[];
|
|
21
|
+
export declare function wearPreset(id: string | null | undefined): WearPreset | undefined;
|
|
22
|
+
export interface WearOptions {
|
|
23
|
+
/** A preset's id, or a number from 0 to 1 for all the levels at once. */
|
|
24
|
+
wear?: string | number | null;
|
|
25
|
+
/** The seed: the same seed lays the same marks the same way. Unless said, 1. */
|
|
26
|
+
seed?: number;
|
|
27
|
+
/** Overrides of one level each, from 0 to 1. */
|
|
28
|
+
corners?: number;
|
|
29
|
+
edges?: number;
|
|
30
|
+
surface?: number;
|
|
31
|
+
creases?: number;
|
|
32
|
+
}
|
|
33
|
+
/** The levels a card's wear asks for, or null when it asks for none (no wear, "perfect", an unknown name or all zero). */
|
|
34
|
+
export declare function wearLevels(options: WearOptions): WearLevels | null;
|
|
35
|
+
export type CornerKind = 'sharp' | 'soft' | 'rounded' | 'chipped' | 'dog-eared';
|
|
36
|
+
export interface WearCorner {
|
|
37
|
+
kind: CornerKind;
|
|
38
|
+
/** How far the damage reaches along each edge, in units of a 250 by 350 card. */
|
|
39
|
+
size: number;
|
|
40
|
+
/** Jagged points of a chip, in the corner's own frame. */
|
|
41
|
+
jag: number[];
|
|
42
|
+
}
|
|
43
|
+
export interface WearMark {
|
|
44
|
+
x1: number;
|
|
45
|
+
y1: number;
|
|
46
|
+
x2: number;
|
|
47
|
+
y2: number;
|
|
48
|
+
/** Strength from 0 to 1. */
|
|
49
|
+
a: number;
|
|
50
|
+
/** A crease that broke the print. */
|
|
51
|
+
heavy?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface WearFleck {
|
|
54
|
+
x: number;
|
|
55
|
+
y: number;
|
|
56
|
+
r: number;
|
|
57
|
+
a: number;
|
|
58
|
+
light: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface WearEdgeFleck {
|
|
61
|
+
x: number;
|
|
62
|
+
y: number;
|
|
63
|
+
w: number;
|
|
64
|
+
h: number;
|
|
65
|
+
a: number;
|
|
66
|
+
}
|
|
67
|
+
export interface WearFace {
|
|
68
|
+
edge: WearEdgeFleck[];
|
|
69
|
+
creases: WearMark[];
|
|
70
|
+
scratches: WearMark[];
|
|
71
|
+
specks: WearFleck[];
|
|
72
|
+
stain: {
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
r: number;
|
|
76
|
+
a: number;
|
|
77
|
+
} | null;
|
|
78
|
+
}
|
|
79
|
+
export interface WearFeatures {
|
|
80
|
+
levels: WearLevels;
|
|
81
|
+
/** Top left, top right, bottom right, bottom left of the front. */
|
|
82
|
+
corners: WearCorner[];
|
|
83
|
+
/** The print's shift off centre in pixels at 300 wide: x and y. */
|
|
84
|
+
centering: {
|
|
85
|
+
x: number;
|
|
86
|
+
y: number;
|
|
87
|
+
};
|
|
88
|
+
front: WearFace;
|
|
89
|
+
back: WearFace;
|
|
90
|
+
}
|
|
91
|
+
export declare const CARD_W = 250;
|
|
92
|
+
export declare const CARD_H = 350;
|
|
93
|
+
/** The radius of a perfect card's corner in these units (15 px of 300). */
|
|
94
|
+
export declare const BASE_RADIUS = 12.5;
|
|
95
|
+
/** Where every mark of a card lies. A pure function of the levels and the seed: no DOM, nothing at random. */
|
|
96
|
+
export declare function wearLayout(levels: WearLevels, seed?: number): WearFeatures;
|
|
97
|
+
/** The outline of a face as an SVG path in the 250 by 350 box, corners as worn. */
|
|
98
|
+
export declare function wearOutline(features: WearFeatures, face?: 'front' | 'back'): string;
|
|
99
|
+
/** The SVG laid over one face: whitening, folds, creases, scratches, specks, stain and toning. Markup only, no script. */
|
|
100
|
+
export declare function wearOverlaySvg(features: WearFeatures, face?: 'front' | 'back'): string;
|
|
101
|
+
/** Draw a card's wear into its shadow root; calling it again with other options replaces the first. */
|
|
102
|
+
export declare function applyWear(root: ShadowRoot, options: WearOptions): boolean;
|
|
103
|
+
/** Take a card's wear away, leaving the card as it was. */
|
|
104
|
+
export declare function clearWear(root: ShadowRoot): void;
|
package/dist/wear.js
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wear: a card that is not perfect.
|
|
3
|
+
*
|
|
4
|
+
* Real condition grading looks at four things: corners, edges, surface and centering, and at creases and staining
|
|
5
|
+
* (see docs/wear.md for the sources and what each says). Here a preset sets how much of each there is, from 0 (none) to
|
|
6
|
+
* 1 (the worst the preset names), and a seed lays the marks out, so the same seed draws the same card every time.
|
|
7
|
+
* Everything is drawn: the outline of each face (rounded, chipped or folded corners) and one SVG over each face
|
|
8
|
+
* (whitening, creases, scratches, specks, staining, toning). Nothing here is a picture.
|
|
9
|
+
*
|
|
10
|
+
* This module is loaded by `<fuda-card>` only when a card asks for wear, so a perfect card carries none of it.
|
|
11
|
+
*/
|
|
12
|
+
import { seededRandom } from './stack.js';
|
|
13
|
+
const L = (corners, edges, surface, creases, toning, centering) => ({ corners, edges, surface, creases, toning, centering });
|
|
14
|
+
/** From perfect to damaged. The names are the plain grading terms; the numbers are this package's reading of them (docs/wear.md). */
|
|
15
|
+
export const wearPresets = [
|
|
16
|
+
{ id: 'perfect', name: 'Perfect', levels: L(0, 0, 0, 0, 0, 0), says: 'No imperfections, even close up. Draws nothing.' },
|
|
17
|
+
{ id: 'mint', name: 'Mint', levels: L(0.05, 0.05, 0.06, 0, 0, 0.1), says: 'Nothing to the naked eye; a flaw or two only on close inspection.' },
|
|
18
|
+
{ id: 'near-mint', name: 'Near mint', levels: L(0.18, 0.2, 0.2, 0, 0, 0.2), says: 'Sharp corners, a trace of edge whitening, a few light scratches.' },
|
|
19
|
+
{ id: 'lightly-played', name: 'Lightly played', levels: L(0.38, 0.45, 0.4, 0, 0.05, 0.3), says: 'Very slight corner rounding, whitening on one or two edges, scratches seen when tilted.' },
|
|
20
|
+
{ id: 'moderately-played', name: 'Moderately played', levels: L(0.62, 0.68, 0.62, 0.08, 0.15, 0.45), says: 'Soft or rounded corners, whitening on several edges, obvious scratches, some gloss lost.' },
|
|
21
|
+
{ id: 'heavily-played', name: 'Heavily played', levels: L(0.82, 0.9, 0.85, 0.3, 0.3, 0.6), says: 'Corners that have lost their shape, heavy whitening, deep scratches, minor creases.' },
|
|
22
|
+
{ id: 'damaged', name: 'Damaged', levels: L(1, 1, 1, 0.85, 0.5, 0.8), says: 'Chipped and folded corners, hard creases, staining.' }
|
|
23
|
+
];
|
|
24
|
+
export function wearPreset(id) {
|
|
25
|
+
return wearPresets.find((preset) => preset.id === id);
|
|
26
|
+
}
|
|
27
|
+
const clamp01 = (value) => (Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0);
|
|
28
|
+
const round = (value) => Math.round(value * 100) / 100;
|
|
29
|
+
/** The levels a card's wear asks for, or null when it asks for none (no wear, "perfect", an unknown name or all zero). */
|
|
30
|
+
export function wearLevels(options) {
|
|
31
|
+
const asked = options.wear;
|
|
32
|
+
let base = L(0, 0, 0, 0, 0, 0);
|
|
33
|
+
if (typeof asked === 'number' && Number.isFinite(asked)) {
|
|
34
|
+
const n = clamp01(asked);
|
|
35
|
+
base = L(n, n, n, n * n, n * 0.5, n);
|
|
36
|
+
}
|
|
37
|
+
else if (typeof asked === 'string' && asked.trim() !== '') {
|
|
38
|
+
const preset = wearPreset(asked.trim());
|
|
39
|
+
if (preset)
|
|
40
|
+
base = preset.levels;
|
|
41
|
+
else if (Number.isFinite(Number(asked)))
|
|
42
|
+
return wearLevels({ ...options, wear: Number(asked) });
|
|
43
|
+
}
|
|
44
|
+
const levels = { ...base };
|
|
45
|
+
for (const key of ['corners', 'edges', 'surface', 'creases']) {
|
|
46
|
+
const given = options[key];
|
|
47
|
+
if (given !== undefined && Number.isFinite(given))
|
|
48
|
+
levels[key] = clamp01(given);
|
|
49
|
+
}
|
|
50
|
+
return Object.values(levels).every((v) => v === 0) ? null : levels;
|
|
51
|
+
}
|
|
52
|
+
export const CARD_W = 250;
|
|
53
|
+
export const CARD_H = 350;
|
|
54
|
+
/** The radius of a perfect card's corner in these units (15 px of 300). */
|
|
55
|
+
export const BASE_RADIUS = 12.5;
|
|
56
|
+
function cornerFor(severity, random) {
|
|
57
|
+
const s = clamp01(severity);
|
|
58
|
+
if (s < 0.1)
|
|
59
|
+
return { kind: 'sharp', size: BASE_RADIUS, jag: [] };
|
|
60
|
+
if (s < 0.35)
|
|
61
|
+
return { kind: 'soft', size: round(BASE_RADIUS + s * 14), jag: [] };
|
|
62
|
+
if (s < 0.6)
|
|
63
|
+
return { kind: 'rounded', size: round(17 + s * 22), jag: [] };
|
|
64
|
+
if (s < 0.8) {
|
|
65
|
+
const size = round(7 + s * 14);
|
|
66
|
+
return { kind: 'chipped', size, jag: [round(0.3 + random() * 0.25), round(0.25 + random() * 0.3), round(0.5 + random() * 0.35), round(0.1 + random() * 0.2)] };
|
|
67
|
+
}
|
|
68
|
+
return { kind: 'dog-eared', size: round(15 + s * 22), jag: [] };
|
|
69
|
+
}
|
|
70
|
+
function faceFor(levels, random) {
|
|
71
|
+
const edge = [];
|
|
72
|
+
const flecks = Math.round(levels.edges * 30);
|
|
73
|
+
for (let i = 0; i < flecks; i++) {
|
|
74
|
+
const side = Math.floor(random() * 4), at = 0.08 + random() * 0.84, len = 2 + random() * (3 + levels.edges * 12), depth = 0.5 + random() * (0.8 + levels.edges * 2.4);
|
|
75
|
+
const a = round(0.7 + random() * 0.3);
|
|
76
|
+
if (side === 0)
|
|
77
|
+
edge.push({ x: round(at * CARD_W), y: 0, w: round(len), h: round(depth), a });
|
|
78
|
+
else if (side === 1)
|
|
79
|
+
edge.push({ x: round(CARD_W - depth), y: round(at * CARD_H), w: round(depth), h: round(len), a });
|
|
80
|
+
else if (side === 2)
|
|
81
|
+
edge.push({ x: round(at * CARD_W), y: round(CARD_H - depth), w: round(len), h: round(depth), a });
|
|
82
|
+
else
|
|
83
|
+
edge.push({ x: 0, y: round(at * CARD_H), w: round(depth), h: round(len), a });
|
|
84
|
+
}
|
|
85
|
+
const scratches = [];
|
|
86
|
+
const lines = Math.round(levels.surface * 9);
|
|
87
|
+
for (let i = 0; i < lines; i++) {
|
|
88
|
+
const x1 = 15 + random() * 220, y1 = 15 + random() * 320, angle = random() * Math.PI, len = 14 + random() * (30 + levels.surface * 60);
|
|
89
|
+
scratches.push({ x1: round(x1), y1: round(y1), x2: round(Math.min(245, Math.max(5, x1 + Math.cos(angle) * len))), y2: round(Math.min(345, Math.max(5, y1 + Math.sin(angle) * len))), a: round(0.15 + random() * 0.35) });
|
|
90
|
+
}
|
|
91
|
+
const specks = [];
|
|
92
|
+
const dots = Math.round(levels.surface * 26);
|
|
93
|
+
for (let i = 0; i < dots; i++)
|
|
94
|
+
specks.push({ x: round(8 + random() * 234), y: round(8 + random() * 334), r: round(0.3 + random() * 0.9), a: round(0.25 + random() * 0.4), light: random() < 0.5 });
|
|
95
|
+
const creases = [];
|
|
96
|
+
const count = levels.creases <= 0.04 ? 0 : Math.min(4, Math.ceil(levels.creases * 3));
|
|
97
|
+
for (let i = 0; i < count; i++) {
|
|
98
|
+
const horizontal = random() < 0.5, along = 0.15 + random() * 0.7, other = 0.15 + random() * 0.7;
|
|
99
|
+
const heavy = levels.creases > 0.5 && i === 0;
|
|
100
|
+
const x1 = horizontal ? 0 : along * CARD_W, y1 = horizontal ? along * CARD_H : 0;
|
|
101
|
+
const x2 = horizontal ? CARD_W : other * CARD_W, y2 = horizontal ? other * CARD_H : CARD_H;
|
|
102
|
+
creases.push({ x1: round(x1), y1: round(y1), x2: round(x2), y2: round(y2), a: round(0.5 + random() * 0.4), heavy });
|
|
103
|
+
}
|
|
104
|
+
const stain = levels.creases > 0.5 || levels.toning > 0.4 ? { x: round(40 + random() * 170), y: round(60 + random() * 230), r: round(25 + random() * 45), a: round(0.12 + levels.toning * 0.25) } : null;
|
|
105
|
+
return { edge, creases, scratches, specks, stain };
|
|
106
|
+
}
|
|
107
|
+
/** Where every mark of a card lies. A pure function of the levels and the seed: no DOM, nothing at random. */
|
|
108
|
+
export function wearLayout(levels, seed = 1) {
|
|
109
|
+
const base = (Number.isFinite(seed) ? seed : 1) * 2654435761;
|
|
110
|
+
const corners = [];
|
|
111
|
+
for (let at = 0; at < 4; at++) {
|
|
112
|
+
const random = seededRandom((base + (at + 1) * 40503) >>> 0);
|
|
113
|
+
corners.push(cornerFor(levels.corners * (0.35 + random() * 0.95), random));
|
|
114
|
+
}
|
|
115
|
+
// A card has at most one folded corner and two chipped ones; the rest are only rounded, as real damage rarely falls on all four.
|
|
116
|
+
let folded = 0, chipped = 0;
|
|
117
|
+
corners.forEach((corner, index) => {
|
|
118
|
+
if (corner.kind === 'dog-eared' && ++folded > 1)
|
|
119
|
+
corners[index] = { kind: 'chipped', size: round(corner.size * 0.45), jag: [0.4, 0.35, 0.6, 0.2] };
|
|
120
|
+
if (corners[index].kind === 'chipped' && ++chipped > 2)
|
|
121
|
+
corners[index] = { kind: 'rounded', size: round(corner.size * 1.6), jag: [] };
|
|
122
|
+
});
|
|
123
|
+
const place = seededRandom((base + 7919) >>> 0);
|
|
124
|
+
const centering = { x: round((place() * 2 - 1) * levels.centering * 7), y: round((place() * 2 - 1) * levels.centering * 5) };
|
|
125
|
+
return { levels, corners, centering, front: faceFor(levels, seededRandom((base + 1000003) >>> 0)), back: faceFor({ ...levels, creases: levels.creases }, seededRandom((base + 2000003) >>> 0)) };
|
|
126
|
+
}
|
|
127
|
+
/** Points of one corner from where it leaves the incoming edge to where it joins the outgoing edge, in the corner's frame (a along the way out, b back along the way in). */
|
|
128
|
+
function cornerPoints(corner) {
|
|
129
|
+
const s = corner.kind === 'sharp' ? BASE_RADIUS : corner.size;
|
|
130
|
+
if (corner.kind === 'dog-eared')
|
|
131
|
+
return [[0, s], [s, 0]];
|
|
132
|
+
if (corner.kind === 'chipped') {
|
|
133
|
+
const [p, q, r, t] = corner.jag;
|
|
134
|
+
return [[0, s], [s * p, s * (1 - q) * 0.9], [s * q * 0.5, s * r * 0.5], [s * (1 - t), s * t], [s, 0]];
|
|
135
|
+
}
|
|
136
|
+
const points = [];
|
|
137
|
+
for (let step = 0; step <= 6; step++) {
|
|
138
|
+
const angle = (step / 6) * (Math.PI / 2);
|
|
139
|
+
points.push([s - s * Math.cos(angle), s - s * Math.sin(angle)]);
|
|
140
|
+
}
|
|
141
|
+
return points;
|
|
142
|
+
}
|
|
143
|
+
/** Which of the front's corners a face's corner is: the back is the front seen from behind, so left and right swap. */
|
|
144
|
+
const frames = [
|
|
145
|
+
{ x: 0, y: 0, a: [1, 0], b: [0, 1] },
|
|
146
|
+
{ x: CARD_W, y: 0, a: [0, 1], b: [-1, 0] },
|
|
147
|
+
{ x: CARD_W, y: CARD_H, a: [-1, 0], b: [0, -1] },
|
|
148
|
+
{ x: 0, y: CARD_H, a: [0, -1], b: [1, 0] }
|
|
149
|
+
];
|
|
150
|
+
const mirrored = [1, 0, 3, 2];
|
|
151
|
+
const at = (frame, a, b) => [round(frame.x + frame.a[0] * a + frame.b[0] * b), round(frame.y + frame.a[1] * a + frame.b[1] * b)];
|
|
152
|
+
/** The corner a face draws at position `index` (0 top left, clockwise as seen on that face). */
|
|
153
|
+
function faceCorner(features, index, face) {
|
|
154
|
+
return features.corners[face === 'front' ? index : mirrored[index]];
|
|
155
|
+
}
|
|
156
|
+
/** The outline of a face as an SVG path in the 250 by 350 box, corners as worn. */
|
|
157
|
+
export function wearOutline(features, face = 'front') {
|
|
158
|
+
const points = [];
|
|
159
|
+
frames.forEach((frame, index) => {
|
|
160
|
+
for (const [a, b] of cornerPoints(faceCorner(features, index, face)))
|
|
161
|
+
points.push(at(frame, a, b));
|
|
162
|
+
});
|
|
163
|
+
return `M${points.map(([x, y]) => `${x} ${y}`).join('L')}Z`;
|
|
164
|
+
}
|
|
165
|
+
function line(m, stroke, width, opacity, extra = '', bend = 0) {
|
|
166
|
+
const nx = -(m.y2 - m.y1), ny = m.x2 - m.x1, len = Math.hypot(nx, ny) || 1;
|
|
167
|
+
const way = bend ? `Q${round((m.x1 + m.x2) / 2 + (nx / len) * bend)} ${round((m.y1 + m.y2) / 2 + (ny / len) * bend)} ${m.x2} ${m.y2}` : `L${m.x2} ${m.y2}`;
|
|
168
|
+
return `<path d="M${m.x1} ${m.y1}${way}" stroke="${stroke}" stroke-width="${width}" opacity="${opacity}" fill="none" stroke-linecap="round"${extra}/>`;
|
|
169
|
+
}
|
|
170
|
+
/** The SVG laid over one face: whitening, folds, creases, scratches, specks, stain and toning. Markup only, no script. */
|
|
171
|
+
export function wearOverlaySvg(features, face = 'front') {
|
|
172
|
+
const data = face === 'front' ? features.front : features.back;
|
|
173
|
+
const levels = features.levels;
|
|
174
|
+
const paper = '#fffaf0';
|
|
175
|
+
const out = [];
|
|
176
|
+
out.push('<defs><radialGradient id="t" cx="50%" cy="48%" r="75%"><stop offset="45%" stop-color="#b8863a" stop-opacity="0"/><stop offset="100%" stop-color="#7a4a14" stop-opacity="1"/></radialGradient><linearGradient id="f" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#fff" stop-opacity="0.5"/><stop offset="1" stop-color="#000" stop-opacity="0.35"/></linearGradient><radialGradient id="s"><stop offset="0" stop-color="#6b4513" stop-opacity="1"/><stop offset="100%" stop-color="#6b4513" stop-opacity="0"/></radialGradient></defs>');
|
|
177
|
+
if (levels.toning > 0)
|
|
178
|
+
out.push(`<rect width="${CARD_W}" height="${CARD_H}" fill="url(#t)" opacity="${round(levels.toning * 0.55)}" style="mix-blend-mode:multiply"/>`);
|
|
179
|
+
if (data.stain)
|
|
180
|
+
out.push(`<circle cx="${data.stain.x}" cy="${data.stain.y}" r="${data.stain.r}" fill="url(#s)" opacity="${data.stain.a}" style="mix-blend-mode:multiply"/>`);
|
|
181
|
+
for (const f of data.specks)
|
|
182
|
+
out.push(`<circle cx="${f.x}" cy="${f.y}" r="${f.r}" fill="${f.light ? '#fff' : '#2b1b08'}" opacity="${f.a}"/>`);
|
|
183
|
+
for (const m of data.scratches)
|
|
184
|
+
out.push(line(m, '#fff', 0.45, m.a));
|
|
185
|
+
for (const m of data.creases) {
|
|
186
|
+
const nx = -(m.y2 - m.y1), ny = m.x2 - m.x1, len = Math.hypot(nx, ny) || 1, ox = round((nx / len) * 0.9), oy = round((ny / len) * 0.9);
|
|
187
|
+
const bend = round((m.a - 0.7) * 14);
|
|
188
|
+
out.push(line({ ...m, x1: round(m.x1 + ox), y1: round(m.y1 + oy), x2: round(m.x2 + ox), y2: round(m.y2 + oy) }, '#2a1a05', m.heavy ? 1.3 : 0.8, round(m.a * 0.4), '', bend));
|
|
189
|
+
out.push(line(m, '#fff', m.heavy ? 1.1 : 0.6, round(m.a * 0.55), '', bend));
|
|
190
|
+
if (m.heavy)
|
|
191
|
+
out.push(line(m, paper, 1.6, 0.8, ' stroke-dasharray="9 5 3 11 6 4"', bend));
|
|
192
|
+
}
|
|
193
|
+
for (const e of data.edge)
|
|
194
|
+
out.push(`<rect x="${e.x}" y="${e.y}" width="${e.w}" height="${e.h}" fill="${paper}" opacity="${e.a}"/>`);
|
|
195
|
+
frames.forEach((frame, index) => {
|
|
196
|
+
const corner = faceCorner(features, index, face);
|
|
197
|
+
const pts = cornerPoints(corner).map(([a, b]) => at(frame, a, b));
|
|
198
|
+
if (corner.kind === 'sharp') {
|
|
199
|
+
if (levels.corners > 0.02)
|
|
200
|
+
out.push(`<circle cx="${at(frame, 1.3, 1.3)[0]}" cy="${at(frame, 1.3, 1.3)[1]}" r="1.3" fill="${paper}" opacity="0.8"/>`);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (corner.kind === 'dog-eared') {
|
|
204
|
+
const s = corner.size, fold = [at(frame, 0, s), at(frame, s, 0), at(frame, s, s)];
|
|
205
|
+
const flap = face === 'front' ? '#183450' : '#e8c46a';
|
|
206
|
+
const shade = [at(frame, 0, s), at(frame, s, 0), at(frame, s + 2.2, s + 2.2)];
|
|
207
|
+
out.push(`<polygon points="${shade.map((p) => p.join(',')).join(' ')}" fill="#000" opacity="0.3"/>`);
|
|
208
|
+
out.push(`<polygon points="${fold.map((p) => p.join(',')).join(' ')}" fill="${flap}" stroke="${paper}" stroke-width="0.8"/>`);
|
|
209
|
+
out.push(`<polygon points="${fold.map((p) => p.join(',')).join(' ')}" fill="url(#f)" opacity="0.55"/>`);
|
|
210
|
+
out.push(`<path d="M${pts.map((p) => p.join(' ')).join('L')}" stroke="${paper}" stroke-width="1.2" fill="none"/>`);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
out.push(`<path d="M${pts.map((p) => p.join(' ')).join('L')}" stroke="${paper}" stroke-width="${corner.kind === 'chipped' ? 2.2 : 1.6}" opacity="0.85" fill="none" stroke-linejoin="round"/>`);
|
|
214
|
+
});
|
|
215
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${CARD_W} ${CARD_H}" preserveAspectRatio="none" aria-hidden="true">${out.join('')}</svg>`;
|
|
216
|
+
}
|
|
217
|
+
const STYLE = '.wear{position:absolute;pointer-events:none;display:block}.wear svg{display:block;width:100%;height:100%}';
|
|
218
|
+
const maskUrl = (path) => `url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${CARD_W} ${CARD_H}" preserveAspectRatio="none"><path d="${path}" fill="#000"/></svg>`)}")`;
|
|
219
|
+
/** Draw a card's wear into its shadow root; calling it again with other options replaces the first. */
|
|
220
|
+
export function applyWear(root, options) {
|
|
221
|
+
const levels = wearLevels(options);
|
|
222
|
+
clearWear(root);
|
|
223
|
+
if (!levels)
|
|
224
|
+
return false;
|
|
225
|
+
const features = wearLayout(levels, options.seed ?? 1);
|
|
226
|
+
const style = document.createElement('style');
|
|
227
|
+
style.dataset.wear = '';
|
|
228
|
+
style.textContent = STYLE;
|
|
229
|
+
root.prepend(style);
|
|
230
|
+
for (const face of ['front', 'back']) {
|
|
231
|
+
const element = root.querySelector(`.face.${face}`);
|
|
232
|
+
if (!element)
|
|
233
|
+
continue;
|
|
234
|
+
const holder = document.createElement('div');
|
|
235
|
+
holder.className = 'wear';
|
|
236
|
+
holder.dataset.wear = face;
|
|
237
|
+
holder.style.inset = face === 'front' ? '-2px' : '-11px';
|
|
238
|
+
holder.innerHTML = wearOverlaySvg(features, face);
|
|
239
|
+
element.append(holder);
|
|
240
|
+
const mask = maskUrl(wearOutline(features, face));
|
|
241
|
+
element.style.setProperty('-webkit-mask-image', mask);
|
|
242
|
+
element.style.setProperty('mask-image', mask);
|
|
243
|
+
element.style.setProperty('-webkit-mask-size', '100% 100%');
|
|
244
|
+
element.style.setProperty('mask-size', '100% 100%');
|
|
245
|
+
element.style.setProperty('-webkit-mask-repeat', 'no-repeat');
|
|
246
|
+
element.style.setProperty('mask-repeat', 'no-repeat');
|
|
247
|
+
}
|
|
248
|
+
const front = root.querySelector('.face.front');
|
|
249
|
+
if (front) {
|
|
250
|
+
const { x, y } = features.centering;
|
|
251
|
+
front.style.padding = `${13 + y}px ${13 - x}px ${13 - y}px ${13 + x}px`;
|
|
252
|
+
}
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
/** Take a card's wear away, leaving the card as it was. */
|
|
256
|
+
export function clearWear(root) {
|
|
257
|
+
root.querySelector('style[data-wear]')?.remove();
|
|
258
|
+
for (const holder of Array.from(root.querySelectorAll('.wear')))
|
|
259
|
+
holder.remove();
|
|
260
|
+
for (const element of Array.from(root.querySelectorAll('.face'))) {
|
|
261
|
+
for (const name of ['-webkit-mask-image', 'mask-image', '-webkit-mask-size', 'mask-size', '-webkit-mask-repeat', 'mask-repeat'])
|
|
262
|
+
element.style.removeProperty(name);
|
|
263
|
+
if (element.classList.contains('front'))
|
|
264
|
+
element.style.removeProperty('padding');
|
|
265
|
+
if (!element.getAttribute('style'))
|
|
266
|
+
element.removeAttribute('style');
|
|
267
|
+
}
|
|
268
|
+
}
|
package/dist/zoom.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ interface ViewState {
|
|
|
3
3
|
zoom: number;
|
|
4
4
|
panX: number;
|
|
5
5
|
panY: number;
|
|
6
|
+
yaw?: number;
|
|
7
|
+
tilt?: number;
|
|
6
8
|
}
|
|
7
9
|
export interface ZoomControls extends HTMLElement {
|
|
8
10
|
readonly state: ViewState;
|
|
@@ -11,6 +13,7 @@ export interface ZoomControls extends HTMLElement {
|
|
|
11
13
|
};
|
|
12
14
|
view: HTMLElement | undefined;
|
|
13
15
|
set(next: Partial<ViewState>): void;
|
|
16
|
+
readonly turning?: boolean;
|
|
14
17
|
setFitScale(scale: number): void;
|
|
15
18
|
}
|
|
16
19
|
export interface ZoomOptions {
|
|
@@ -20,6 +23,8 @@ export interface ZoomOptions {
|
|
|
20
23
|
address?: boolean;
|
|
21
24
|
/** Put the controls after this element instead of after the stage. */
|
|
22
25
|
after?: Element;
|
|
26
|
+
/** The colour theme of the controls (`light` or `dark`); left out they follow the page. */
|
|
27
|
+
theme?: string;
|
|
23
28
|
}
|
|
24
29
|
export interface ZoomView {
|
|
25
30
|
controls: ZoomControls;
|
|
@@ -30,6 +35,8 @@ export interface ZoomView {
|
|
|
30
35
|
/** Go back to the opening view. */
|
|
31
36
|
reset(): void;
|
|
32
37
|
zoomed(): boolean;
|
|
38
|
+
/** Let the reader turn the view in 3D (angle, tilt, Auto-turn) or only zoom and move it. Off by default. */
|
|
39
|
+
setTurnable(on: boolean): void;
|
|
33
40
|
}
|
|
34
41
|
/**
|
|
35
42
|
* Zoom, Fit and pan for a flat view. `stage` clips, `view` is its absolutely positioned child that holds the items and is
|
package/dist/zoom.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '@johnmorrisdotca/kazoku-ui/view-controls/define';
|
|
2
2
|
const MARGIN = 12;
|
|
3
3
|
const ZOOMED = 1.05;
|
|
4
|
-
const TAPPABLE = 'button:not(:disabled), a[href]';
|
|
4
|
+
const TAPPABLE = 'button:not(:disabled), a[href], [role=button]';
|
|
5
5
|
/**
|
|
6
6
|
* Zoom, Fit and pan for a flat view. `stage` clips, `view` is its absolutely positioned child that holds the items and is
|
|
7
7
|
* moved and scaled. Fit shows every item at once; the reader's zoom and pan are never reset by a change of content.
|
|
@@ -12,7 +12,8 @@ export function zoomView(stage, view, options = {}) {
|
|
|
12
12
|
controls.setAttribute('flat', '');
|
|
13
13
|
controls.setAttribute('ignore', '');
|
|
14
14
|
controls.setAttribute('zoom-min', '0.4');
|
|
15
|
-
|
|
15
|
+
if (options.theme)
|
|
16
|
+
controls.setAttribute('theme', options.theme);
|
|
16
17
|
if (options.address)
|
|
17
18
|
controls.setAttribute('address', '');
|
|
18
19
|
(options.after ?? stage).after(controls);
|
|
@@ -21,7 +22,8 @@ export function zoomView(stage, view, options = {}) {
|
|
|
21
22
|
stage.addEventListener('dragstart', e => e.preventDefault());
|
|
22
23
|
let box = { w: 0, h: 0, cx: 0, cy: 0, bw: 0, bh: 0 };
|
|
23
24
|
let fit = 1;
|
|
24
|
-
|
|
25
|
+
let turnable = false;
|
|
26
|
+
const self = { controls, minOpen: 0, refresh, reset: () => refresh(true), zoomed: () => controls.state.zoom > ZOOMED, setTurnable };
|
|
25
27
|
function measure() {
|
|
26
28
|
const previous = view.style.transform;
|
|
27
29
|
view.style.transform = 'none';
|
|
@@ -50,7 +52,17 @@ export function zoomView(stage, view, options = {}) {
|
|
|
50
52
|
function draw(state) {
|
|
51
53
|
const scale = fit * state.zoom;
|
|
52
54
|
view.style.transformOrigin = `${box.cx}px ${box.cy}px`;
|
|
53
|
-
|
|
55
|
+
const turn = turnable ? ` rotateX(${state.tilt ?? 0}deg) rotateY(${state.yaw ?? 0}deg)` : '';
|
|
56
|
+
view.style.transform = `translate(${box.w / 2 - box.cx + state.panX}px,${box.h / 2 - box.cy + state.panY}px) scale(${scale})${turn}`;
|
|
57
|
+
}
|
|
58
|
+
function setTurnable(on) {
|
|
59
|
+
if (on === turnable)
|
|
60
|
+
return;
|
|
61
|
+
turnable = on;
|
|
62
|
+
if (!on)
|
|
63
|
+
controls.set({ yaw: 0, tilt: 0 });
|
|
64
|
+
controls.toggleAttribute('flat', !on);
|
|
65
|
+
draw(controls.state);
|
|
54
66
|
}
|
|
55
67
|
function refresh(open = false) {
|
|
56
68
|
measure();
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Collection displays
|
|
2
2
|
|
|
3
|
-
Fuda supplies reusable frames for a caller's cards and reusable ways to display collections on websites. The hosting site supplies the card data and artwork or interactive content. Initial versions of
|
|
3
|
+
Fuda supplies reusable frames for a caller's cards and reusable ways to display collections on websites. The hosting site supplies the card data and artwork or interactive content. Initial versions of twelve layouts now exist in `<fuda-collection>`. They are prototypes; the detailed capabilities below remain design goals unless described as implemented in the README.
|
|
4
|
+
|
|
5
|
+
## Choosing a display, the deck and the fan (0.6.0)
|
|
6
|
+
|
|
7
|
+
- **Display buttons.** All twelve displays are buttons on screen at once, in a row that spans the width, each with a small picture of its layout. No drop-down. At least 48 px high; 4 to a row on a phone, 6 on a desk; arrow keys move the choice; light and dark follow the reader.
|
|
8
|
+
- **Deck.** A deck and a pile. Next flips the top card off to the pile on the deck's other side, Previous brings it back. The landing is a choice: still facing up, upside down (spun half way round in its plane) or face down (turned over, showing the back image, or the package's own back). One element flies, so a card is never drawn twice. The deck turns in 3D with the angle, tilt and Auto-turn controls.
|
|
9
|
+
- **Fan.** `view="fan"`: the cards of the deck spread in an arc like a hand of playing cards (about half of each card shows) and close back to the squared-up deck, each card back where it started. The state is in the address (`?fan=open`).
|
|
10
|
+
- Not done: a fan or a pile inside `<fuda-card stack>` (those cards all carry the same picture), dealing more than one card at a time, a pile that fills up with the whole discard history (the pile shows the last ten).
|
|
4
11
|
|
|
5
12
|
## Zoom, Fit and move (every view)
|
|
6
13
|
|