fancy-ui-vue 0.3.0 → 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.
Files changed (54) hide show
  1. package/README.md +9 -6
  2. package/dist/components/magnetic-field/MagnetPuck.vue.d.ts +51 -0
  3. package/dist/components/magnetic-field/MagnetPuck.vue.js +7 -0
  4. package/dist/components/magnetic-field/MagnetPuck.vue2.js +191 -0
  5. package/dist/components/magnetic-field/MagneticField.vue.d.ts +39 -0
  6. package/dist/components/magnetic-field/MagneticField.vue.js +7 -0
  7. package/dist/components/magnetic-field/MagneticField.vue2.js +157 -0
  8. package/dist/components/magnetic-field/MagneticItem.vue.d.ts +28 -0
  9. package/dist/components/magnetic-field/MagneticItem.vue.js +7 -0
  10. package/dist/components/magnetic-field/MagneticItem.vue2.js +72 -0
  11. package/dist/components/magnetic-field/index.d.ts +10 -0
  12. package/dist/components/magnetic-field/magnetic-field-core.d.ts +163 -0
  13. package/dist/components/magnetic-field/magnetic-field-core.js +534 -0
  14. package/dist/components/magnetic-field/magnetic-field-source.d.ts +58 -0
  15. package/dist/components/magnetic-field/magnetic-field-source.js +58 -0
  16. package/dist/components/magnetic-field/types.d.ts +14 -0
  17. package/dist/components/magnetic-field/types.js +5 -0
  18. package/dist/components/pixel-scene/PixelScene.vue.d.ts +60 -0
  19. package/dist/components/pixel-scene/PixelScene.vue.js +184 -0
  20. package/dist/components/pixel-scene/PixelScene.vue2.js +4 -0
  21. package/dist/components/pixel-scene/index.d.ts +4 -0
  22. package/dist/components/pixel-scene/pixel-scene-core.d.ts +256 -0
  23. package/dist/components/pixel-scene/pixel-scene-core.js +878 -0
  24. package/dist/components/pixel-scene/pixel-scene-hdr.d.ts +68 -0
  25. package/dist/components/pixel-scene/pixel-scene-hdr.js +312 -0
  26. package/dist/components/pixel-scene/pixel-scene-scenes.d.ts +31 -0
  27. package/dist/components/pixel-scene/pixel-scene-scenes.js +1074 -0
  28. package/dist/components/story-thread/StoryNode.vue.d.ts +11 -0
  29. package/dist/components/story-thread/StoryNode.vue.js +7 -0
  30. package/dist/components/story-thread/StoryNode.vue2.js +23 -0
  31. package/dist/components/story-thread/StoryThread.vue.d.ts +56 -0
  32. package/dist/components/story-thread/StoryThread.vue.js +7 -0
  33. package/dist/components/story-thread/StoryThread.vue2.js +103 -0
  34. package/dist/components/story-thread/index.d.ts +5 -0
  35. package/dist/components/story-thread/story-thread-core.d.ts +119 -0
  36. package/dist/components/story-thread/story-thread-core.js +491 -0
  37. package/dist/components/story-thread/types.d.ts +1 -0
  38. package/dist/components/sun-switch/SunSwitch.vue.d.ts +61 -0
  39. package/dist/components/sun-switch/SunSwitch.vue.js +7 -0
  40. package/dist/components/sun-switch/SunSwitch.vue2.js +559 -0
  41. package/dist/components/sun-switch/index.d.ts +4 -0
  42. package/dist/components/sun-switch/pixel-wave-core.d.ts +82 -0
  43. package/dist/components/sun-switch/pixel-wave-core.js +508 -0
  44. package/dist/components/sun-switch/sun-switch-core.d.ts +251 -0
  45. package/dist/components/sun-switch/sun-switch-core.js +546 -0
  46. package/dist/components/sun-switch/sun-switch-hdr.d.ts +70 -0
  47. package/dist/components/sun-switch/sun-switch-hdr.js +311 -0
  48. package/dist/components/tracing-beam/TracingBeam.vue.d.ts +20 -1
  49. package/dist/components/tracing-beam/TracingBeam.vue.js +5 -164
  50. package/dist/components/tracing-beam/TracingBeam.vue2.js +168 -1
  51. package/dist/index.d.ts +4 -0
  52. package/dist/index.js +190 -164
  53. package/dist/styles.css +499 -0
  54. package/package.json +1 -1
@@ -0,0 +1,251 @@
1
+ /** Four colours from the top of the sun to the bottom (halo: outer fringe → inner rim). */
2
+ export type SunPalette = readonly [string, string, string, string];
3
+ export declare const SUN_PALETTE: SunPalette;
4
+ /** Opacity of the horizon dots when drawn in ink (outside the lens). */
5
+ export declare const HORIZON_ALPHA = 0.16;
6
+ /** Share of ink laid over the day sun at rest, so the lens (pure colour) reads on
7
+ * the disc too. Mixing toward the ink also raises the disc's contrast with the page. */
8
+ export declare const DAY_REST_INK = 0.3;
9
+ /** Half-widths of the reflection rows under the horizon line, as a share of the
10
+ * disc's outer radius (radius + 0.5). */
11
+ export declare const REFLECTION_ROWS: readonly number[];
12
+ /** Exponent applied to the halo depth before the Bayer threshold. */
13
+ export declare const HALO_EXPONENT = 0.7;
14
+ /** 4 × 4 ordered-dither thresholds, `(v + 0.5) / 16`, row-major (index = y * 4 + x). */
15
+ export declare const BAYER4: readonly number[];
16
+ /** Threshold of grid cell (x, y). Fixed in grid space; negative indices wrap. */
17
+ export declare function bayer4(x: number, y: number): number;
18
+ export declare function easeInOutCubic(t: number): number;
19
+ /** `clamp01(D) ** 0.7`: fraction of Bayer cells lit at halo depth D. */
20
+ export declare function haloDensity(D: number): number;
21
+ /** Palette index at halo depth D: 0 = outer fringe (first colour), 3 = inner rim. */
22
+ export declare function haloColorIndex(D: number): 0 | 1 | 2 | 3;
23
+ export interface ParsedColor {
24
+ r: number;
25
+ g: number;
26
+ b: number;
27
+ a: number;
28
+ }
29
+ /** Parses `rgb()` / `rgba()` (comma or space syntax), `#rgb[a]` / `#rrggbb[aa]` and
30
+ * `transparent`. Returns null for anything else (named colours, `oklch()`, ...). */
31
+ export declare function parseInk(css: string): ParsedColor | null;
32
+ /** Glow of the day sun at rest (× SDR white), on HDR displays. */
33
+ export declare const SUN_GLOW_DAY = 2.2;
34
+ /** Glow of a sun cell under the lens. */
35
+ export declare const SUN_GLOW_LENS = 4.9;
36
+ /** Glow of a horizon / reflection cell under the lens. */
37
+ export declare const HORIZON_GLOW_LENS = 1.6;
38
+ /** Halo glow at depth D: the dense inner rim peaks, the sparse fringe stays near SDR. */
39
+ export declare function haloGlow(D: number): number;
40
+ /**
41
+ * Receives every painted square that should glow on an HDR display: its
42
+ * top-left corner in device px, its colour as `0xRRGGBB` (what the 2D canvas
43
+ * shows) and its glow (× SDR white). The 2D painting is unchanged.
44
+ */
45
+ export interface GlowSink {
46
+ clear(): void;
47
+ push(px: number, py: number, rgb: number, glow: number): void;
48
+ }
49
+ /** What the painter hands its frames to: a sink and a render call. */
50
+ export interface SunGlowTarget {
51
+ readonly sink: GlowSink;
52
+ render(width: number, height: number, size: number): void;
53
+ }
54
+ /** `0xRRGGBB` of an opaque-enough CSS colour `parseInk` reads, else -1. Cached. */
55
+ export declare function rgbOf(css: string): number;
56
+ /** `a` blended toward `b` by `t` (sRGB, like the 2D canvas does). */
57
+ export declare function mixRgb(a: number, b: number, t: number): number;
58
+ export interface SunCell {
59
+ x: number;
60
+ y: number;
61
+ /** Palette index. */
62
+ color: number;
63
+ layer: "sun" | "horizon";
64
+ }
65
+ export interface SunRaster {
66
+ /** Canvas side in cells: 2 × radius + 1. */
67
+ size: number;
68
+ /** First row below the visible disc (== size when `horizon` is false). */
69
+ horizonRow: number;
70
+ cells: SunCell[];
71
+ }
72
+ /** Deterministic integer hash in [0, 1). Same bits in every JS engine. */
73
+ export declare function hash2(x: number, y: number): number;
74
+ /** Rasterises the sun disc (cut at 60 % when `horizon`), the dotted horizon line
75
+ * and up to three dashed reflection rows under it. */
76
+ export declare function rasterSun(o: {
77
+ radius: number;
78
+ horizon: boolean;
79
+ }): SunRaster;
80
+ /** `((origin % cell) + cell) % cell`: grid phase of a pixel coordinate. */
81
+ export declare function gridOffset(origin: number, cell: number): number;
82
+ /** Outer halo radius (cells) at which the clip covers every point of a W × H box. */
83
+ export declare function coverRadiusCells(origin: {
84
+ x: number;
85
+ y: number;
86
+ }, W: number, H: number, cell: number, halo: number): number;
87
+ /** One row of the staircase clip, in px. Every coordinate is ≡ the grid offset (mod cell). */
88
+ export interface StairRow {
89
+ y0: number;
90
+ y1: number;
91
+ x0: number;
92
+ x1: number;
93
+ }
94
+ /**
95
+ * Rows of the grid-aligned staircase disc of radius `innerRadius` (cells) centred
96
+ * on (tx, ty) (grid units, usually integer + 0.5). A cell row is included when its
97
+ * centre line meets the disc; its span is the chord widened to whole cells.
98
+ * Empty when `innerRadius` is not > 0.
99
+ */
100
+ export declare function staircaseRows(tx: number, ty: number, innerRadius: number, cell: number, ox: number, oy: number): StairRow[];
101
+ /** Same membership rule as `staircaseRows`, for one cell (i, j). */
102
+ export declare function inStaircase(i: number, j: number, tx: number, ty: number, inner: number): boolean;
103
+ export declare const EMPTY_POLYGON = "polygon(0 0, 0 0, 0 0)";
104
+ /** CSS `polygon()` outlining the rows (right side down, left side up), with
105
+ * consecutive duplicate vertices removed. `EMPTY_POLYGON` when there are no rows. */
106
+ export declare function staircasePolygon(rows: readonly StairRow[]): string;
107
+ /** CSS `clip-path` showing a W × H box except the staircase (an even-odd hole):
108
+ * the old-state layer in contained mode. Just the box when there are no rows. */
109
+ export declare function staircaseHoleClip(rows: readonly StairRow[], W: number, H: number): string;
110
+ /** The slice of CanvasRenderingContext2D the cores use (a recording fake fits). */
111
+ export interface Ctx2D {
112
+ fillStyle: string | CanvasGradient | CanvasPattern;
113
+ globalAlpha: number;
114
+ fillRect(x: number, y: number, w: number, h: number): void;
115
+ clearRect(x: number, y: number, w: number, h: number): void;
116
+ setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
117
+ beginPath?(): void;
118
+ rect?(x: number, y: number, w: number, h: number): void;
119
+ fill?(rule?: CanvasFillRule): void;
120
+ }
121
+ export interface HaloParams {
122
+ /** Wave origin in grid units of the halo canvas (usually integer + 0.5). */
123
+ cx: number;
124
+ cy: number;
125
+ /** Outer halo radius in cells. */
126
+ R: number;
127
+ /** Halo thickness in cells. */
128
+ halo: number;
129
+ cell: number;
130
+ dot: number;
131
+ /** Grid phase in CSS px. */
132
+ ox: number;
133
+ oy: number;
134
+ /** Canvas size in CSS px. */
135
+ W: number;
136
+ H: number;
137
+ palette: SunPalette;
138
+ /** Device pixel ratio of the canvas backing store. Default 1. */
139
+ dpr?: number;
140
+ /** HDR: every halo square is also pushed here, glowing by depth ({@link haloGlow}). */
141
+ glow?: GlowSink | null;
142
+ }
143
+ /**
144
+ * Paints the dithered halo band (cells with depth D = (R − d) / halo in [0, 1] and
145
+ * `bayer4 <= D^0.7`), iterating only the ring band of each row. Does not clear.
146
+ * Returns the number of squares drawn.
147
+ */
148
+ export declare function paintHalo(ctx: Ctx2D, p: HaloParams): number;
149
+ /** A rectangle in CSS px. */
150
+ export interface KeepRect {
151
+ x: number;
152
+ y: number;
153
+ w: number;
154
+ h: number;
155
+ }
156
+ /**
157
+ * Fills a W × H (CSS px) canvas with `color` except the staircase `hole`, then
158
+ * clears `keep` (the live element, so it stays visible). Uses `fillRect` /
159
+ * `clearRect` only. Does not clear first.
160
+ */
161
+ export declare function paintSheet(ctx: Ctx2D, color: string, W: number, H: number, dpr: number, hole: readonly StairRow[] | null, keep?: KeepRect | null): void;
162
+ export interface LensTarget {
163
+ x: number;
164
+ y: number;
165
+ on: boolean;
166
+ }
167
+ export interface Lens {
168
+ /** Current centre (cells) and radius (cells). */
169
+ readonly x: number;
170
+ readonly y: number;
171
+ readonly r: number;
172
+ /** Target radius while open. */
173
+ radius: number;
174
+ /**
175
+ * Advances to `nowMs` toward `target`. The first step after creation or
176
+ * `resetClock()` counts as one 60 Hz frame; later steps clamp dt to 64 ms.
177
+ * Returns true while still moving.
178
+ */
179
+ step(nowMs: number, target: LensTarget, reduced: boolean): boolean;
180
+ /** Forget the last timestamp (call when an idle loop restarts). */
181
+ resetClock(): void;
182
+ /** Whether cell (i, j) is under the lens. */
183
+ covers(i: number, j: number): boolean;
184
+ }
185
+ /** Soft circular lens: frame-rate independent position lerp, radius eased with
186
+ * 140 ms (open) / 260 ms (close) time constants, snapping within 0.3 cell. */
187
+ export declare function createLens(o: {
188
+ radius: number;
189
+ lerp?: number;
190
+ inMs?: number;
191
+ outMs?: number;
192
+ }): Lens;
193
+ export interface SunPainterOptions {
194
+ radius: number;
195
+ cell: number;
196
+ dot: number;
197
+ palette: SunPalette;
198
+ nightAlpha: number;
199
+ horizon: boolean;
200
+ lens: boolean;
201
+ lensRadius: number;
202
+ checked: boolean;
203
+ reducedMotion: boolean;
204
+ }
205
+ /** The wave front as seen by the painter, in canvas-local CSS px. `R` is the CLIP
206
+ * radius (outer halo radius − haloCells + 0.5, times cell), so the painter's
207
+ * "inside the front" test is exactly the staircase membership of the clip. */
208
+ export interface SunFront {
209
+ cx: number;
210
+ cy: number;
211
+ R: number;
212
+ nextChecked: boolean;
213
+ oldInk: string;
214
+ }
215
+ export interface SunPainter {
216
+ /** Layout keys (radius / cell / dot / horizon) re-raster and resize. */
217
+ setOptions(next: Partial<SunPainterOptions>): void;
218
+ /** Any CSS colour the canvas accepts (the computed `color` of the canvas). */
219
+ setInk(css: string): void;
220
+ /** Pointer in canvas cells; `on` opens / closes the lens. */
221
+ pointer(cellX: number, cellY: number, on: boolean): void;
222
+ setFront(front: SunFront | null): void;
223
+ /** HDR: every painted frame is also handed to `target` (null detaches it). */
224
+ setGlowTarget(target: SunGlowTarget | null): void;
225
+ resize(): void;
226
+ /** Resumes after `sleep()`: paints once and restarts the loop if anything animates. */
227
+ wake(): void;
228
+ /** Suspends the loop (out of view / hidden document). */
229
+ sleep(): void;
230
+ destroy(): void;
231
+ }
232
+ /** Paints the sun raster for one frame. Exported for tests (a recording fake fits). */
233
+ export declare function paintSun(ctx: Ctx2D, raster: SunRaster, o: {
234
+ cell: number;
235
+ dot: number;
236
+ dpr: number;
237
+ palette: SunPalette;
238
+ nightAlpha: number;
239
+ checked: boolean;
240
+ ink: string;
241
+ lens: Lens | null;
242
+ front: SunFront | null;
243
+ /** HDR: the day sun and the cells under the lens are also pushed here. */
244
+ glow?: GlowSink | null;
245
+ }): void;
246
+ /**
247
+ * Creates the painter for the switch canvas. Returns null when no 2D context is
248
+ * available (jsdom, SSR). The rAF loop runs only while the lens moves or a wave
249
+ * front is set; otherwise the canvas is painted once and the loop sleeps.
250
+ */
251
+ export declare function createSunPainter(canvas: HTMLCanvasElement, opts: SunPainterOptions): SunPainter | null;