@mkbabb/glass-ui 8.0.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aurora.js +371 -349
- package/dist/blob.js +42 -42
- package/dist/{checkbox-BnXuGgJ3.js → checkbox-B1qn65se.js} +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/color.glsl-DTJhdekG.js +34 -0
- package/dist/color.wgsl-BTszLY39.js +398 -0
- package/dist/{command-BuBnYpxF.js → command-tEzAaVY_.js} +1 -1
- package/dist/command.js +1 -1
- package/dist/components/_shared/control.d.ts +0 -1
- package/dist/components/_shared/index.d.ts +0 -1
- package/dist/components/aurora/Aurora.vue.d.ts +1 -0
- package/dist/components/aurora/composables/frameLoop.d.ts +6 -5
- package/dist/components/aurora/composables/runtime.d.ts +26 -1
- package/dist/components/aurora/composables/useAurora.d.ts +28 -0
- package/dist/components/aurora/composables/wgpuSetup.d.ts +1 -1
- package/dist/components/aurora/constants/presets.d.ts +44 -5
- package/dist/components/aurora/index.d.ts +1 -1
- package/dist/components/configurator/Configurator.vue.d.ts +25 -2
- package/dist/components/configurator/ConfiguratorRow.vue.d.ts +4 -2
- package/dist/components/configurator/styles.css +1 -1
- package/dist/components/dock/DockSeparator.vue.d.ts +2 -3
- package/dist/components/dock/GlassDock.vue.d.ts +1 -0
- package/dist/components/dock/composables/dockContext.d.ts +1 -8
- package/dist/components/dock/composables/useDockRun.d.ts +20 -0
- package/dist/components/dock/composables/useDockSearch.d.ts +1 -1
- package/dist/components/dock/composables/useDockShellProps.d.ts +18 -101
- package/dist/components/dock/composables/useDockState.d.ts +2 -9
- package/dist/components/dock/constants.d.ts +15 -0
- package/dist/components/dock/index.d.ts +2 -2
- package/dist/components/dock/styles/controls/icon-button.css +1 -1
- package/dist/components/dock/styles/controls/tab-button.css +1 -1
- package/dist/components/dock/styles/controls/triggers.css +1 -1
- package/dist/components/dock/styles/controls.css +1 -1
- package/dist/components/dock/styles/density.css +1 -1
- package/dist/components/dock/styles/index.css +1 -1
- package/dist/components/dock/styles/layer-group.css +1 -1
- package/dist/components/dock/styles/layers.css +1 -1
- package/dist/components/dock/styles/morph.css +1 -1
- package/dist/components/dock/styles/run.css +1 -0
- package/dist/components/dock/styles/search.css +1 -1
- package/dist/components/dock/styles/shape.css +1 -1
- package/dist/components/dock/styles/shell-regions.css +1 -1
- package/dist/components/dock/styles/shell.css +1 -1
- package/dist/components/fourier-field/FourierField.vue.d.ts +28 -25
- package/dist/components/fourier-field/clock.d.ts +35 -0
- package/dist/components/fourier-field/constants.d.ts +78 -103
- package/dist/components/fourier-field/index.d.ts +3 -28
- package/dist/components/fourier-field/math.d.ts +69 -77
- package/dist/components/fourier-field/renderer/mint.d.ts +50 -0
- package/dist/components/fourier-field/renderer/uniforms.d.ts +84 -0
- package/dist/components/fourier-field/renderer/wgpu.d.ts +28 -0
- package/dist/components/fourier-field/shaders/compute.wgsl.d.ts +1 -0
- package/dist/components/fourier-field/shaders/render.wgsl.d.ts +1 -0
- package/dist/components/fourier-field/useFourierField.d.ts +49 -0
- package/dist/components/handmark/HandMark.vue.d.ts +18 -14
- package/dist/components/handmark/index.d.ts +4 -23
- package/dist/components/handmark/stroke.d.ts +92 -0
- package/dist/composables/dark/darkModeSyncScript.d.ts +19 -0
- package/dist/composables/motion/pointer/pointerFieldMappings.d.ts +0 -41
- package/dist/{components/search/composables → composables/search}/index.d.ts +2 -2
- package/dist/{components/search/composables/fuzzySearchIndex.d.ts → composables/search/match.d.ts} +8 -3
- package/dist/configurator-BHJymdrF.js +339 -0
- package/dist/configurator.js +1 -1
- package/dist/constellation.js +2 -2
- package/dist/control-DJp15L4U.js +7 -0
- package/dist/{dark-z_P5QwqI.js → dark-CLlmo7dD.js} +2 -2
- package/dist/dark-mode-toggle.js +1 -1
- package/dist/dark.js +1 -1
- package/dist/dock.js +712 -486
- package/dist/dom.js +90 -8
- package/dist/easing.js +3 -3
- package/dist/expandable-container-BY1hQXi4.js +142 -0
- package/dist/expandable-container.js +2 -142
- package/dist/fourier-field.js +643 -855
- package/dist/fourier-math.js +6 -6
- package/dist/glass-ui.css +1 -1
- package/dist/glass-ui.js +85 -72
- package/dist/handmark.js +330 -718
- package/dist/index.d.ts +1 -1
- package/dist/labeled-field.js +2 -2
- package/dist/{menu-wLu1XGKn.js → menu-TDMNtZjG.js} +1 -1
- package/dist/menu.js +1 -1
- package/dist/motion-core.js +34 -34
- package/dist/{participation-B0hdsIRo.js → participation-Di4UHbzk.js} +8 -8
- package/dist/{pointerFieldMappings-DP5tla5z.js → pointerFieldMappings-DXwlU5uj.js} +7 -23
- package/dist/{popover-DBMKTPkL.js → popover-C04Rrdcz.js} +1 -1
- package/dist/popover.js +1 -1
- package/dist/{radio-group-Ci8o-pDx.js → radio-group-BNV7PN1O.js} +1 -1
- package/dist/radio-group.js +1 -1
- package/dist/{select-CDgwGH_P.js → select-COox45Kv.js} +1 -1
- package/dist/select.js +1 -1
- package/dist/{slider-gsc8jDIo.js → slider-5ChjjWSR.js} +1 -1
- package/dist/slider.js +1 -1
- package/dist/styles/components.css +1 -1
- package/dist/styles/glass/material.css +1 -1
- package/dist/styles/glass/overlay-plate.css +1 -1
- package/dist/{switch-DxZzDrmV.js → switch-lLkbREB-.js} +1 -1
- package/dist/switch.js +1 -1
- package/dist/{tabs-CYscnq5H.js → tabs-DSJMd1Et.js} +1 -1
- package/dist/tabs.js +1 -1
- package/dist/{toggle-group-11aPGMfE.js → toggle-group-DUcmKnDw.js} +1 -1
- package/dist/toggle-group.js +1 -1
- package/dist/{tooltip-DqKMZ4dn.js → tooltip-BKk2qVDn.js} +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/{resolveCanvasColor-6MCrswTB.js → useCanvas2D-CQRElMyE.js} +1 -11
- package/dist/useResolveTokenColor-B2FfJnd9.js +24 -0
- package/package.json +2 -20
- package/dist/canvas.d.ts +0 -1
- package/dist/canvas.js +0 -2
- package/dist/color.wgsl-B0N3mKMb.js +0 -412
- package/dist/compile-D7VYG3gi.js +0 -19
- package/dist/components/dock/composables/useDockOverflowFit.d.ts +0 -20
- package/dist/components/dock/composables/useDockTouchGate.d.ts +0 -42
- package/dist/components/dock/styles/overflow.css +0 -1
- package/dist/components/fourier-field/composables/fourierFieldGLSetup.d.ts +0 -24
- package/dist/components/fourier-field/composables/fourierFieldWGPUSetup.d.ts +0 -31
- package/dist/components/fourier-field/composables/uniformBridgeWGPU.d.ts +0 -39
- package/dist/components/fourier-field/composables/useFourierField.d.ts +0 -56
- package/dist/components/fourier-field/shaders/fourier-field.compute.wgsl.d.ts +0 -1
- package/dist/components/fourier-field/shaders/fourier-field.glsl.d.ts +0 -4
- package/dist/components/fourier-field/shaders/fourier-field.render.wgsl.d.ts +0 -1
- package/dist/components/fourier-field/shaders/fourier-field.ribbon.d.ts +0 -51
- package/dist/components/handmark/brush.d.ts +0 -269
- package/dist/components/handmark/composables/useHandMark.d.ts +0 -99
- package/dist/components/handmark/constants.d.ts +0 -69
- package/dist/components/handmark/freehand.d.ts +0 -69
- package/dist/components/handmark/geometry.d.ts +0 -62
- package/dist/components/handmark/ink.d.ts +0 -11
- package/dist/components/handmark/noise.d.ts +0 -30
- package/dist/components/handmark/texture.d.ts +0 -39
- package/dist/components/handmark/types.d.ts +0 -70
- package/dist/components/search/SearchBar.vue.d.ts +0 -38
- package/dist/components/search/index.d.ts +0 -8
- package/dist/components/search/searchVariants.d.ts +0 -16
- package/dist/configurator-BoeScnDL.js +0 -311
- package/dist/control-Da4XeT43.js +0 -11
- package/dist/search.d.ts +0 -1
- package/dist/search.js +0 -61
- package/dist/useFuzzySearch-CUnZknpm.js +0 -177
- package/dist/useResolveTokenColor-CspQv_ik.js +0 -107
- /package/dist/{components/search/composables → composables/search}/types.d.ts +0 -0
- /package/dist/{components/search/composables → composables/search}/useFuzzySearch.d.ts +0 -0
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { WebGPUCanvasFrame } from "../../../composables/glass/webgpu/useWebGPUCanvas.js";
|
|
2
|
-
import type { OklchStop } from "../../../composables/color/index.js";
|
|
3
|
-
import { type FourierFieldConfig } from "../constants.js";
|
|
4
|
-
import type { BasisComponent } from "../math.js";
|
|
5
|
-
export interface FourierWGPUSetupDeps {
|
|
6
|
-
canvas: HTMLCanvasElement;
|
|
7
|
-
config: FourierFieldConfig;
|
|
8
|
-
/** The CPU-minted spectrum (re-read each frame so a source-swap reaches the buffer). */
|
|
9
|
-
getSpectrum: () => readonly BasisComponent[];
|
|
10
|
-
/** The resolved (ColorResolver) palette stops as OKLCh — re-read each frame so a live edit reaches the buffer. */
|
|
11
|
-
getPalette: () => OklchStop[];
|
|
12
|
-
/** The single loop parameter `head_t ∈ [0,1)` (the ONE keyframes.js clock). */
|
|
13
|
-
getHeadT: () => number;
|
|
14
|
-
/** Demand-gate (the renderer's quiescence layer — substrate-agnostic). */
|
|
15
|
-
shouldContinue: () => boolean;
|
|
16
|
-
/** The per-frame pointer hook — useFourierField advances the shared pointer field here. */
|
|
17
|
-
onFrame?: (timeSec: number) => void;
|
|
18
|
-
/**
|
|
19
|
-
* D6b — the 2-D cursor FOLLOW: a small MODEL-space offset added to
|
|
20
|
-
* the view-fit center so the whole reconstruction LEANS toward the cursor (the spatial
|
|
21
|
-
* "follow" beside D6a's velocity scrub). Reuses the EXISTING uFit center uniform (NO new
|
|
22
|
-
* uniform, NO shader/bridge edit — parity-safe by construction, both arms read the same
|
|
23
|
-
* fit). `{x:0,y:0}` (the ambient/PRM register) is byte-identical to today.
|
|
24
|
-
*/
|
|
25
|
-
getPointerLean?: () => {
|
|
26
|
-
x: number;
|
|
27
|
-
y: number;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/** Build the fourier-field `setupWGPU(device, context, format)` callback. */
|
|
31
|
-
export declare function createFourierWGPUSetup(deps: FourierWGPUSetupDeps): (device: GPUDevice, context: GPUCanvasContext, format: GPUTextureFormat) => WebGPUCanvasFrame;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { OklchStop } from "../../../composables/color/index.js";
|
|
2
|
-
import { type BasisComponent } from "../math.js";
|
|
3
|
-
/** One phasor lane in the storage buffer: (re, im, index, _pad). */
|
|
4
|
-
export declare const FOURIER_PHASOR_BYTES = 16;
|
|
5
|
-
export interface FourierUniformScratch {
|
|
6
|
-
buffer: ArrayBuffer;
|
|
7
|
-
f32: Float32Array;
|
|
8
|
-
i32: Int32Array;
|
|
9
|
-
}
|
|
10
|
-
export declare function createFourierComputeScratch(): FourierUniformScratch;
|
|
11
|
-
/** Pack the compute uniforms in place. */
|
|
12
|
-
export declare function packFourierComputeUniforms(scratch: FourierUniformScratch, headT: number, trailArc: number, harmonicN: number, epicycleArmN: number, sampleCount: number, phasorCount: number): FourierUniformScratch;
|
|
13
|
-
export declare function createFourierRenderScratch(): FourierUniformScratch;
|
|
14
|
-
/** The model→clip fit transform (center + uniform scale) — computed once per spectrum. */
|
|
15
|
-
export interface FourierFit {
|
|
16
|
-
centerX: number;
|
|
17
|
-
centerY: number;
|
|
18
|
-
/** The uniform scale s such that (model − center)·s maps the curve into clip [-1,1] with margin. */
|
|
19
|
-
scale: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Stable view-fit: sample the FULL reconstruction once over the period, bound its bbox,
|
|
23
|
-
* and derive the center + a margin-padded uniform scale. The render's fullscreen pass
|
|
24
|
-
* inverts this transform per fragment so the curve never clips and the scale is fixed.
|
|
25
|
-
*/
|
|
26
|
-
export declare function computeFourierFit(spectrum: readonly BasisComponent[]): FourierFit;
|
|
27
|
-
/**
|
|
28
|
-
* Convert a CSS-px stroke width to MODEL units (the shader's space). The fit `scale` maps
|
|
29
|
-
* model → clip; clip spans [-1,1] over the min CSS dimension → cssPx-per-clip = canvasCssMin/2.
|
|
30
|
-
* model-per-cssPx = (1/scale)·(2/canvasCssMin).
|
|
31
|
-
*/
|
|
32
|
-
export declare function trailWidthToModel(trailWidthPx: number, scale: number, canvasCssMin: number): number;
|
|
33
|
-
/** Pack the render uniforms in place. */
|
|
34
|
-
export declare function packFourierRenderUniforms(scratch: FourierUniformScratch, fit: FourierFit, aspect: number, trailWidthModel: number, peakAlpha: number, headGlowAlpha: number, trailFadeExp: number, trailFloor: number, intensity: number, showEpicycles: boolean, rainbowChain: boolean, squashGain: number, celGain: number, edgeMargin: number, sampleCount: number, armCount: number, palette: OklchStop[]): FourierUniformScratch;
|
|
35
|
-
/**
|
|
36
|
-
* Pack the phasor storage table (re, im, index, _pad) from the CPU-minted spectrum. The
|
|
37
|
-
* WGSL SUMS this per frame — it is the ONLY spectrum upload (no WGSL-side mint).
|
|
38
|
-
*/
|
|
39
|
-
export declare function packPhasorTable(spectrum: readonly BasisComponent[]): Float32Array;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { type Ref } from "vue";
|
|
2
|
-
import { type GpuBackend, type RendererStatus } from "../../../composables/glass/webgpu/useGpuSubstrate.js";
|
|
3
|
-
import type { OklchStop } from "../../../composables/color/index.js";
|
|
4
|
-
import type { FourierFieldConfig } from "../constants.js";
|
|
5
|
-
import type { BasisComponent } from "../math.js";
|
|
6
|
-
export interface UseFourierFieldOptions {
|
|
7
|
-
config: FourierFieldConfig;
|
|
8
|
-
/** The active phasor spectrum (CPU-minted; re-read each frame so a source-swap reaches the buffer). */
|
|
9
|
-
getSpectrum: () => readonly BasisComponent[];
|
|
10
|
-
/** Resolve the curve-color palette as OKLCh (the demo themes it; default warm-identity). */
|
|
11
|
-
getPalette: () => OklchStop[];
|
|
12
|
-
/** When true, hold the deterministic best-frame and never advance (the capture, freeze lever). */
|
|
13
|
-
freeze?: () => boolean;
|
|
14
|
-
/** The static deterministic best-frame parameter under `freeze`/PRM. Default 0.34. */
|
|
15
|
-
frozenT?: number;
|
|
16
|
-
/** Base forward period for one full traversal at 1× speed, in seconds. Default 16. */
|
|
17
|
-
periodS?: number;
|
|
18
|
-
/** `"capture"` → renderAt-only (the deterministic π capture path). Default `"live"`. */
|
|
19
|
-
mode?: "live" | "capture";
|
|
20
|
-
/**
|
|
21
|
-
* the route pointer BROADCASTER read (the SUBTLE-interactive background
|
|
22
|
-
* register). A full-bleed `pointer-events:none` field cannot listen for its own pointer, so
|
|
23
|
-
* an ambient consumer reads the route-level `useRoutePointer` and feeds the shared field
|
|
24
|
-
* from here each frame (viewport-normalized ≈ host-normalized for a full-bleed field). The
|
|
25
|
-
* lean/bias then read on a background field WITHOUT the field owning a pointer listener.
|
|
26
|
-
* Omit for the studio (which binds its own host listeners).
|
|
27
|
-
*/
|
|
28
|
-
routePointer?: () => {
|
|
29
|
-
x: number;
|
|
30
|
-
y: number;
|
|
31
|
-
active: boolean;
|
|
32
|
-
} | null;
|
|
33
|
-
}
|
|
34
|
-
/** The uniform handle a consumer wires its lifecycle against (backend-agnostic). */
|
|
35
|
-
export interface FourierFieldHandle {
|
|
36
|
-
/** The resolved backend (`"webgpu"` where supported, else the WebGL2 GLSL fallback). */
|
|
37
|
-
readonly backend: GpuBackend;
|
|
38
|
-
/** Park the loop (the WCAG-2.2.2 pause seam — `DockBackgroundToggle` wires this). */
|
|
39
|
-
pause: () => void;
|
|
40
|
-
/** Re-arm the loop. */
|
|
41
|
-
resume: () => void;
|
|
42
|
-
/** Re-arm a parked loop on demand. */
|
|
43
|
-
wake: () => void;
|
|
44
|
-
/** Draw one frame out-of-loop (capture, thumbnail). */
|
|
45
|
-
renderAt: (timeSec: number) => void;
|
|
46
|
-
/** The live `prefers-reduced-motion: reduce` state. */
|
|
47
|
-
readonly reducedMotion: boolean;
|
|
48
|
-
/** The current loop parameter `head_t ∈ [0,1)` (the scrubber reads/writes it). */
|
|
49
|
-
readonly headT: number;
|
|
50
|
-
readonly rendererStatus: Readonly<Ref<RendererStatus>>;
|
|
51
|
-
/** Scrub the clock directly (the transport scrubber, a pointer drag). */
|
|
52
|
-
setHeadT: (t: number) => void;
|
|
53
|
-
/** Tear down the renderer + release GPU/GL resources. */
|
|
54
|
-
dispose: () => void;
|
|
55
|
-
}
|
|
56
|
-
export declare function useFourierField(canvasRef: Ref<HTMLCanvasElement | null>, options: UseFourierFieldOptions): FourierFieldHandle;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const FOURIER_FIELD_COMPUTE_WGSL = "\nconst MAX_PHASORS: i32 = 64;\nconst TAU: f32 = 6.283185307179586;\n\nstruct Phasor {\n // (re, im, index, _pad)\n data: vec4<f32>,\n};\n\n// \u2500\u2500 Compute uniforms (the typed-struct source-of-truth \u2014 see uniformBridgeWGPU.ts) \u2500\u2500\nstruct ComputeUniforms {\n // c0: (headT, trailArc, _pad, _pad)\n c0: vec4<f32>,\n // ints: (harmonicN, epicycleArmN, sampleCount, phasorCount)\n ints: vec4<i32>,\n};\n\n@group(0) @binding(0) var<uniform> u: ComputeUniforms;\n@group(0) @binding(1) var<storage, read> phasors: array<Phasor>;\n// curveSamples[i] = (x, y, age, _pad)\n@group(0) @binding(2) var<storage, read_write> curveSamples: array<vec4<f32>>;\n// chainTips[k] = (x, y, _pad, _pad) \u2014 the running tip after stacking phasor k\n@group(0) @binding(3) var<storage, read_write> chainTips: array<vec4<f32>>;\n\n// The PARTIAL-SUM curve point at parameter t over the first n phasors \u2014 the WGSL\n// transcription of math.ts:78-95 (partialSumAt). EXACTLY:\n// c += vec2(re\u00B7cos \u2212 im\u00B7sin, re\u00B7sin + im\u00B7cos) with angle = TAU\u00B7index\u00B7t.\nfn partialSumAt(t: f32, n: i32) -> vec2<f32> {\n var c = vec2<f32>(0.0, 0.0);\n let phasorCount = u.ints.w;\n let lim = min(n, phasorCount);\n for (var i = 0; i < MAX_PHASORS; i = i + 1) {\n if (i >= lim) { break; }\n let p = phasors[i].data;\n let re = p.x;\n let im = p.y;\n let index = p.z;\n let angle = TAU * index * t;\n let cs = cos(angle);\n let sn = sin(angle);\n c = c + vec2<f32>(re * cs - im * sn, re * sn + im * cs);\n }\n return c;\n}\n\n// The epicycle chain tip after stacking the first k phasors at head_t \u2014 the WGSL\n// transcription of math.ts:41-60 (positionsAt, read at the running tip). The running tip\n// after phasor (k\u22121) is exactly the partial sum over the first k terms.\nfn epicycleChainTip(t: f32, k: i32) -> vec2<f32> {\n return partialSumAt(t, k);\n}\n\n@compute @workgroup_size(64)\nfn cs_main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let i = i32(gid.x);\n let headT = u.c0.x;\n let trailArc = u.c0.y;\n let harmonicN = u.ints.x;\n let armN = u.ints.y;\n let sampleCount = u.ints.z;\n\n // \u2500\u2500 The comet body samples \u2500\u2500\n if (i < sampleCount) {\n // age: 0 at the oldest tail (i = sampleCount\u22121), 1 at the head (i = 0).\n let denom = max(f32(sampleCount - 1), 1.0);\n let frac = f32(i) / denom; // 0 = head, 1 = tail\n let age = 1.0 - frac; // 1 = head, 0 = tail\n // sample back along the period from the head by trailArc.\n var t = headT - trailArc * frac;\n t = t - floor(t); // fract \u2192 [0,1)\n let pt = partialSumAt(t, harmonicN);\n curveSamples[i] = vec4<f32>(pt.x, pt.y, age, 0.0);\n }\n\n // \u2500\u2500 The epicycle chain tips (k = 0..armN, capped to harmonicN) \u2500\u2500\n // chainTips[0] is the origin; chainTips[k] is the tip after phasor (k\u22121).\n let armLim = min(armN, harmonicN);\n if (i <= armLim && i <= MAX_PHASORS) {\n let tip = epicycleChainTip(headT, i);\n chainTips[i] = vec4<f32>(tip.x, tip.y, 0.0, 0.0);\n }\n}\n";
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/** The instanced ribbon VERTEX — expands the unit quad to each instance's covered bbox. */
|
|
2
|
-
export declare const FOURIER_FIELD_VERT_GLSL = "#version 300 es\n// Must equal the WGSL twin and FOURIER_TANGENT_EPS in constants.ts.\n#define RIBBON_UNDERGLOW_SCALE 2.2\n\nin vec2 aCorner; // the unit quad corner \u2208 [0,1]\u00B2\nin vec4 aSeg; // (ax, ay, bx, by) \u2014 segment endpoints in MODEL space\nin vec4 aData; // (age, strokeHalf, arg2, _pad) \u2014 strokeHalf/age/arg2 per layer\n\nuniform vec4 uFit; // (centerX, centerY, scale, aspect) \u2014 model\u2192clip fit\nuniform int uLayer; // 0 trail \u00B7 1 epicycle \u00B7 2 head \u00B7 3 cel-rope \u00B7 4 cel-arm\nuniform float uEdgeMargin; // AA-feather slop in MODEL units (a few CSS px), padding the bbox\n\nout vec2 vP; // the MODEL-space fragment coordinate (the fs runs the SDF on it)\nout vec2 vA;\nout vec2 vB;\nout float vAge;\nout float vHalf;\nout float vArg2;\n\nvoid main() {\n vec2 a = aSeg.xy;\n vec2 b = aSeg.zw;\n float strokeHalf = aData.y;\n vA = a; vB = b; vAge = aData.x; vHalf = strokeHalf; vArg2 = aData.z;\n\n vec2 pos;\n if (uLayer == 1 || uLayer == 2) {\n // AABB around a \u2014 the epicycle orbit RING (radius = |b-a|) or the head HALO.\n float ext = (uLayer == 1) ? (length(b - a) + strokeHalf * 0.7) : (strokeHalf * 4.5);\n ext += uEdgeMargin;\n pos = a + (aCorner * 2.0 - 1.0) * ext;\n } else {\n // Capsule along a\u2192b padded by the covered extent (trail under-glow, cel stroke).\n float ext = (uLayer == 0) ? (strokeHalf * RIBBON_UNDERGLOW_SCALE) : strokeHalf;\n ext += uEdgeMargin;\n vec2 d = b - a;\n float len = length(d);\n vec2 dir = len > 1e-6 ? d / len : vec2(1.0, 0.0);\n vec2 perp = vec2(-dir.y, dir.x);\n vec2 along = mix(a - dir * ext, b + dir * ext, aCorner.x);\n pos = along + perp * (aCorner.y * 2.0 - 1.0) * ext;\n }\n\n vP = pos;\n vec2 center = uFit.xy;\n float scale = max(uFit.z, 1e-6);\n float aspect = max(uFit.w, 1e-4);\n // model \u2192 clip (the inverse of the fs's p = center + vClip\u00B7aspect, scale).\n float clipX = (pos.x - center.x) * scale / aspect;\n float clipY = (pos.y - center.y) * scale;\n gl_Position = vec4(clipX, clipY, 0.0, 1.0);\n}\n";
|
|
3
|
-
/** The instanced ribbon FRAGMENT — the exact per-layer SDF over-composite, loop-free. */
|
|
4
|
-
export declare const FOURIER_FIELD_FRAG_GLSL = "#version 300 es\nprecision highp float;\n\n#define MAX_FOURIER_STOPS 4\n// Must equal the WGSL twin and FOURIER_TANGENT_EPS in constants.ts.\n#define TANGENT_EPS 1e-4\n#define SPEED_REF_HALFWIDTHS 6.0\n// The thick luminous ribbon mirrors RIBBON_TAIL_FRAC verbatim\n// from constants.ts because the GLSL twin cannot import a TS const; parity coverage verifies the\n// two copies are equal so the mid-body floor (RIBBON_HEAD_FLOOR_PX) can never drift off it.\n#define RIBBON_TAIL_FRAC 0.4\n#define RIBBON_UNDERGLOW_SCALE 2.2\n#define RIBBON_UNDERGLOW_ALPHA 0.16\n\nin vec2 vP;\nin vec2 vA;\nin vec2 vB;\nin float vAge;\nin float vHalf;\nin float vArg2;\nout vec4 fragColor;\n\nuniform vec4 uTrail; // (trailWidth, peakAlpha, headGlowAlpha, trailFadeExp)\nuniform vec4 uEnv; // (trailFloor, intensity, showEpicycles, rainbowChain)\nuniform vec4 uLoom; // (squashGain, celGain, _pad, _pad) \u2014 FOURIER-LOOM \u00A72b/\u00A73b\nuniform int uLayer; // 0 trail \u00B7 1 epicycle \u00B7 2 head \u00B7 3 cel-rope \u00B7 4 cel-arm\nuniform int uStopCount;\nuniform vec3 uPalette[MAX_FOURIER_STOPS]; // linear-sRGB stops\n\nconst float PI = 3.141592653589793;\n\n\nfloat srgbToLinearCh(float c) {\n return c <= 0.04045 ? c / 12.92 : pow((c + 0.055) / 1.055, 2.4);\n}\nvec3 srgbToLinear(vec3 c) {\n return vec3(srgbToLinearCh(c.r), srgbToLinearCh(c.g), srgbToLinearCh(c.b));\n}\n\nfloat linearToSrgbCh(float c) {\n return c <= 0.0031308 ? c * 12.92 : 1.055 * pow(c, 1.0 / 2.4) - 0.055;\n}\nvec3 linearToSrgb(vec3 c) {\n return vec3(linearToSrgbCh(c.r), linearToSrgbCh(c.g), linearToSrgbCh(c.b));\n}\n\n// value.js LINEAR_SRGB_TO_LMS (constants.ts), row-major; written here as GLSL\n// columns (= the transpose) so mat3 * vec3 evaluates the row-major M\u00B7v.\nconst mat3 LINEAR_SRGB_TO_LMS = mat3(\n 0.4122214708, 0.2119034982, 0.0883024619,\n 0.5363325363, 0.6806995451, 0.2817188376,\n 0.0514459929, 0.1073969566, 0.6299787005\n);\n\n// value.js srgbToOKLab's INLINE LMS\u2192OKLab coefficients (gamut.ts lines 295-297 \u2014\n// these differ at the ~1e-9 digit from LMS_TO_OKLAB_MATRIX; use the inline ones to\n// mirror the exact value.js path), row-major \u2192 GLSL columns.\nconst mat3 LMS_TO_OKLAB = mat3(\n 0.2104542553, 1.9779984951, 0.0259040371,\n 0.7936177850, -2.4285922050, 0.7827717662,\n -0.0040720468, 0.4505937099, -0.8086757660\n);\n\n// value.js OKLAB_TO_LMS_COEFF (constants.ts), row-major \u2192 GLSL columns. Rows:\n// l = [1, 0.3963377774, 0.2158037573], m = [1, -0.1055613458, -0.0638541728],\n// s = [1, -0.0894841775, -1.2914855480].\nconst mat3 OKLAB_TO_LMS = mat3(\n 1.0, 1.0, 1.0,\n 0.3963377774, -0.1055613458, -0.0894841775,\n 0.2158037573, -0.0638541728, -1.2914855480\n);\n\n// value.js LMS_TO_LINEAR_SRGB (constants.ts), row-major \u2192 GLSL columns.\nconst mat3 LMS_TO_LINEAR_SRGB = mat3(\n 4.0767416621, -1.2684380046, -0.0041960863,\n -3.3077115913, 2.6097574011, -0.7034186147,\n 0.2309699292, -0.3413193965, 1.7076147010\n);\n\n// Gamma sRGB \u2192 raw OKLab (L, a, b). Mirrors value.js srgbToOKLab.\nvec3 srgbToOklab(vec3 c) {\n vec3 lin = srgbToLinear(c);\n vec3 lms = LINEAR_SRGB_TO_LMS * lin;\n vec3 lmsCbrt = sign(lms) * pow(abs(lms), vec3(1.0 / 3.0));\n return LMS_TO_OKLAB * lmsCbrt;\n}\n\n// Raw OKLab (L, a, b) \u2192 linear sRGB. Mirrors value.js oklabToLinearSRGB.\nvec3 oklabToLinearSrgb(vec3 lab) {\n vec3 lms_ = OKLAB_TO_LMS * lab;\n vec3 lms = lms_ * lms_ * lms_;\n return LMS_TO_LINEAR_SRGB * lms;\n}\n\n// OKLab \u2192 OKLCh: H in RADIANS. Mirrors value.js rawOklabToOklch (which returns\n// degrees; we stay in radians and only fold to [0, 2pi)).\nvec3 oklabToOklch(vec3 lab) {\n float C = length(lab.yz);\n float H = atan(lab.z, lab.y);\n if (H < 0.0) H += 2.0 * PI;\n return vec3(lab.x, C, H);\n}\n\n// OKLCh (H radians) \u2192 OKLab. Mirrors value.js rawOklchToOklab.\nvec3 oklchToOklab(vec3 lch) {\n return vec3(lch.x, lch.y * cos(lch.z), lch.y * sin(lch.z));\n}\n\n// Negative-safe cube root (the WGSL chunk's cbrt3 twin; the GLSL chunk inlines it).\nvec3 cbrt3(vec3 v) { return sign(v) * pow(abs(v), vec3(1.0 / 3.0)); }\n\nvec3 samplePaletteLin(float t) {\n if (uStopCount <= 1) return uPalette[0];\n float n = float(uStopCount);\n float ft = clamp(t, 0.0, 1.0) * (n - 1.0);\n int i0 = int(floor(ft));\n int i1 = min(i0 + 1, uStopCount - 1);\n float f = ft - float(i0);\n vec3 labA = LMS_TO_OKLAB * cbrt3(LINEAR_SRGB_TO_LMS * uPalette[i0]);\n vec3 labB = LMS_TO_OKLAB * cbrt3(LINEAR_SRGB_TO_LMS * uPalette[i1]);\n return oklabToLinearSrgb(mix(labA, labB, f));\n}\n\nvec3 chainColorLin(float seg, bool rainbow) {\n vec3 baseLin = uPalette[0];\n if (!rainbow) return baseLin;\n vec3 lab = LMS_TO_OKLAB * cbrt3(LINEAR_SRGB_TO_LMS * baseLin);\n vec3 lch = oklabToOklch(lab);\n float hueShift = mix(-0.45, 1.15, clamp(seg, 0.0, 1.0));\n vec3 lifted = vec3(0.66, max(lch.y, 0.14), lch.z + hueShift);\n return oklabToLinearSrgb(oklchToOklab(lifted));\n}\n\nfloat segDist(vec2 p, vec2 a, vec2 b) {\n vec2 pa = p - a;\n vec2 ba = b - a;\n float h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-8), 0.0, 1.0);\n return length(pa - ba * h);\n}\n\n// The head travel frame (T, \u015D), the GLSL twin of the WGSL headFrame.\nstruct HeadFrame { vec2 T; float sHat; };\nHeadFrame headFrame(vec2 head, vec2 headBack, float halfW) {\n vec2 d = head - headBack;\n float s = length(d);\n HeadFrame fr;\n if (s <= TANGENT_EPS) { fr.T = vec2(1.0, 0.0); fr.sHat = 0.0; return fr; }\n fr.T = d / s;\n float refScale = max(halfW * SPEED_REF_HALFWIDTHS, 1e-6);\n fr.sHat = clamp(s / refScale, 0.0, 1.0);\n return fr;\n}\n\n// The volume-preserving anisotropic head distance (the WGSL headAniso twin).\nfloat headAniso(vec2 p, vec2 head, HeadFrame fr, float k) {\n float g = 1.0 + k * fr.sHat;\n vec2 n = vec2(-fr.T.y, fr.T.x);\n vec2 rel = p - head;\n float along = dot(rel, fr.T) / g;\n float across = dot(rel, n) * g;\n return length(vec2(along, across));\n}\n\nvoid main() {\n vec2 p = vP;\n float aa = max(fwidth(p.x) + fwidth(p.y), 1e-5) * 0.75;\n float peak = uTrail.y * uEnv.y;\n float headGlow = uTrail.z * uEnv.y;\n float fadeExp = uTrail.w;\n float trailFloor = uEnv.x;\n bool rainbow = uEnv.w > 0.5;\n float squashGain = uLoom.x;\n float celGain = uLoom.y;\n float halfW = vHalf;\n\n if (uLayer == 0) {\n // \u2500\u2500 TRAIL \u2014 the tapered luminous ribbon over its own soft under-glow \u2500\u2500\n float age = vAge;\n float d = segDist(p, vA, vB);\n // Head\u2192tail taper: the ribbon half-width scales with age (thick head, thin tail).\n float ribbonHalf = halfW * (RIBBON_TAIL_FRAC + (1.0 - RIBBON_TAIL_FRAC) * age);\n vec3 lin = samplePaletteLin(1.0 - age * 0.4);\n vec3 rgb = clamp(linearToSrgb(lin), vec3(0.0), vec3(1.0));\n // Soft under-glow: a wider, low-alpha copy under the crisp ribbon (one color event).\n float glowHalf = ribbonHalf * RIBBON_UNDERGLOW_SCALE;\n float glowCover = 1.0 - smoothstep(glowHalf, glowHalf + aa * 3.0, d);\n float ga = peak * RIBBON_UNDERGLOW_ALPHA * pow(age, fadeExp) * glowCover;\n // The crisp tapered ribbon core.\n float cover = 1.0 - smoothstep(ribbonHalf, ribbonHalf + aa, d);\n float ca = max(peak * pow(age, fadeExp), peak * trailFloor) * cover;\n // core OVER glow OVER transparent (both premultiplied on the SAME rgb \u2192 out = rgb\u00B7outA).\n float outA = ca + ga * (1.0 - ca);\n fragColor = vec4(rgb * outA, outA);\n } else if (uLayer == 1) {\n // \u2500\u2500 EPICYCLE \u2014 orbit RING + ARM + joint DOT union (MAX-blended, no join seam) \u2500\u2500\n float seg = vArg2;\n vec3 lin = chainColorLin(seg, rainbow);\n vec3 rgb = clamp(linearToSrgb(lin), vec3(0.0), vec3(1.0));\n float radius = length(vB - vA);\n float dRing = abs(length(p - vA) - radius);\n float ringW = max(halfW * 0.45, aa);\n float ringMask = (1.0 - smoothstep(ringW, ringW + aa, dRing)) * 0.5;\n float dArm = segDist(p, vA, vB);\n float armMask = 1.0 - smoothstep(halfW * 0.55, halfW * 0.55 + aa, dArm);\n float dotR = max(halfW * 0.7, aa * 2.0);\n float dDot = length(p - vA);\n float dotMask = 1.0 - smoothstep(dotR, dotR + aa, dDot);\n float m = clamp(max(max(ringMask, armMask), dotMask), 0.0, 1.0) * peak * 0.7;\n fragColor = vec4(rgb * m, m);\n } else if (uLayer == 2) {\n // \u2500\u2500 HEAD \u2014 squash-and-stretch (\u00A72b): halo + saturated core + white specular \u2500\u2500\n vec2 head = vA;\n vec2 headBack = vB;\n HeadFrame fr = headFrame(head, headBack, halfW);\n float dHead = headAniso(p, head, fr, squashGain);\n float coreR = halfW * 1.5;\n float haloR = coreR * 3.0;\n vec3 headRgb = clamp(linearToSrgb(samplePaletteLin(0.0)), vec3(0.0), vec3(1.0));\n float halo = (1.0 - smoothstep(0.0, haloR, dHead)) * headGlow * 0.35;\n vec4 accum = vec4(headRgb * halo, halo);\n float core = (1.0 - smoothstep(coreR, coreR + aa, dHead)) * headGlow;\n accum = vec4(headRgb * core, core) + accum * (1.0 - core);\n float spec = (1.0 - smoothstep(coreR * 0.4, coreR * 0.4 + aa, dHead)) * headGlow * 0.9;\n accum = vec4(vec3(1.0) * spec, spec) + accum * (1.0 - spec);\n fragColor = accum;\n } else {\n // \u2500\u2500 CEL \u2014 the technicolor ink shadow (rope uLayer==3, arm uLayer==4) \u2500\u2500\n float celA = clamp(celGain, 0.0, 1.0);\n float d = segDist(p, vA, vB);\n float cover = 1.0 - smoothstep(halfW, halfW + aa, d);\n float m = cover * celA * peak * vArg2; // vArg2 = celStrength (1.0 rope / 0.7 arm)\n fragColor = vec4(0.0, 0.0, 0.0, m);\n }\n}\n";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const FOURIER_FIELD_RENDER_WGSL = "\n// The instanced-ribbon LAYER selector (a pipeline-overridable constant \u2014 5 pipelines share the\n// ONE module, each specializing this): 0 trail \u00B7 1 epicycle \u00B7 2 head \u00B7 3 cel-rope \u00B7 4 cel-arm.\noverride LAYER: i32 = 0;\n\nconst PI: f32 = 3.141592653589793;\n// The degenerate-tangent guard must equal FOURIER_TANGENT_EPS in\n// constants.ts and the GL CPU bead path so a cusp resolves identically across both engines.\nconst TANGENT_EPS: f32 = 1e-4;\nconst SPEED_REF_HALFWIDTHS: f32 = 6.0;\n// The thick luminous ribbon mirrors RIBBON_TAIL_FRAC verbatim\n// from constants.ts because the WGSL twin cannot import a TS const; parity coverage verifies the\n// two copies are equal so the mid-body floor (RIBBON_HEAD_FLOOR_PX) can never drift off it.\nconst RIBBON_TAIL_FRAC: f32 = 0.4;\nconst RIBBON_UNDERGLOW_SCALE: f32 = 2.2;\nconst RIBBON_UNDERGLOW_ALPHA: f32 = 0.16;\n\n// \u2500\u2500 Render uniforms (the typed-struct source-of-truth \u2014 see uniformBridgeWGPU.ts) \u2500\u2500\nstruct RenderUniforms {\n // r0: (centerX, centerY, scale, aspect) \u2014 model\u2192clip fit transform\n r0: vec4<f32>,\n // r1: (trailWidth, peakAlpha, headGlowAlpha, trailFadeExp)\n r1: vec4<f32>,\n // r2: (trailFloor, intensity, showEpicycles, rainbowChain)\n r2: vec4<f32>,\n // r3: (squashGain, celGain, edgeMargin, _pad) \u2014 FOURIER-LOOM \u00A72b/\u00A73b + the ribbon bbox slop\n r3: vec4<f32>,\n // ints: (sampleCount, armCount, stopCount, _pad)\n ints: vec4<i32>,\n // palette stops: linear-sRGB rgb + _pad\n palette: array<vec4<f32>, 4>,\n};\n\n@group(0) @binding(0) var<uniform> u: RenderUniforms;\n// curveSamples[i] = (x, y, age, _pad) in MODEL space \u2014 the render VERTEX-PULLS these.\n@group(0) @binding(1) var<storage, read> curveSamples: array<vec4<f32>>;\n// chainTips[k] = (x, y, _pad, _pad) in MODEL space.\n@group(0) @binding(2) var<storage, read> chainTips: array<vec4<f32>>;\n\n\nfn srgbToLinearCh(c: f32) -> f32 {\n if (c <= 0.04045) { return c / 12.92; }\n return pow((c + 0.055) / 1.055, 2.4);\n}\nfn srgbToLinear(c: vec3<f32>) -> vec3<f32> {\n return vec3<f32>(srgbToLinearCh(c.r), srgbToLinearCh(c.g), srgbToLinearCh(c.b));\n}\n\nfn linearToSrgbCh(c: f32) -> f32 {\n if (c <= 0.0031308) { return c * 12.92; }\n return 1.055 * pow(c, 1.0 / 2.4) - 0.055;\n}\nfn linearToSrgb(c: vec3<f32>) -> vec3<f32> {\n return vec3<f32>(linearToSrgbCh(c.r), linearToSrgbCh(c.g), linearToSrgbCh(c.b));\n}\n\n// value.js LINEAR_SRGB_TO_LMS, row-major \u2192 WGSL columns (= the transpose).\nconst LINEAR_SRGB_TO_LMS: mat3x3<f32> = mat3x3<f32>(\n 0.4122214708, 0.2119034982, 0.0883024619,\n 0.5363325363, 0.6806995451, 0.2817188376,\n 0.0514459929, 0.1073969566, 0.6299787005\n);\n\n// value.js srgbToOKLab's INLINE LMS\u2192OKLab coefficients, row-major \u2192 WGSL columns.\nconst LMS_TO_OKLAB: mat3x3<f32> = mat3x3<f32>(\n 0.2104542553, 1.9779984951, 0.0259040371,\n 0.7936177850, -2.4285922050, 0.7827717662,\n -0.0040720468, 0.4505937099, -0.8086757660\n);\n\n// value.js OKLAB_TO_LMS_COEFF, row-major \u2192 WGSL columns.\nconst OKLAB_TO_LMS: mat3x3<f32> = mat3x3<f32>(\n 1.0, 1.0, 1.0,\n 0.3963377774, -0.1055613458, -0.0894841775,\n 0.2158037573, -0.0638541728, -1.2914855480\n);\n\n// value.js LMS_TO_LINEAR_SRGB, row-major \u2192 WGSL columns.\nconst LMS_TO_LINEAR_SRGB: mat3x3<f32> = mat3x3<f32>(\n 4.0767416621, -1.2684380046, -0.0041960863,\n -3.3077115913, 2.6097574011, -0.7034186147,\n 0.2309699292, -0.3413193965, 1.7076147010\n);\n\nfn cbrt3(v: vec3<f32>) -> vec3<f32> {\n return sign(v) * pow(abs(v), vec3<f32>(1.0 / 3.0));\n}\n\n// Gamma sRGB \u2192 raw OKLab (L, a, b). Mirrors value.js srgbToOKLab.\nfn srgbToOklab(c: vec3<f32>) -> vec3<f32> {\n let lin = srgbToLinear(c);\n let lms = LINEAR_SRGB_TO_LMS * lin;\n return LMS_TO_OKLAB * cbrt3(lms);\n}\n\n// Raw OKLab (L, a, b) \u2192 linear sRGB. Mirrors value.js oklabToLinearSRGB.\nfn oklabToLinearSrgb(lab: vec3<f32>) -> vec3<f32> {\n let lms_ = OKLAB_TO_LMS * lab;\n let lms = lms_ * lms_ * lms_;\n return LMS_TO_LINEAR_SRGB * lms;\n}\n\n// OKLab \u2192 OKLCh: H in RADIANS, folded to [0, 2pi). Mirrors value.js rawOklabToOklch.\nfn oklabToOklch(lab: vec3<f32>) -> vec3<f32> {\n let C = length(lab.yz);\n var H = atan2(lab.z, lab.y);\n if (H < 0.0) { H = H + 2.0 * PI; }\n return vec3<f32>(lab.x, C, H);\n}\n\n// OKLCh (H radians) \u2192 OKLab. Mirrors value.js rawOklchToOklab.\nfn oklchToOklab(lch: vec3<f32>) -> vec3<f32> {\n return vec3<f32>(lch.x, lch.y * cos(lch.z), lch.y * sin(lch.z));\n}\n\nfn samplePaletteLin(t: f32) -> vec3<f32> {\n let stopCount = u.ints.z;\n if (stopCount <= 1) { return u.palette[0].rgb; }\n let n = f32(stopCount);\n let ft = clamp(t, 0.0, 1.0) * (n - 1.0);\n let i0 = i32(floor(ft));\n let i1 = min(i0 + 1, stopCount - 1);\n let f = ft - f32(i0);\n let labA = LMS_TO_OKLAB * cbrt3(LINEAR_SRGB_TO_LMS * u.palette[i0].rgb);\n let labB = LMS_TO_OKLAB * cbrt3(LINEAR_SRGB_TO_LMS * u.palette[i1].rgb);\n return oklabToLinearSrgb(mix(labA, labB, f));\n}\n\nfn chainColorLin(seg: f32, rainbow: bool) -> vec3<f32> {\n let baseLin = u.palette[0].rgb;\n if (!rainbow) { return baseLin; }\n let lab = LMS_TO_OKLAB * cbrt3(LINEAR_SRGB_TO_LMS * baseLin);\n let lch = oklabToOklch(lab);\n let hueShift = mix(-0.45, 1.15, clamp(seg, 0.0, 1.0));\n let h = lch.z + hueShift;\n let lifted = vec3<f32>(0.66, max(lch.y, 0.14), h);\n return oklabToLinearSrgb(oklchToOklab(lifted));\n}\n\nfn segDist(p: vec2<f32>, a: vec2<f32>, b: vec2<f32>) -> f32 {\n let pa = p - a;\n let ba = b - a;\n let h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-8), 0.0, 1.0);\n return length(pa - ba * h);\n}\n\n// The head travel frame + the volume-preserving anisotropic distance.\nstruct HeadFrame { T: vec2<f32>, sHat: f32, };\nfn headFrame(head: vec2<f32>, headBack: vec2<f32>, halfW: f32) -> HeadFrame {\n let d = head - headBack;\n let s = length(d);\n var out: HeadFrame;\n if (s <= TANGENT_EPS) {\n out.T = vec2<f32>(1.0, 0.0);\n out.sHat = 0.0;\n return out;\n }\n out.T = d / s;\n let refScale = max(halfW * SPEED_REF_HALFWIDTHS, 1e-6);\n out.sHat = clamp(s / refScale, 0.0, 1.0);\n return out;\n}\n\nfn headAniso(p: vec2<f32>, head: vec2<f32>, fr: HeadFrame, k: f32) -> f32 {\n let g = 1.0 + k * fr.sHat;\n let n = vec2<f32>(-fr.T.y, fr.T.x);\n let rel = p - head;\n let along = dot(rel, fr.T) / g;\n let across = dot(rel, n) * g;\n return length(vec2<f32>(along, across));\n}\n\n// The cel ink lags behind the travel \u2014 the SAME \u2212T\u00B7halfW\u00B71.4 offset both engines apply (the\n// head frame is read straight off the compute-filled curveSamples[0]/[1], parity by construction).\nfn celOffset(halfW: f32) -> vec2<f32> {\n let fr = headFrame(curveSamples[0].xy, curveSamples[1].xy, halfW);\n return -fr.T * halfW * 1.4;\n}\n\n// The unit quad as two triangles (6 verts) in [0,1]\u00B2 \u2014 the instanced vertex expands it.\nfn quadCorner(vi: u32) -> vec2<f32> {\n var c = array<vec2<f32>, 6>(\n vec2<f32>(0.0, 0.0), vec2<f32>(1.0, 0.0), vec2<f32>(0.0, 1.0),\n vec2<f32>(0.0, 1.0), vec2<f32>(1.0, 0.0), vec2<f32>(1.0, 1.0),\n );\n return c[vi];\n}\n\nstruct VSOut {\n @builtin(position) pos: vec4<f32>,\n @location(0) p: vec2<f32>, // model-space fragment coordinate\n @location(1) a: vec2<f32>,\n @location(2) b: vec2<f32>,\n @location(3) segData: vec3<f32>, // (age, strokeHalf, arg2)\n};\n\n@vertex\nfn vs_main(@builtin(vertex_index) vi: u32, @builtin(instance_index) inst: u32) -> VSOut {\n let corner = quadCorner(vi);\n let center = u.r0.xy;\n let scale = max(u.r0.z, 1e-6);\n let aspect = max(u.r0.w, 1e-4);\n let halfW = u.r1.x * 0.5;\n let margin = u.r3.z;\n\n var a: vec2<f32> = vec2<f32>(0.0);\n var b: vec2<f32> = vec2<f32>(0.0);\n var strokeHalf: f32 = halfW;\n var age: f32 = 0.0;\n var arg2: f32 = 0.0;\n var isCapsule: bool = true;\n var ext: f32 = halfW;\n\n if (LAYER == 0) {\n // TRAIL \u2014 the curve capsule; the covered extent is the head-width under-glow.\n a = curveSamples[inst].xy;\n b = curveSamples[inst + 1u].xy;\n age = max(curveSamples[inst].z, curveSamples[inst + 1u].z);\n ext = halfW * RIBBON_UNDERGLOW_SCALE;\n isCapsule = true;\n } else if (LAYER == 1) {\n // EPICYCLE \u2014 the chain AABB around a (radius = |b\u2212a|).\n a = chainTips[inst].xy;\n b = chainTips[inst + 1u].xy;\n arg2 = f32(inst) / max(f32(u.ints.y - 1), 1.0);\n ext = length(b - a) + halfW * 0.7;\n isCapsule = false;\n } else if (LAYER == 2) {\n // HEAD \u2014 the comet head at curveSamples[0], AABB by the halo radius.\n a = curveSamples[0].xy;\n b = curveSamples[1].xy;\n ext = halfW * 4.5;\n isCapsule = false;\n } else if (LAYER == 3) {\n // CEL-ROPE \u2014 the curve capsule, offset opposite travel; full-width ink.\n let off = celOffset(halfW);\n a = curveSamples[inst].xy + off;\n b = curveSamples[inst + 1u].xy + off;\n arg2 = 1.0;\n ext = halfW;\n isCapsule = true;\n } else {\n // CEL-ARM (LAYER == 4) \u2014 the chain capsule, offset; the narrower arm ink (0.55\u00B7halfW).\n let off = celOffset(halfW);\n a = chainTips[inst].xy + off;\n b = chainTips[inst + 1u].xy + off;\n strokeHalf = halfW * 0.55;\n arg2 = 0.7;\n ext = halfW * 0.55;\n isCapsule = true;\n }\n ext = ext + margin;\n\n var pos: vec2<f32>;\n if (isCapsule) {\n let d = b - a;\n let len = length(d);\n var dir = vec2<f32>(1.0, 0.0);\n if (len > 1e-6) { dir = d / len; }\n let perp = vec2<f32>(-dir.y, dir.x);\n let along = mix(a - dir * ext, b + dir * ext, corner.x);\n pos = along + perp * (corner.y * 2.0 - 1.0) * ext;\n } else {\n pos = a + (corner * 2.0 - vec2<f32>(1.0)) * ext;\n }\n\n let clipX = (pos.x - center.x) * scale / aspect;\n let clipY = (pos.y - center.y) * scale;\n var out: VSOut;\n out.pos = vec4<f32>(clipX, clipY, 0.0, 1.0);\n out.p = pos;\n out.a = a;\n out.b = b;\n out.segData = vec3<f32>(age, strokeHalf, arg2);\n return out;\n}\n\n@fragment\nfn fs_main(in: VSOut) -> @location(0) vec4<f32> {\n let p = in.p;\n let aa = max(fwidth(p.x) + fwidth(p.y), 1e-5) * 0.75;\n let peak = u.r1.y * u.r2.y;\n let headGlow = u.r1.z * u.r2.y;\n let fadeExp = u.r1.w;\n let trailFloor = u.r2.x;\n let rainbow = u.r2.w > 0.5;\n let squashGain = u.r3.x;\n let celGain = u.r3.y;\n let halfW = in.segData.y;\n let age = in.segData.x;\n let arg2 = in.segData.z;\n let a = in.a;\n let b = in.b;\n\n if (LAYER == 0) {\n // \u2500\u2500 TRAIL \u2014 the tapered luminous ribbon over its own soft under-glow \u2500\u2500\n let d = segDist(p, a, b);\n let ribbonHalf = halfW * (RIBBON_TAIL_FRAC + (1.0 - RIBBON_TAIL_FRAC) * age);\n let lin = samplePaletteLin(1.0 - age * 0.4);\n let rgb = clamp(linearToSrgb(lin), vec3<f32>(0.0), vec3<f32>(1.0));\n let glowHalf = ribbonHalf * RIBBON_UNDERGLOW_SCALE;\n let glowCover = 1.0 - smoothstep(glowHalf, glowHalf + aa * 3.0, d);\n let ga = peak * RIBBON_UNDERGLOW_ALPHA * pow(age, fadeExp) * glowCover;\n let cover = 1.0 - smoothstep(ribbonHalf, ribbonHalf + aa, d);\n let ca = max(peak * pow(age, fadeExp), peak * trailFloor) * cover;\n let outA = ca + ga * (1.0 - ca);\n return vec4<f32>(rgb * outA, outA);\n } else if (LAYER == 1) {\n // \u2500\u2500 EPICYCLE \u2014 orbit RING + ARM + joint DOT union (MAX-blended, no join seam) \u2500\u2500\n let lin = chainColorLin(arg2, rainbow);\n let rgb = clamp(linearToSrgb(lin), vec3<f32>(0.0), vec3<f32>(1.0));\n let radius = length(b - a);\n let dRing = abs(length(p - a) - radius);\n let ringW = max(halfW * 0.45, aa);\n let ringMask = (1.0 - smoothstep(ringW, ringW + aa, dRing)) * 0.5;\n let dArm = segDist(p, a, b);\n let armMask = 1.0 - smoothstep(halfW * 0.55, halfW * 0.55 + aa, dArm);\n let dotR = max(halfW * 0.7, aa * 2.0);\n let dDot = length(p - a);\n let dotMask = 1.0 - smoothstep(dotR, dotR + aa, dDot);\n let m = clamp(max(max(ringMask, armMask), dotMask), 0.0, 1.0) * peak * 0.7;\n return vec4<f32>(rgb * m, m);\n } else if (LAYER == 2) {\n // \u2500\u2500 HEAD \u2014 squash-and-stretch (\u00A72b): halo + saturated core + white specular \u2500\u2500\n let head = a;\n let headBack = b;\n let fr = headFrame(head, headBack, halfW);\n let dHead = headAniso(p, head, fr, squashGain);\n let coreR = halfW * 1.5;\n let haloR = coreR * 3.0;\n let headRgb = clamp(linearToSrgb(samplePaletteLin(0.0)), vec3<f32>(0.0), vec3<f32>(1.0));\n let halo = (1.0 - smoothstep(0.0, haloR, dHead)) * headGlow * 0.35;\n var accum = vec4<f32>(headRgb * halo, halo);\n let core = (1.0 - smoothstep(coreR, coreR + aa, dHead)) * headGlow;\n accum = vec4<f32>(headRgb * core, core) + accum * (1.0 - core);\n let spec = (1.0 - smoothstep(coreR * 0.4, coreR * 0.4 + aa, dHead)) * headGlow * 0.9;\n accum = vec4<f32>(vec3<f32>(1.0) * spec, spec) + accum * (1.0 - spec);\n return accum;\n } else {\n // \u2500\u2500 CEL \u2014 the technicolor ink shadow (rope LAYER==3, arm LAYER==4) \u2500\u2500\n let celA = clamp(celGain, 0.0, 1.0);\n let d = segDist(p, a, b);\n let cover = 1.0 - smoothstep(halfW, halfW + aa, d);\n let m = cover * celA * peak * arg2; // arg2 = celStrength (1.0 rope / 0.7 arm)\n return vec4<f32>(0.0, 0.0, 0.0, m);\n }\n}\n";
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The ordered ribbon LAYER kinds — the fullscreen loop's draw order, one instanced draw each:
|
|
3
|
-
* cel-rope → cel-arm (the technicolor ink shadow, painted FIRST, UNDER the lit chain)
|
|
4
|
-
* epicycle (the orbit rings + arms + joint dots — the scaffold under the curve)
|
|
5
|
-
* trail (the tapered luminous ribbon over its own under-glow)
|
|
6
|
-
* head (the squash-and-stretch comet head — halo + core + specular)
|
|
7
|
-
*/
|
|
8
|
-
export type RibbonLayerKind = "cel-rope" | "cel-arm" | "epicycle" | "trail" | "head";
|
|
9
|
-
/**
|
|
10
|
-
* The blend mode a layer draws with. `over` is the premultiplied source-over
|
|
11
|
-
* (`ONE, ONE_MINUS_SRC_ALPHA`) every layer but the epicycle uses. `max` (per-channel
|
|
12
|
-
* `blendEquation MAX`) is the FB5 fix for the epicycle-join over-composite SEAM: adjacent
|
|
13
|
-
* arms' rings/dots overlap, and over-compositing them separately double-darkened the joins
|
|
14
|
-
* (the named 9× residual); MAX makes the epicycle group a per-channel UNION so overlapping
|
|
15
|
-
* arms take the brighter contribution instead of stacking.
|
|
16
|
-
*/
|
|
17
|
-
export type RibbonBlend = "over" | "max";
|
|
18
|
-
/** The shader LAYER selector (WGSL override `LAYER` / GLSL `uLayer`) per kind. */
|
|
19
|
-
export declare const RIBBON_LAYER_ID: Readonly<Record<RibbonLayerKind, number>>;
|
|
20
|
-
export interface RibbonLayer {
|
|
21
|
-
readonly kind: RibbonLayerKind;
|
|
22
|
-
/** The instance count for this layer's single `drawInstanced` (0 layers are omitted). */
|
|
23
|
-
readonly instanceCount: number;
|
|
24
|
-
readonly blend: RibbonBlend;
|
|
25
|
-
}
|
|
26
|
-
export interface RibbonPlanInput {
|
|
27
|
-
/** The comet-curve sample count — the trail draws `sampleCount − 1` capsule instances. */
|
|
28
|
-
readonly sampleCount: number;
|
|
29
|
-
/** The epicycle arm count (0 / `showEpicycles: false` → no epicycle + no cel-arm layer). */
|
|
30
|
-
readonly armCount: number;
|
|
31
|
-
readonly showEpicycles: boolean;
|
|
32
|
-
/** The cel-shadow gain — `0` omits the cel-rope + cel-arm layers (byte-frozen). */
|
|
33
|
-
readonly celGain: number;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* The per-frame ribbon DRAW PLAN both backends iterate — the ordered list of instanced draws
|
|
37
|
-
* that reproduces the fullscreen loop's paint (cel first/under, head last/over). An empty
|
|
38
|
-
* layer (no arms, no cel) is omitted, never a zero-instance draw.
|
|
39
|
-
*/
|
|
40
|
-
export declare function planRibbonLayers(input: RibbonPlanInput): RibbonLayer[];
|
|
41
|
-
/**
|
|
42
|
-
* The unit quad as a 4-vertex TRIANGLE_STRIP for the WebGL2 instanced draw — corners
|
|
43
|
-
* (0,0)(1,0)(0,1)(1,1) in `[0,1]²`; the instanced vertex expands each corner to the
|
|
44
|
-
* per-instance capsule (a→b padded) or AABB (ring / head halo) bbox. The WGPU render pass
|
|
45
|
-
* builds the SAME quad from `vertex_index` in-shader (a 6-vertex two-triangle list), so it
|
|
46
|
-
* consumes only {@link planRibbonLayers}, never this buffer.
|
|
47
|
-
*/
|
|
48
|
-
export declare const RIBBON_QUAD_STRIP: Float32Array<ArrayBuffer>;
|
|
49
|
-
export declare const RIBBON_QUAD_STRIP_VERTS = 4;
|
|
50
|
-
/** Floats per ribbon instance in the WebGL2 attribute buffer: `aSeg`(vec4) + `aData`(vec4). */
|
|
51
|
-
export declare const RIBBON_INSTANCE_FLOATS = 8;
|
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* brush.ts — the flat Brush DATA model (the keystone; SPEC §2). Pure data, 0 deps.
|
|
3
|
-
* ─────────────────────────────────────────────────────────────────────────────
|
|
4
|
-
* A `Brush` is a plain JSON-serialisable record — twelve scalars, four enums, and
|
|
5
|
-
* one optional `stamp` function. Every built-in medium is a frozen literal: a
|
|
6
|
-
* POINT in one continuous parameter space, NOT a class in a taxonomy. The renderer
|
|
7
|
-
* (`ink.ts`) reads fields — it NEVER branches on instrument name (SPEC §12 acc-1).
|
|
8
|
-
* Adding a medium = adding one row here; an in-between medium = a spread/lerp.
|
|
9
|
-
*
|
|
10
|
-
* Field-count discipline (SPEC §2): resist a 13th scalar per new instrument —
|
|
11
|
-
* `blend` earned its place only because highlighter genuinely needed `multiply`.
|
|
12
|
-
*
|
|
13
|
-
* The shipped register: PEN is the default (clean ink, grain:0 ⇒ no filter, the one
|
|
14
|
-
* `ribbon:'stroke'` clean voice). The variable-width VOICES — boil (the pressured
|
|
15
|
-
* pen-line), crayon (the waxy swell), marker (the juicy core), highlighter (the wide
|
|
16
|
-
* slab) — all ENGAGE `ribbon:'hull'`, the vendored perfect-freehand body, sharing the
|
|
17
|
-
* one curvature-coupled pressure profile (ink.ts `addPressure`). pen/pencil/ring stay
|
|
18
|
-
* `ribbon:'stroke'` by intent (pen clean, pencil's dry tooth-grain is its character,
|
|
19
|
-
* ring a thin whisper). The pf body ships whenever any hull brush does.
|
|
20
|
-
*/
|
|
21
|
-
export type BlendMode = "source-over" | "multiply" | "darken" | "screen";
|
|
22
|
-
export interface TaperSpec {
|
|
23
|
-
/** px the width ramps 0→full at the start (lift-on). */
|
|
24
|
-
start: number;
|
|
25
|
-
/** px the width ramps full→0 at the end (lift-off / dry run-out). */
|
|
26
|
-
end: number;
|
|
27
|
-
/** out-cubic = the lazy pencil run-out. */
|
|
28
|
-
ease: "linear" | "out-cubic";
|
|
29
|
-
}
|
|
30
|
-
export interface Brush {
|
|
31
|
-
/** base stroke diameter, in viewBox units. */
|
|
32
|
-
weight: number;
|
|
33
|
-
/** 0..1.4 seeded ±width variance along arc-length. */
|
|
34
|
-
weightJitter: number;
|
|
35
|
-
/** -1..1 pressure→width gain (pf `thinning`). */
|
|
36
|
-
thinning: number;
|
|
37
|
-
/** lift-on / lift-off ramp. */
|
|
38
|
-
taper: TaperSpec;
|
|
39
|
-
/** L2 body strategy: plain stroked <path> | pf filled hull. DEFAULT 'stroke'. */
|
|
40
|
-
ribbon: "stroke" | "hull";
|
|
41
|
-
/** 0..1 base alpha. */
|
|
42
|
-
opacity: number;
|
|
43
|
-
/** 'source-over' ink | 'multiply' highlighter-behind-text. */
|
|
44
|
-
blend: BlendMode;
|
|
45
|
-
/** overdraw count (pen 1 · crayon 2-3). */
|
|
46
|
-
passes: number;
|
|
47
|
-
/** 0..1 per-pass alpha falloff (heavy core, light fringe). */
|
|
48
|
-
passOpacity: number;
|
|
49
|
-
/** 0..1 paper-through depth — THE master pen↔crayon knob. 0 ⇒ NO filter. */
|
|
50
|
-
grain: number;
|
|
51
|
-
/** feTurbulence baseFrequency (high=pencil tooth · low=crayon wax). */
|
|
52
|
-
grainFreq: number;
|
|
53
|
-
/** feDisplacementMap edge-fray scale, px. */
|
|
54
|
-
grainScale: number;
|
|
55
|
-
/** feTurbulence numOctaves (grain richness). */
|
|
56
|
-
octaves: number;
|
|
57
|
-
/** macro tremor → wobbleLinePoints({ roughness }). */
|
|
58
|
-
roughness: number;
|
|
59
|
-
/** micro displacement scale (boil amplitude + warp filter). */
|
|
60
|
-
wobble: number;
|
|
61
|
-
/** wobble centerline resolution. */
|
|
62
|
-
segments: number;
|
|
63
|
-
cap: "round" | "square" | "butt";
|
|
64
|
-
/** when present, OVERRIDES the built-in ink stage only. */
|
|
65
|
-
stamp?: StampFn;
|
|
66
|
-
}
|
|
67
|
-
/** SPEC §5 — the arbitrary-brush escape hatch (one optional field, not a framework). */
|
|
68
|
-
export type StampFn = (ctx: {
|
|
69
|
-
centerline: [number, number][];
|
|
70
|
-
brush: Brush;
|
|
71
|
-
rng: () => number;
|
|
72
|
-
seed: number;
|
|
73
|
-
length: number;
|
|
74
|
-
color: string;
|
|
75
|
-
}) => {
|
|
76
|
-
paths: InkPath[];
|
|
77
|
-
filterId?: string | null;
|
|
78
|
-
defs?: string[];
|
|
79
|
-
};
|
|
80
|
-
/** One ink path the renderer emits (shared with ink.ts; declared here to avoid a cycle). */
|
|
81
|
-
export interface InkPath {
|
|
82
|
-
d: string;
|
|
83
|
-
fill?: string;
|
|
84
|
-
stroke?: string;
|
|
85
|
-
opacity: number;
|
|
86
|
-
blend: BlendMode;
|
|
87
|
-
/** geometry finish — bound to the SVG `stroke-linecap` on the path (d). */
|
|
88
|
-
cap?: "round" | "square" | "butt";
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* The named points in the continuum. `pen` is the DEFAULT (clean ink, grain:0,
|
|
92
|
-
* `ribbon:'stroke'`). `boil`/`crayon`/`marker`/`highlighter` engage `ribbon:'hull'`
|
|
93
|
-
* (the curvature-coupled variable-width body); `pencil`/`ring` stay clean stroke.
|
|
94
|
-
*/
|
|
95
|
-
export declare const BRUSHES: {
|
|
96
|
-
readonly pen: {
|
|
97
|
-
readonly weight: 6;
|
|
98
|
-
readonly weightJitter: 0.1;
|
|
99
|
-
readonly thinning: 0.15;
|
|
100
|
-
readonly taper: {
|
|
101
|
-
readonly start: 14;
|
|
102
|
-
readonly end: 14;
|
|
103
|
-
readonly ease: "out-cubic";
|
|
104
|
-
};
|
|
105
|
-
readonly ribbon: "stroke";
|
|
106
|
-
readonly opacity: 1;
|
|
107
|
-
readonly blend: "source-over";
|
|
108
|
-
readonly passes: 1;
|
|
109
|
-
readonly passOpacity: 0;
|
|
110
|
-
readonly grain: 0;
|
|
111
|
-
readonly grainFreq: 0.1;
|
|
112
|
-
readonly grainScale: 0;
|
|
113
|
-
readonly octaves: 2;
|
|
114
|
-
readonly roughness: 0.7;
|
|
115
|
-
readonly wobble: 1.2;
|
|
116
|
-
readonly segments: 9;
|
|
117
|
-
readonly cap: "round";
|
|
118
|
-
};
|
|
119
|
-
readonly boil: {
|
|
120
|
-
readonly weight: 7;
|
|
121
|
-
readonly weightJitter: 0.12;
|
|
122
|
-
readonly thinning: 0.55;
|
|
123
|
-
readonly taper: {
|
|
124
|
-
readonly start: 14;
|
|
125
|
-
readonly end: 18;
|
|
126
|
-
readonly ease: "out-cubic";
|
|
127
|
-
};
|
|
128
|
-
readonly ribbon: "hull";
|
|
129
|
-
readonly opacity: 1;
|
|
130
|
-
readonly blend: "source-over";
|
|
131
|
-
readonly passes: 1;
|
|
132
|
-
readonly passOpacity: 0;
|
|
133
|
-
readonly grain: 0;
|
|
134
|
-
readonly grainFreq: 0.1;
|
|
135
|
-
readonly grainScale: 0;
|
|
136
|
-
readonly octaves: 2;
|
|
137
|
-
readonly roughness: 0.9;
|
|
138
|
-
readonly wobble: 1.4;
|
|
139
|
-
readonly segments: 14;
|
|
140
|
-
readonly cap: "round";
|
|
141
|
-
};
|
|
142
|
-
readonly pencil: {
|
|
143
|
-
readonly weight: 3;
|
|
144
|
-
readonly weightJitter: 0.3;
|
|
145
|
-
readonly thinning: 0.4;
|
|
146
|
-
readonly taper: {
|
|
147
|
-
readonly start: 8;
|
|
148
|
-
readonly end: 18;
|
|
149
|
-
readonly ease: "out-cubic";
|
|
150
|
-
};
|
|
151
|
-
readonly ribbon: "stroke";
|
|
152
|
-
readonly opacity: 0.6;
|
|
153
|
-
readonly blend: "source-over";
|
|
154
|
-
readonly passes: 1;
|
|
155
|
-
readonly passOpacity: 0;
|
|
156
|
-
readonly grain: 0.5;
|
|
157
|
-
readonly grainFreq: 0.42;
|
|
158
|
-
readonly grainScale: 1.5;
|
|
159
|
-
readonly octaves: 3;
|
|
160
|
-
readonly roughness: 1;
|
|
161
|
-
readonly wobble: 1.6;
|
|
162
|
-
readonly segments: 11;
|
|
163
|
-
readonly cap: "round";
|
|
164
|
-
};
|
|
165
|
-
readonly crayon: {
|
|
166
|
-
readonly weight: 16;
|
|
167
|
-
readonly weightJitter: 1;
|
|
168
|
-
readonly thinning: 0.25;
|
|
169
|
-
readonly taper: {
|
|
170
|
-
readonly start: 6;
|
|
171
|
-
readonly end: 6;
|
|
172
|
-
readonly ease: "linear";
|
|
173
|
-
};
|
|
174
|
-
readonly ribbon: "hull";
|
|
175
|
-
readonly opacity: 0.8;
|
|
176
|
-
readonly blend: "source-over";
|
|
177
|
-
readonly passes: 2;
|
|
178
|
-
readonly passOpacity: 0.18;
|
|
179
|
-
readonly grain: 0.85;
|
|
180
|
-
readonly grainFreq: 0.16;
|
|
181
|
-
readonly grainScale: 2.6;
|
|
182
|
-
readonly octaves: 4;
|
|
183
|
-
readonly roughness: 1.5;
|
|
184
|
-
readonly wobble: 3;
|
|
185
|
-
readonly segments: 13;
|
|
186
|
-
readonly cap: "round";
|
|
187
|
-
};
|
|
188
|
-
readonly ring: {
|
|
189
|
-
readonly weight: 5;
|
|
190
|
-
readonly weightJitter: 0.6;
|
|
191
|
-
readonly thinning: 0.3;
|
|
192
|
-
readonly taper: {
|
|
193
|
-
readonly start: 8;
|
|
194
|
-
readonly end: 12;
|
|
195
|
-
readonly ease: "out-cubic";
|
|
196
|
-
};
|
|
197
|
-
readonly ribbon: "stroke";
|
|
198
|
-
readonly opacity: 0.55;
|
|
199
|
-
readonly blend: "source-over";
|
|
200
|
-
readonly passes: 1;
|
|
201
|
-
readonly passOpacity: 0;
|
|
202
|
-
readonly grain: 0.7;
|
|
203
|
-
readonly grainFreq: 0.18;
|
|
204
|
-
readonly grainScale: 1.8;
|
|
205
|
-
readonly octaves: 4;
|
|
206
|
-
readonly roughness: 1.4;
|
|
207
|
-
readonly wobble: 2.6;
|
|
208
|
-
readonly segments: 13;
|
|
209
|
-
readonly cap: "round";
|
|
210
|
-
};
|
|
211
|
-
readonly marker: {
|
|
212
|
-
readonly weight: 12;
|
|
213
|
-
readonly weightJitter: 0.2;
|
|
214
|
-
readonly thinning: 0.1;
|
|
215
|
-
readonly taper: {
|
|
216
|
-
readonly start: 4;
|
|
217
|
-
readonly end: 10;
|
|
218
|
-
readonly ease: "out-cubic";
|
|
219
|
-
};
|
|
220
|
-
readonly ribbon: "hull";
|
|
221
|
-
readonly opacity: 0.92;
|
|
222
|
-
readonly blend: "source-over";
|
|
223
|
-
readonly passes: 1;
|
|
224
|
-
readonly passOpacity: 0;
|
|
225
|
-
readonly grain: 0.22;
|
|
226
|
-
readonly grainFreq: 0.09;
|
|
227
|
-
readonly grainScale: 1;
|
|
228
|
-
readonly octaves: 3;
|
|
229
|
-
readonly roughness: 1;
|
|
230
|
-
readonly wobble: 2.2;
|
|
231
|
-
readonly segments: 9;
|
|
232
|
-
readonly cap: "square";
|
|
233
|
-
};
|
|
234
|
-
readonly highlighter: {
|
|
235
|
-
readonly weight: 26;
|
|
236
|
-
readonly weightJitter: 0.05;
|
|
237
|
-
readonly thinning: 0;
|
|
238
|
-
readonly taper: {
|
|
239
|
-
readonly start: 6;
|
|
240
|
-
readonly end: 10;
|
|
241
|
-
readonly ease: "out-cubic";
|
|
242
|
-
};
|
|
243
|
-
readonly ribbon: "hull";
|
|
244
|
-
readonly opacity: 0.38;
|
|
245
|
-
readonly blend: "multiply";
|
|
246
|
-
readonly passes: 1;
|
|
247
|
-
readonly passOpacity: 0;
|
|
248
|
-
readonly grain: 0.12;
|
|
249
|
-
readonly grainFreq: 0.2;
|
|
250
|
-
readonly grainScale: 1.5;
|
|
251
|
-
readonly octaves: 2;
|
|
252
|
-
readonly roughness: 0.5;
|
|
253
|
-
readonly wobble: 1.4;
|
|
254
|
-
readonly segments: 9;
|
|
255
|
-
readonly cap: "square";
|
|
256
|
-
};
|
|
257
|
-
};
|
|
258
|
-
export type BrushName = keyof typeof BRUSHES;
|
|
259
|
-
/**
|
|
260
|
-
* Resolution order (KISS, deterministic): preset → object overrides → extra `o`.
|
|
261
|
-
* A string selects a preset; an object spreads over `pen`. Later wins.
|
|
262
|
-
*/
|
|
263
|
-
export declare const resolveBrush: (b: BrushName | Partial<Brush>, o?: Partial<Brush>) => Brush;
|
|
264
|
-
/**
|
|
265
|
-
* lerpBrush — the continuum proof (SPEC §12 acc-2). Linearly interpolate the
|
|
266
|
-
* scalar fields of two brushes; enums/taper/ribbon snap from `a` below 0.5, `b`
|
|
267
|
-
* at/above. Yields a sensible in-between ("inky crayon"), no NaN.
|
|
268
|
-
*/
|
|
269
|
-
export declare const lerpBrush: (a: Brush, b: Brush, t: number) => Brush;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* useHandMark.ts — the headless reactive core (L2/L3/L4; SPEC §9).
|
|
3
|
-
* ─────────────────────────────────────────────────────────────────────────────
|
|
4
|
-
* Sits between the props and the SFC template so a future React/web-component skin
|
|
5
|
-
* reuses L1–L4. It orchestrates: resolve brush → shapeGeom → ink → animation. It
|
|
6
|
-
* owns NO DOM (the SFC anchors/measures/mounts the filter); it owns the reactive
|
|
7
|
-
* pipeline + the draw-on, boil state machine.
|
|
8
|
-
*
|
|
9
|
-
* Two draw-on mechanisms, picked by a FIELD (never an instrument `if`):
|
|
10
|
-
* - clean ink (no grain): `stroke-dashoffset` on `pathLength="1"` — the slides
|
|
11
|
-
* recipe, geometry-agnostic, compositor-cheap, no filter to re-raster.
|
|
12
|
-
* - grained ink (crayon): a `clip-path: inset()` WIPE — the filter rasters ONCE
|
|
13
|
-
* and the reveal mutates only the clip (`ds-crayon-handmark §5.1`). NEVER
|
|
14
|
-
* dashoffset under a filter (it would re-raster the graph per frame — the Δ4
|
|
15
|
-
* gate).
|
|
16
|
-
*
|
|
17
|
-
* PRM: every draw-on collapses to instant (finished static state); boil no-ops
|
|
18
|
-
* (`useLineBoil.start()` early-returns under reduced motion).
|
|
19
|
-
*/
|
|
20
|
-
import { type Ref } from "vue";
|
|
21
|
-
import { type Brush, type BrushName } from "../brush.js";
|
|
22
|
-
/**
|
|
23
|
-
* The boil clock surface the SFC binds — the `useLineBoil` return shape, declared
|
|
24
|
-
* structurally over glass-ui's OWN `Ref` (pencil-boil ships a nested `@vue`, so its
|
|
25
|
-
* `Ref` symbol differs; the no-op stub is built with this `ref`, hence the surface
|
|
26
|
-
* is named here rather than `ReturnType<typeof useLineBoil>`).
|
|
27
|
-
*/
|
|
28
|
-
export interface BoilClock {
|
|
29
|
-
currentFrame: Ref<number>;
|
|
30
|
-
start: () => void;
|
|
31
|
-
stop: () => void;
|
|
32
|
-
}
|
|
33
|
-
import { type ShapeGeom } from "../geometry.js";
|
|
34
|
-
import { type SVGFragment } from "../ink.js";
|
|
35
|
-
import type { HandAnimation, HandMarkProps, HandShape, MarkBox } from "../types.js";
|
|
36
|
-
export interface UseHandMarkInput {
|
|
37
|
-
brush: BrushName | Partial<Brush>;
|
|
38
|
-
shape: HandShape;
|
|
39
|
-
color: string;
|
|
40
|
-
seed: number;
|
|
41
|
-
overrides?: Partial<Brush>;
|
|
42
|
-
animation: HandAnimation;
|
|
43
|
-
boilFps: number;
|
|
44
|
-
boilFrames: number;
|
|
45
|
-
roughness: number | null;
|
|
46
|
-
segments: number | null;
|
|
47
|
-
jagged: boolean;
|
|
48
|
-
/** NATURAL underline morphology (C-2) — procedural off the house-seeded engine. */
|
|
49
|
-
natural: boolean;
|
|
50
|
-
/** NATURAL-underline excursion knob ( (c)); `null` ⇒ derive from brush wobble. */
|
|
51
|
-
amplitude: number | null;
|
|
52
|
-
box: MarkBox | null;
|
|
53
|
-
path: string | null;
|
|
54
|
-
filterId: string;
|
|
55
|
-
/**
|
|
56
|
-
* The MEASURED text baseline as a fraction of the `.hm` box height (text-mode
|
|
57
|
-
* underline anchor). `null` until the SFC measures it (ResizeObserver +
|
|
58
|
-
* `document.fonts.ready`) — geometry falls back to the legacy constant for that
|
|
59
|
-
* one pre-measure frame. Ignored in positioned (`box`) mode.
|
|
60
|
-
*/
|
|
61
|
-
baselineFrac: number | null;
|
|
62
|
-
/**
|
|
63
|
-
* The aspect-correct marking-space height: `VB_W * boxAspect`, using the
|
|
64
|
-
* SFC-measured `.hm` box aspect so `preserveAspectRatio="none"`
|
|
65
|
-
* scales the text-mode wobble SHAPE uniformly (the humps stop crushing flat on a short
|
|
66
|
-
* word). Defaults to `VB_H`; used ONLY for the measured text-mode marks (the positioned/
|
|
67
|
-
* box path keeps `VB_H` byte-for-byte).
|
|
68
|
-
*/
|
|
69
|
-
vbH: number;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Normalise raw HandMarkProps (with their defaults applied) into the core input.
|
|
73
|
-
* `baselineFrac` is the SFC's MEASURED text baseline (text-mode underline anchor) —
|
|
74
|
-
* passed in (not a prop) because it is a runtime measurement, `null` until measured.
|
|
75
|
-
*/
|
|
76
|
-
export declare function normalizeProps(props: HandMarkProps, filterId: string, baselineFrac?: number | null, vbH?: number): UseHandMarkInput;
|
|
77
|
-
export interface HandMarkCore {
|
|
78
|
-
/** the resolved effective brush vector. */
|
|
79
|
-
brush: Ref<Brush>;
|
|
80
|
-
/** the static base geometry (boil re-perturbs THIS). */
|
|
81
|
-
baseGeom: Ref<ShapeGeom>;
|
|
82
|
-
/** the live SVG fragment (paths + filter defs). */
|
|
83
|
-
fragment: Ref<SVGFragment>;
|
|
84
|
-
/** the live `d` (escape-hatch path > boiled geometry > static base). */
|
|
85
|
-
pathD: Ref<string>;
|
|
86
|
-
/** does the brush emit a grain filter? (drives the draw-on mechanism). */
|
|
87
|
-
grained: Ref<boolean>;
|
|
88
|
-
/** the draw-on mechanism for this mark: dashoffset (pen) | clip (crayon). */
|
|
89
|
-
drawKind: Ref<"dashoffset" | "clip">;
|
|
90
|
-
/** does this animation draw on at all? */
|
|
91
|
-
draws: Ref<boolean>;
|
|
92
|
-
/** does this animation boil? */
|
|
93
|
-
boils: Ref<boolean>;
|
|
94
|
-
/** the boil clock (a real `useLineBoil` only when the mark boils; else a no-op stub). */
|
|
95
|
-
boil: BoilClock;
|
|
96
|
-
/** arm/disarm boil (draw-then-boil holds it until the draw finishes). */
|
|
97
|
-
boilArmed: Ref<boolean>;
|
|
98
|
-
}
|
|
99
|
-
export declare function useHandMark(input: Ref<UseHandMarkInput>): HandMarkCore;
|