vireglass 2.1.0 → 2.3.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 +41 -1
- package/dist/{chunk-3PGYF2NK.js → chunk-CTTZNZFV.js} +3 -3
- package/dist/{chunk-3PGYF2NK.js.map → chunk-CTTZNZFV.js.map} +1 -1
- package/dist/{chunk-FL5UZPY5.js → chunk-H5QTBF67.js} +4 -4
- package/dist/{chunk-FL5UZPY5.js.map → chunk-H5QTBF67.js.map} +1 -1
- package/dist/{chunk-TTOKBARR.js → chunk-MMPK6DCK.js} +10 -3
- package/dist/chunk-MMPK6DCK.js.map +1 -0
- package/dist/{chunk-BZC2WHCK.js → chunk-PM2SWCSF.js} +4 -4
- package/dist/{chunk-BZC2WHCK.js.map → chunk-PM2SWCSF.js.map} +1 -1
- package/dist/{chunk-P2ZOODXD.js → chunk-SLRPHDV7.js} +3 -3
- package/dist/{chunk-P2ZOODXD.js.map → chunk-SLRPHDV7.js.map} +1 -1
- package/dist/dom.cjs +48 -20
- package/dist/dom.cjs.map +1 -1
- package/dist/dom.d.cts +15 -3
- package/dist/dom.d.ts +15 -3
- package/dist/dom.js +44 -23
- package/dist/dom.js.map +1 -1
- package/dist/index.cjs +1 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -5
- package/dist/law.cjs +8 -1
- package/dist/law.cjs.map +1 -1
- package/dist/law.d.cts +7 -0
- package/dist/law.d.ts +7 -0
- package/dist/law.js +1 -1
- package/dist/reference.js +2 -2
- package/dist/web/index.cjs +262 -153
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts +88 -2
- package/dist/web/index.d.ts +88 -2
- package/dist/web/index.js +257 -156
- package/dist/web/index.js.map +1 -1
- package/docs/law.md +2 -2
- package/package.json +13 -9
- package/src/dom/body.ts +24 -9
- package/src/dom/index.ts +44 -10
- package/src/dom/probe.ts +27 -3
- package/src/law.ts +7 -0
- package/src/targets/glsl.ts +4 -0
- package/src/web/gl.ts +57 -4
- package/src/web/gpu-timer.ts +111 -0
- package/src/web/index.ts +1 -0
- package/src/web/renderer.ts +305 -218
- package/dist/chunk-TTOKBARR.js.map +0 -1
package/README.md
CHANGED
|
@@ -87,6 +87,43 @@ and variegation of what lies under it. That is what the adaptation layer reads.
|
|
|
87
87
|
> **WebGL does not see the DOM**, so this renderer refracts only what it drew itself — hence the
|
|
88
88
|
> `scene` callback. For glass over your actual page, use `vireglass/dom` below.
|
|
89
89
|
|
|
90
|
+
### GPU backdrop
|
|
91
|
+
|
|
92
|
+
`scene` costs a CPU rasterize and a `texSubImage2D` upload every frame. If your backdrop is
|
|
93
|
+
already a GPU simulation — a fluid, a shader animation, a video frame — draw it straight into the
|
|
94
|
+
texture the lens samples with `backdrop` instead, in the same WebGL2 context, no canvas and no
|
|
95
|
+
readback:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import { createProgram, drawFullscreenTriangle, FULLSCREEN_TRIANGLE_VERTEX_SOURCE } from 'vireglass/web';
|
|
99
|
+
|
|
100
|
+
let program: WebGLProgram | undefined;
|
|
101
|
+
|
|
102
|
+
renderer.render({
|
|
103
|
+
density: devicePixelRatio,
|
|
104
|
+
debug: 'normal',
|
|
105
|
+
pieces: [/* ... */],
|
|
106
|
+
backdrop: (gl, target) => {
|
|
107
|
+
program ??= createProgram(gl, FULLSCREEN_TRIANGLE_VERTEX_SOURCE, MY_FRAGMENT_SOURCE);
|
|
108
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer);
|
|
109
|
+
gl.viewport(0, 0, target.width, target.height);
|
|
110
|
+
gl.useProgram(program);
|
|
111
|
+
drawFullscreenTriangle(gl);
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`backdrop: (gl: WebGL2RenderingContext, target: { framebuffer, width, height }) => void` takes
|
|
117
|
+
over from `scene` entirely — exactly one of the two is required. The pass may render through as
|
|
118
|
+
many of its own FBOs first as it likes; it must finish by drawing into `target.framebuffer`.
|
|
119
|
+
|
|
120
|
+
**Orientation.** The texture this FBO wraps is top-row-first (row 0 is the scene's top row), and
|
|
121
|
+
that row sits at `gl_FragCoord.y = 0` — the window-coordinate bottom, not the top. A pass that
|
|
122
|
+
blits an ordinary image (loaded the normal way, via `texImage2D`) needs no flip at all:
|
|
123
|
+
`texture(src, gl_FragCoord.xy / size)` lands it correctly. A pass that treats increasing `y` as
|
|
124
|
+
its own "up", the natural convention for a physics simulation, has to flip before this final
|
|
125
|
+
write, or its top ends up stored as the scene's bottom.
|
|
126
|
+
|
|
90
127
|
## Live DOM
|
|
91
128
|
|
|
92
129
|
```ts
|
|
@@ -219,10 +256,13 @@ preference; `applyGlassScale` gives that preference its own axis, ultra clear to
|
|
|
219
256
|
## Quality gates
|
|
220
257
|
|
|
221
258
|
```bash
|
|
259
|
+
npm run check:english # every tracked file is English
|
|
222
260
|
npm run typecheck
|
|
223
261
|
npm test
|
|
224
262
|
npm run check:glsl # both shaders compile and link as GLSL ES 3.0
|
|
263
|
+
npm run check:agsl # ...and are valid SkSL, which is what Android runs
|
|
225
264
|
npm run check:optics
|
|
265
|
+
npm run check:backdrop # the GPU backdrop path reproduces the scene path, pixel for pixel
|
|
226
266
|
npm run check:law # every calibrated number is in src/law.ts, cited or named unmeasured
|
|
227
267
|
npm run check:dom # a real browser: the glass bends live DOM, and only where it should
|
|
228
268
|
npm run check:package # packs, installs into an empty project, loads every entry point
|
|
@@ -281,7 +321,7 @@ timestamp so the claims can be checked. No Apple code, assets or footage is incl
|
|
|
281
321
|
distributed with this package.
|
|
282
322
|
|
|
283
323
|
Every calibrated number lives in `src/law.ts` with its provenance, and `check:law` names the ones
|
|
284
|
-
that have none: **
|
|
324
|
+
that have none: **43 of 121** today. See [`docs/law.md`](docs/law.md).
|
|
285
325
|
|
|
286
326
|
## License
|
|
287
327
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CONFIRMATIONS, FLIP_LUMA, RETURN_LUMA } from './chunk-JNRZNMJJ.js';
|
|
2
|
-
import { SCALE, SCROLL_EDGE, ACCENT, ACCESSIBILITY, BODY, SPRING } from './chunk-
|
|
2
|
+
import { SCALE, SCROLL_EDGE, ACCENT, ACCESSIBILITY, BODY, SPRING } from './chunk-MMPK6DCK.js';
|
|
3
3
|
|
|
4
4
|
// src/accent.ts
|
|
5
5
|
var clamp01 = (v) => v < 0 ? 0 : v > 1 ? 1 : v;
|
|
@@ -356,5 +356,5 @@ function createGroupState(sink) {
|
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
export { GLASS_SCALE_DEFAULT, GRADIENT, NO_ACCESSIBILITY, SCROLL_EDGE_ENGAGE_DP, SETTLE, SMOOTH, accentAmount, accentTone, aggregate, applyAccessibility, applyAppear, applyGlassScale, concentricFit, concentricInset, concentricRadius, contrastRimLuma, createDeform, createGroupState, elasticAllowed, probeValuesAt, raiseIntoGlass, resolveShape, scrollEdgeReachDp, scrollEdgeStrength, scrollEdgeStyle, shadowTint, smoothPlane };
|
|
359
|
-
//# sourceMappingURL=chunk-
|
|
360
|
-
//# sourceMappingURL=chunk-
|
|
359
|
+
//# sourceMappingURL=chunk-CTTZNZFV.js.map
|
|
360
|
+
//# sourceMappingURL=chunk-CTTZNZFV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/accent.ts","../src/appear.ts","../src/shadow-tint.ts","../src/touch-response.ts","../src/accessibility.ts","../src/glass-scale.ts","../src/scroll-edge.ts","../src/concentric.ts","../src/group-model.ts"],"names":["clamp01","k","luma"],"mappings":";;;;AAaA,IAAM,OAAA,GAAU,CAAC,CAAA,KAAe,CAAA,GAAI,IAAI,CAAA,GAAI,CAAA,GAAI,IAAI,CAAA,GAAI,CAAA;AASjD,SAAS,UAAA,CACd,OACA,YAAA,EAC0B;AAC1B,EAAA,MAAM,CAAA,GAAI,OAAO,IAAA,GAA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,MAAA,EAAQ,YAAY,CAAA;AAC5C,MAAA,MAAM,WAAW,OAAA,EAAQ;AACzB,MAAA,IAAI,CAAC,QAAA,EAAU;AACf,MAAA,IAAI,CAAC,mBAAA,CAAoB,QAAA,EAAU,QAAQ,CAAA,EAAG;AAC5C,QAAA,OAAA,GAAU,CAAA;AACV,QAAA;AAAA,MACF;AACA,MAAA,OAAA,IAAW,CAAA;AACX,MAAA,IAAI,UAAU,aAAA,EAAe;AAC7B,MAAA,OAAA,GAAU,CAAA;AACV,MAAA,QAAA,GAAW,QAAA,KAAa,IAAI,CAAA,GAAI,CAAA;AAChC,MAAA,IAAA,CAAK,KAAK,QAAQ,CAAA;AAAA,IACpB,CAAA;AAAA;AAAA;AAAA;AAAA,IAIA,QAAQ,EAAA,EAAI;AACV,MAAA,IAAI,OAAA,CAAQ,MAAA,CAAO,EAAE,CAAA,EAAG,OAAA,EAAQ;AAAA,IAClC,CAAA;AAAA,IACA,OAAO,MAAM,KAAA;AAAA,IACb,UAAU,MAAM,QAAA;AAAA,IAChB,eAAe,MAAM;AAAA,GACvB;AACF","file":"chunk-3PGYF2NK.js","sourcesContent":["// Tinting (docs/reference.md §7, 219 @16:31): \"Selecting a color generates a range of tones that\n// are mapped to content brightness underneath the tinted element. It draws inspiration from how\n// colored glass works in reality: changing its hue, brightness and saturation depending on what's\n// behind without deviating too much from the intended color.\"\n//\n// So a tint is not a fill. @17:03 is explicit about what a fill costs: \"it is completely opaque\n// and breaks the visual character of Liquid Glass.\" The colour has to be a property of the medium,\n// and the content has to keep coming through it.\n//\n// JS twin of the accent block in the lens shader.\nimport type { VireGlassAccent } from './adapters';\nimport { ACCENT } from './law';\n\nconst clamp01 = (v: number) => (v < 0 ? 0 : v > 1 ? 1 : v);\n\n/**\n * The tone this accent takes over a backdrop of the given lightness — deeper over dark, lighter\n * over light, which is what \"a range of tones mapped to content brightness\" means.\n *\n * @17:21: tinting is for the primary action, not for everything. \"When every element is tinted,\n * nothing stands out.\" That is the host's call, not this function's.\n */\nexport function accentTone(\n color: readonly [number, number, number],\n backdropLuma: number,\n): [number, number, number] {\n const k = ACCENT.deep + (ACCENT.light - ACCENT.deep) * clamp01(backdropLuma);\n return [clamp01(color[0] * k), clamp01(color[1] * k), clamp01(color[2] * k)];\n}\n\n/** The fraction of the medium the colour occupies, which is what keeps the content showing\n * through it rather than being covered by it. */\nexport function accentAmount(accent: VireGlassAccent): number {\n return clamp01(accent.amount ?? ACCENT.amount);\n}\n","// Materialising in and out (docs/reference.md §1, 219 @2:55): \"Instead of fading, Liquid Glass\n// objects materialize in and out by gradually modulating the light bending and lensing, ensuring a\n// graceful transition that preserves the optical integrity of the material.\"\n//\n// So an element must not arrive by opacity. Fading it leaves a half-transparent picture OF glass;\n// modulating the lens leaves glass that is not yet bending much light. The difference is visible:\n// a faded element shows the backdrop through a veil, a materialising one shows it undistorted.\n//\n// JS twin of what `u_appear` multiplies in the lens: the lens strength itself, the frost, the\n// body, the dimming layer and the rim's light. Everything that makes the material present, and\n// nothing that makes it opaque.\nimport type { VireGlassOptics } from './material';\n\nconst clamp01 = (v: number) => (v < 0 ? 0 : v > 1 ? 1 : v);\n\n/**\n * `t` of 0 is an element indistinguishable from the backdrop beneath it; 1 is the material at\n * full strength. Between them the glass bends progressively more light.\n */\nexport function applyAppear(optics: VireGlassOptics, t: number): VireGlassOptics {\n const a = clamp01(t);\n if (a === 1) return optics;\n return {\n ...optics,\n refraction: optics.refraction * a,\n blur: optics.blur * a,\n bodyDensity: optics.bodyDensity * a,\n dimming: optics.dimming * a,\n edgeLight: optics.edgeLight * a,\n // A floor on how far the element must stand out from its backdrop (§3). Left alone it holds\n // the element visible at t = 0, which is the opposite of what materialising means.\n presence: optics.presence * a,\n // The spectral trio is lensing too — §1's \"light bending and lensing\" is not only the\n // displacement. The fringe map and the per-channel split are drawn from these, and a filter\n // graph that still paints them is an element that is not there but is casting a rainbow.\n dispersion: optics.dispersion * a,\n iridescence: optics.iridescence * a,\n diffraction: optics.diffraction * a,\n tintStrength: optics.tintStrength * a,\n // Legibility is a REQUIREMENT, not an effect: an element still arriving has no ink on it yet,\n // and holding a demand it cannot meet would darken the body exactly while it should be\n // clearing. It fades with the rest.\n legibility: optics.legibility * a,\n };\n}\n","// The colour that bleeds into a shadow (docs/reference.md §4, 219 @8:22): \"the light reflects,\n// scatters, and bleeds into the shadow as well — much like it would in the physical world.\"\n//\n// JS twin of the lens surface's `vgShadowTint`. A shadow that is simply black leaves an element\n// over colourful content hanging above a grey blob, which reads as pasted on rather than resting\n// there.\n\nconst LUMA: readonly [number, number, number] = [0.2126, 0.7152, 0.0722];\n\nconst luma = (c: readonly [number, number, number]) => c[0] * LUMA[0] + c[1] * LUMA[1] + c[2] * LUMA[2];\n\n/**\n * Hue without lightness, scaled by how much light there is to bleed. Lightness is subtracted out\n * of the hue on purpose: left in, the shadow PALES and loses its depth instead of warming up. And\n * over a nearly black backdrop there is nothing to spill, so the result goes to zero on its own.\n */\nexport function shadowTint(ambient: readonly [number, number, number]): [number, number, number] {\n const peak = Math.max(ambient[0], ambient[1], ambient[2], 0.001);\n const hue: [number, number, number] = [ambient[0] / peak, ambient[1] / peak, ambient[2] / peak];\n const grey = luma(hue);\n const available = luma(ambient);\n return [(hue[0] - grey) * available, (hue[1] - grey) * available, (hue[2] - grey) * available];\n}\n","// The element's response to a finger — PART OF THE MATERIAL, not the app: the springs here\n// describe what the medium feels like, exactly the way ior describes what it looks like through.\n// Keeping them with the consumer would mean web and Android end up with two different glasses\n// under one name.\n//\n// It's the FIELD around the touch point that deforms (vgTouchWarp in sdf.ts), so four values are\n// computed here: where it was touched, how far it's being dragged, how deep the press is, and\n// what wave is currently running.\n//\n// The key point: drag is anchored to the touch BLOB. Pull the right edge and the right edge\n// moves, the left stays put; the finger has area, not a point — the plateau inside `vgTouchWarp`.\n// Scaling the shape's bounding box isn't an option: that would make a rightward pull also bulge\n// the left side, which liquid doesn't do.\n//\n// PRESS is viscous: it dents shallow and releases slowly.\n// DRAG is thick: the body noticeably lags the finger, travel is short, and on release it snaps\n// back quickly with almost no overshoot. A wide, springy overshoot would be liquid jelly, not\n// dense glass.\n// WAVE: touch and lift-off each throw a short ring that decays within a quarter second.\n\nimport { ACCESSIBILITY, SPRING } from './law';\n\nexport type DeformSample = {\n /** Touch point relative to the element's center, CSS pixels. */\n touchX: number;\n touchY: number;\n pullX: number;\n pullY: number;\n press: number;\n active: number;\n /** Wave amplitude in CSS pixels and its phase in turns. */\n waveAmp: number;\n wavePhase: number;\n};\n\n/**\n * `elastic: false` is reduced motion (§9): the spring and the ripple are the material's elastic\n * properties and stop, the press stays and is damped. An element that goes dead under the setting\n * would not be reduced motion — it would be no feedback at all, and the press is what lights the\n * element from within (§5), which is light rather than movement.\n */\nexport type DeformOptions = { elastic?: boolean };\n\nexport function createDeform(options: DeformOptions = {}) {\n let elastic = options.elastic !== false;\n let pressCeiling = elastic ? 1 : ACCESSIBILITY.stillPress;\n let touchX = 0;\n let touchY = 0;\n let targetTouchX = 0;\n let targetTouchY = 0;\n let pullX = 0;\n let pullY = 0;\n let vx = 0;\n let vy = 0;\n let targetX = 0;\n let targetY = 0;\n let held = false;\n let press = 0;\n let active = 0;\n let waveAmp = 0;\n let wavePhase = 0;\n\n /** `x`, `y` — touch point relative to the element's center, CSS pixels. */\n function grab(x: number, y: number, waveStart: number): void {\n // Rest is checked BEFORE the grab: idle() looks at !held, and after `held = true` it's\n // always false — the point would then jump even on a first touch of a resting element.\n const atRest = idle();\n held = true;\n targetTouchX = x;\n targetTouchY = y;\n // On a resting element the finger lands instantly; if it hasn't settled yet from the\n // previous touch, the point travels there over a couple of frames. An instant jump tears the\n // deformation, and on rapid taps that reads as jitter.\n if (atRest) {\n touchX = x;\n touchY = y;\n }\n targetX = 0;\n targetY = 0;\n // Impulses ADD UP rather than restart, and phase isn't reset: resetting it would cut off a\n // running wave mid-period, which is exactly what causes a jolt on rapid clicks.\n if (elastic) waveAmp = Math.min(waveAmp + waveStart, waveStart * SPRING.waveCapOnGrab);\n }\n\n function drag(dx: number, dy: number, limit: number): void {\n if (!held || !elastic) return;\n const len = Math.hypot(dx, dy);\n // Travel saturates rather than clips: near the limit the finger keeps moving while the field\n // barely does — that's how a thick liquid behaves once it hits its limit.\n const scale = len > 1e-3 ? (limit * Math.tanh(len / limit)) / len : 0;\n targetX = dx * scale;\n targetY = dy * scale;\n }\n\n /** Lifting the finger throws a second wave — weaker than the one from touching down. */\n function release(waveStart: number): void {\n held = false;\n targetX = 0;\n targetY = 0;\n if (elastic) waveAmp = Math.min(waveAmp + waveStart, waveStart * SPRING.waveCapOnRelease);\n }\n\n function integrate(dt: number): void {\n const k = held ? SPRING.holdStiffness : SPRING.releaseStiffness;\n const c = held ? SPRING.holdDamping : SPRING.releaseDamping;\n vx += (k * (targetX - pullX) - c * vx) * dt;\n vy += (k * (targetY - pullY) - c * vy) * dt;\n pullX += vx * dt;\n pullY += vy * dt;\n\n const pressTarget = held ? pressCeiling : 0;\n const tau = held ? SPRING.pressAttack : SPRING.pressRelease;\n press += (pressTarget - press) * (1 - Math.exp(-dt / tau));\n active += (pressTarget - active) * (1 - Math.exp(-dt / SPRING.activeFollow));\n\n // The touch point catches up to the finger fast, but not instantly — see grab().\n const follow = 1 - Math.exp(-dt / SPRING.pointFollow);\n touchX += (targetTouchX - touchX) * follow;\n touchY += (targetTouchY - touchY) * follow;\n\n wavePhase += dt * SPRING.waveTurnsPerSecond;\n waveAmp *= Math.exp(-dt / SPRING.waveDecay);\n if (waveAmp < 0.01) waveAmp = 0;\n }\n\n /**\n * The step is fixed, the frame isn't: on a software renderer there can be as few as ten frames\n * a second, and integrating \"however much time passed\" makes the response lag behind real time\n * (and at a large step the spring can even diverge). So time is caught up in sub-steps.\n */\n function step(dt: number): void {\n let rest = Math.min(Math.max(dt, 0), 0.25);\n const h = 1 / 120;\n while (rest > 1e-6) {\n const slice = Math.min(h, rest);\n integrate(slice);\n rest -= slice;\n }\n // Settled means exactly at rest. The `idle()` threshold stops rendering, but the values\n // themselves only approach zero asymptotically, and the element would stay forever very\n // slightly deformed: invisible to the eye, but a frame-vs-reference comparison would flag the\n // mismatch forever.\n if (idle()) {\n pullX = 0;\n pullY = 0;\n vx = 0;\n vy = 0;\n press = 0;\n active = 0;\n wavePhase = 0;\n }\n }\n\n /** Whether the element has settled — the bench uses this to decide whether to keep drawing frames. */\n function idle(): boolean {\n return (\n !held &&\n Math.abs(pullX) < 0.05 &&\n Math.abs(pullY) < 0.05 &&\n Math.hypot(vx, vy) < 0.5 &&\n press < 0.004 &&\n active < 0.004 &&\n waveAmp === 0\n );\n }\n\n /** The setting can be turned on while the page is open, and a deformation already in flight has\n * to stop rather than finish. */\n function setElastic(on: boolean): void {\n if (on === elastic) return;\n elastic = on;\n pressCeiling = on ? 1 : ACCESSIBILITY.stillPress;\n if (!on) {\n pullX = 0;\n pullY = 0;\n vx = 0;\n vy = 0;\n targetX = 0;\n targetY = 0;\n waveAmp = 0;\n wavePhase = 0;\n }\n }\n\n function sample(): DeformSample {\n return { touchX, touchY, pullX, pullY, press, active, waveAmp, wavePhase };\n }\n\n return { grab, drag, release, step, idle, sample, setElastic };\n}\n\n/**\n * RAISING INTO GLASS (reference §5, M 4:10–4:30). A control that isn't glass at rest — a switch\n * knob, a slider handle — stops being frosted under the finger and becomes a lens: whatever is\n * beneath it shows through.\n *\n * Glass comes in FASTER than frost leaves: the two fractions overlap, otherwise midway through\n * the transition the backdrop flashes through the knob for an instant — a hole where the control\n * should be.\n *\n * Lifting off the backdrop is NOT part of this. The shader's `u_lift` is a direction (\"this kind\n * of element sinks in or rises\"), not a magnitude — how far it has already risen is carried by\n * the press value that `u_lift` gets multiplied by. Returning a third fraction here would mean\n * multiplying press by itself — which is exactly what happened the first time the web bench wired\n * this up.\n */\nexport function raiseIntoGlass(press: number): { glass: number; solid: number } {\n const t = press < 0 ? 0 : press > 1 ? 1 : press;\n return { glass: Math.pow(t, 0.6), solid: 1 - Math.pow(t, 1.4) };\n}\n","// System accessibility settings change the material's LAYERS, they don't override it (reference\n// 219 @18:15). So what's adjusted here are EFFECTS, like with toggles: the shader knows nothing\n// about accessibility.\nimport { ACCESSIBILITY, BODY } from './law';\nimport type { VireGlassOptics } from './material';\n\nexport type VireGlassAccessibility = {\n /** The glass becomes more frosted and hides content beneath it more strongly (219 @18:22). */\n reduceTransparency: boolean;\n /** The element moves nearly to black or white and picks up a contrasting border (219 @18:29). */\n increaseContrast: boolean;\n /** The material's springiness is turned off, effects are quieter (219 @18:35). */\n reduceMotion: boolean;\n};\n\nexport const NO_ACCESSIBILITY: VireGlassAccessibility = {\n reduceTransparency: false,\n increaseContrast: false,\n reduceMotion: false,\n};\n\n/** A system setting acts on the whole glass and outranks the material preset (219 @18:45): even\n * a transparent preset moves to the edge of the scale under contrast — the user needs contrast\n * more than they need aesthetics. */\nexport function applyAccessibility(\n optics: VireGlassOptics,\n mods: VireGlassAccessibility = NO_ACCESSIBILITY,\n): VireGlassOptics {\n if (!mods.reduceTransparency && !mods.increaseContrast) return optics;\n const out = { ...optics };\n if (mods.reduceTransparency) {\n out.blur = Math.max(out.blur, ACCESSIBILITY.frostMinDp);\n out.bodyDensity = Math.max(out.bodyDensity, ACCESSIBILITY.obscureMin);\n }\n if (mods.increaseContrast) {\n out.bodyDensity = Math.max(out.bodyDensity, ACCESSIBILITY.contrastDensity);\n out.presence = Math.max(out.presence, ACCESSIBILITY.contrastPresence);\n out.legibility = 1;\n }\n return out;\n}\n\n/**\n * The lightness of the contrasting border §9 asks for, for a body sitting at `tintLuma`.\n *\n * It is the one place the rim stops being an environmental thing. Everywhere else the hairline\n * takes its colour from what is around the element — \"over a yellow flower the rim is yellow\"\n * (§2) — and a hairline the colour of its surroundings is not a border that contrasts with the\n * element it outlines. Under this setting it is measured from the body instead.\n */\nexport function contrastRimLuma(tintLuma: number): number {\n const light = tintLuma < 0.5;\n return light\n ? Math.min(tintLuma + ACCESSIBILITY.contrastRim, BODY.tintLight)\n : Math.max(tintLuma - ACCESSIBILITY.contrastRim, BODY.tintDark);\n}\n\n/**\n * Whether the material may deform. §9: reduced motion \"disables any elastic properties for the\n * material\" — the spring and the ripple. It does NOT disable the response: the press that lights\n * an element from within (§5) is light, not motion, and survives at reduced intensity.\n */\nexport function elasticAllowed(mods: VireGlassAccessibility = NO_ACCESSIBILITY): boolean {\n return !mods.reduceMotion;\n}\n","// User-facing glass transparency scale: iOS 26.1 gave a choice between two options (\"default clear\n// look\" or \"tinted look which increases opacity of the material\"), iOS 27 a continuous slider\n// \"ultra clear → fully tinted\", and apps get it without recompiling.\n//\n// It adjusts EFFECTS, not causes, and that's not a compromise. The cause \"medium density\" is\n// deliberately absent from the model: the glass has no color of its own, `bodyDensity` is derived\n// from absorption through the body and never exceeds 0.03, and the visible density is held by the\n// legibility requirement and scattering. A thickness scale would move a number that isn't visible\n// in the frame (measured by the `check:optics` gate).\nimport { SCALE } from './law';\nimport type { VireGlassOptics } from './material';\n\n/** The point on the scale where the material stays exactly as it is today. */\nexport const GLASS_SCALE_DEFAULT = SCALE.default;\n\nconst clamp01 = (v: number) => (v < 0 ? 0 : v > 1 ? 1 : v);\n\n/**\n * `scale` 0 is ultra clear, 1 is fully tinted. Toward the transparent end, the legibility\n * requirement and the dimming layer are relaxed (the user chose clarity); toward the tinted end,\n * body density grows.\n *\n * Accessibility settings apply AFTER the scale: they set floors, and the user's chosen clarity\n * does not override them (219 @18:45).\n */\nexport function applyGlassScale(optics: VireGlassOptics, scale: number): VireGlassOptics {\n const s = clamp01(scale);\n if (s === GLASS_SCALE_DEFAULT) return optics;\n if (s < GLASS_SCALE_DEFAULT) {\n const k = s / GLASS_SCALE_DEFAULT;\n return { ...optics, legibility: optics.legibility * k, dimming: optics.dimming * k };\n }\n const k = (s - GLASS_SCALE_DEFAULT) / (1 - GLASS_SCALE_DEFAULT);\n return { ...optics, bodyDensity: Math.max(optics.bodyDensity, SCALE.tintedDensity * k) };\n}\n","// Scroll edge effect (reference 219 @8:52) — the SCREEN's job, not the material's: it sits over\n// the content beneath the panel, and the glass sees an already-dimmed backdrop. Only the general\n// rules live here.\nimport { SCROLL_EDGE } from './law';\n\n/**\n * 356 @11:48 names two styles across the system, \"soft and hard\", and says not to mix or stack\n * them. Soft is the default; hard is \"a stronger, more opaque boundary\", mostly macOS, for pinned\n * table headers and controls without backgrounds.\n *\n * Soft has two forms, and which one is in play is not a choice: 219 @9:16 dissolves the content\n * into the background, and @9:33, when darker content scrolls under and the glass itself turns to\n * its dark style, \"the effect intelligently switches to apply a subtle dimming instead\". Same\n * trigger as ink polarity, because it is the same problem — dark content under dark glass merges\n * with it unless the content is pushed down.\n */\nexport type ScrollEdgeStyle = 'dissolve' | 'dim' | 'hard';\n\nexport function scrollEdgeStyle(inkLight: boolean, pinned = false): ScrollEdgeStyle {\n if (pinned) return 'hard';\n return inkLight ? 'dim' : 'dissolve';\n}\n\n/** How far the content has to slide under the panel for the effect to fully engage, dp. */\nexport const SCROLL_EDGE_ENGAGE_DP = SCROLL_EDGE.engageDp;\n\n/**\n * How tall to make the edge, given the bar it sits under. The host positions the element; without\n * this it has to guess a height, and the reference has an answer — measured off the footage rather\n * than chosen (see `SCROLL_EDGE.reachOfBarHeight`).\n */\nexport function scrollEdgeReachDp(barHeightDp: number): number {\n return Math.max(barHeightDp, 0) * SCROLL_EDGE.reachOfBarHeight;\n}\n\n/**\n * Edge strength as a function of scroll. With no scroll, content near the top doesn't slide\n * under the panel yet — so there's no effect (a mail screen at the top: the header sits on a\n * clean background). At the bottom, content slides under it for as long as there's room left\n * to scroll.\n */\nexport function scrollEdgeStrength(side: 'top' | 'bottom', scroll: number, maxScroll: number): number {\n const room = side === 'top' ? scroll : maxScroll - scroll;\n return Math.min(Math.max(room / SCROLL_EDGE_ENGAGE_DP, 0), 1);\n}\n","// Concentricity (reference 219 @7:53): nested shapes share the CENTER of curvature, not the radius.\n// So the inner shape's radius is smaller by exactly the inset — otherwise the corners don't run\n// parallel and the gap between the shapes either gets eaten or spreads apart.\n\n/**\n * Radius of a nested shape: outer radius minus inset. Zero is a square corner; it never goes\n * negative — once the inset exceeds the outer radius, the corner is simply a right angle.\n *\n * `minimum` — a floor on the radius (analogous to `concentric(minimum:)` in SwiftUI): far from\n * the edge, honest concentricity yields zero and the nested element drops out of the family with\n * a sharp corner. The floor breaks concentricity on purpose — here kinship between shapes matters\n * more than a shared center of curvature.\n */\nexport function concentricRadius(outerRadius: number, inset: number, minimum = 0): number {\n return Math.max(outerRadius - inset, Math.max(minimum, 0));\n}\n\n/**\n * The inset at which an inner shape with a given radius stays concentric with the outer one.\n * The inverse problem: the element's radius is known (its size dictates it), and what's needed\n * is the margin around it.\n */\nexport function concentricInset(outerRadius: number, innerRadius: number): number {\n return Math.max(outerRadius - innerRadius, 0);\n}\n\n/**\n * The three shape types the design system builds concentric layouts from (356 @3:42): \"fixed\n * shapes have a constant corner radius. Capsules use a radius that's half the height of the\n * container. And concentric shapes calculate their radius by subtracting padding from the\n * parent's.\"\n *\n * Naming them is the point. 356 @5:09: \"using the three shape types we covered earlier helps keep\n * your components aligned with the system.\" A host that only has a number has to decide what that\n * number means every time the layout changes; a host that has the type gets the number recomputed\n * for it.\n */\nexport type ShapeSpec =\n | { type: 'fixed'; radius: number }\n | { type: 'capsule' }\n /**\n * `fallback` is 356 @6:00: \"a neat trick for managing components that need to work both inside a\n * container and on their own: use a concentric shape with a fallback radius. The concentric value\n * adapts when nested, and the fallback kicks in when the component stands alone.\"\n *\n * It is not the same as `minimum`. A minimum is a floor that applies while nested and breaks\n * concentricity on purpose; a fallback applies only when there is no parent to be concentric\n * with, and never overrides a parent that exists.\n */\n | { type: 'concentric'; inset: number; minimum?: number; fallback?: number };\n\n/** What is around a shape, when there is something around it. */\nexport type ShapeParent = { cornerRadius: number };\n\n/**\n * The corner radius a shape takes in the place it finds itself. `height` is the shape's own, which\n * is what a capsule's radius is measured from; `parent` is absent when the shape stands alone.\n */\nexport function resolveShape(spec: ShapeSpec, height: number, parent?: ShapeParent): number {\n switch (spec.type) {\n case 'fixed':\n return Math.max(spec.radius, 0);\n case 'capsule':\n return Math.max(height, 0) / 2;\n case 'concentric':\n return parent\n ? concentricRadius(parent.cornerRadius, spec.inset, spec.minimum)\n : Math.max(spec.fallback ?? 0, 0);\n }\n}\n\n/**\n * Whether two nested shapes are concentric, and which way they are wrong when they are not.\n * 356 @5:19: \"keep an eye out for corners that feel too pinched — or flared. They can create\n * tension and break the sense of balance.\"\n *\n * Pinched is an inner radius smaller than concentricity asks for: the gap between the corners\n * widens through the curve. Flared is larger: the gap narrows and the corners crowd each other.\n * The defect is visible to the eye and usually goes unnamed, which is why this names it.\n */\nexport function concentricFit(\n outerRadius: number,\n inset: number,\n innerRadius: number,\n tolerance = 0.5,\n): 'concentric' | 'pinched' | 'flared' {\n const want = concentricRadius(outerRadius, inset);\n if (innerRadius < want - tolerance) return 'pinched';\n if (innerRadius > want + tolerance) return 'flared';\n return 'concentric';\n}\n","import { CONFIRMATIONS, FLIP_LUMA, RETURN_LUMA, type BackdropSample } from './adaptation';\n\n/**\n * GLASS GROUP ESTIMATE — the pure part of the surface group (`glass-group.tsx`).\n *\n * Everything that decides lives here: the lightness plane from members' samples, the group's\n * aggregates, the polarity requirement and its hysteresis. None of these rules need React or the\n * native layer, so they live apart from the component and are checked by a unit test.\n */\n\nexport type GroupMember = { x: number; y: number; sample: BackdropSample; legibility: number };\n\n/** Group estimate: center and average lightness, slope along x, the lightest spot, and the\n * measurement values shared by everyone — [variegation, lo, hi, r, g, b]. */\nexport type GroupPlane = {\n mx: number;\n ml: number;\n slope: number;\n base: number;\n rest: number[];\n};\n\n/** Input to the polarity decision: the lightness the group judges by, and the strictest of the requirements. */\nexport type GroupDecision = { decisive: number; legibility: number };\n\n/** Fraction of a new sample in the smoothed estimate. Samples come in from every member, so the\n * group collects roughly twenty a second — a quarter is enough for a response within ~200 ms. */\nexport const SMOOTH = 0.25;\n\n/** The remainder below which smoothing snaps the value to the sample. An exponential never\n * actually reaches its target, and the estimate kept \"changing\" by denormals for two more\n * minutes after the backdrop had settled. */\nexport const SETTLE = 1e-6;\n\n/**\n * Fraction of the slope that reaches the members.\n *\n * A plane through four points nearly interpolates them: right at a black/white border, buttons\n * were getting 0.0, 0.3, 0.7 and 1.0 — that is, exactly their own individual values, and the\n * group fell apart into independent elements again. Density is set by the group's LIGHTEST spot;\n * the slope only lets it off slightly at the dark end.\n */\nexport const GRADIENT = 0.35;\n\nconst clamp01 = (v: number) => (v < 0 ? 0 : v > 1 ? 1 : v);\n\n/**\n * Lightness plane from members' samples. The slope is a least-squares fit along x: the group's\n * members stand in a row, and one axis is enough — there's no vertical spread among them. The\n * coordinates are centered, so the normal equations decouple.\n */\nfunction fitLuma(members: readonly GroupMember[]): {\n mx: number;\n ml: number;\n slope: number;\n} {\n const n = members.length;\n let mx = 0;\n let ml = 0;\n for (const m of members) {\n mx += m.x;\n ml += m.sample.luma;\n }\n mx /= n;\n ml /= n;\n let sxx = 0;\n let sxl = 0;\n for (const m of members) {\n const dx = m.x - mx;\n sxx += dx * dx;\n sxl += dx * m.sample.luma;\n }\n return { mx, ml, slope: sxx > 1e-6 ? sxl / sxx : 0 };\n}\n\n/** Group estimate from its members. An empty group has nothing to estimate — that's `null`. */\nexport function aggregate(\n members: readonly GroupMember[],\n): { plane: GroupPlane; decision: GroupDecision } | null {\n if (members.length === 0) return null;\n\n const { mx, ml, slope } = fitLuma(members);\n let busy = 0;\n let lo = 1;\n let hi = 0;\n // The group's lightest SPOT: density for everyone is computed from it. Otherwise, right at a\n // black/white border the group would hold to the average, a light ink would never darken\n // against anything, and it would drown over the light half.\n let base = 0;\n let r = 0;\n let g = 0;\n let b = 0;\n // The legibility requirement is the group's strictest: polarity is one for all, and going by\n // the weakest requirement would leave a neighbor with pickier optics illegible.\n let legibility = 0;\n for (const m of members) {\n busy = Math.max(busy, m.sample.busy);\n lo = Math.min(lo, m.sample.lo);\n hi = Math.max(hi, m.sample.hi);\n base = Math.max(base, m.sample.luma);\n r += m.sample.r;\n g += m.sample.g;\n b += m.sample.b;\n legibility = Math.max(legibility, m.legibility);\n }\n const k = members.length;\n return {\n plane: { mx, ml, slope, base, rest: [busy, lo, hi, r / k, g / k, b / k] },\n // The polarity decision is one per group, by its AVERAGE lightness. Deciding on its own,\n // each button used to end up a different color over a busy backdrop.\n decision: { decisive: ml * 0.75 + hi * 0.25, legibility },\n };\n}\n\n/**\n * Smoothing runs over samples, not frames: the native lens smooths ITS OWN estimate, and the\n * group estimate overrides it with an already-finished value. Without this the group's tone\n * changed in steps — the probe's 180 ms cadence is too coarse for the adaptation to read as\n * unnoticeable.\n */\nexport function smoothPlane(prev: GroupPlane | null, next: GroupPlane): GroupPlane {\n if (!prev) return next;\n const e = (was: number, now: number) =>\n Math.abs(now - was) < SETTLE ? now : was + (now - was) * SMOOTH;\n const ml = e(prev.ml, next.ml);\n const slope = e(prev.slope, next.slope);\n const base = e(prev.base, next.base);\n const rest = next.rest.map((v, i) => e(prev.rest[i], v));\n // A converged estimate is handed back as the same object: otherwise `setPlane` would repaint\n // the group on every sample — twenty times a second, even on a still screen.\n const same =\n next.mx === prev.mx &&\n ml === prev.ml &&\n slope === prev.slope &&\n base === prev.base &&\n rest.every((v, i) => v === prev.rest[i]);\n return same ? prev : { mx: next.mx, ml, slope, base, rest };\n}\n\n/** The sample a member at position `x` hands its own lens — in the order of its prop. */\nexport function probeValuesAt(plane: GroupPlane, x: number): number[] {\n // Down from the group's lightest spot — by exactly as much as that spot is darker along the\n // plane, and even then only a GRADIENT fraction of it. This lets the dark end off on density,\n // without canceling it: the group stays a single material.\n const here = plane.ml + plane.slope * (x - plane.mx);\n const luma = clamp01(plane.base - (plane.base - here) * GRADIENT);\n // The slope doesn't carry over into the lens: the group's is measured in screen dp, while the\n // shader multiplies `u_probeSlope` by a normalized position within the element — different\n // units.\n return [luma, plane.rest[0], plane.rest[1], plane.rest[2], 0, 0, plane.rest[3], plane.rest[4], plane.rest[5]];\n}\n\n/** Whether the group needs to flip ink polarity given the current one (1 light, 0 dark). */\nfunction wantsPolarityChange(decision: GroupDecision, polarity: number): boolean {\n return polarity === 1 ? decision.decisive >= FLIP_LUMA : decision.decisive < RETURN_LUMA;\n}\n\nexport type GroupSink = {\n /** The group estimate has been recomputed: members take their values from it. */\n plane: (plane: GroupPlane | null) => void;\n /** The group flips ink polarity for everyone at once. */\n flip: (polarity: number) => void;\n};\n\nexport type GroupState = {\n report: (\n id: string,\n x: number,\n y: number,\n sample: BackdropSample,\n legibility: number,\n ) => void;\n release: (id: string) => void;\n plane: () => GroupPlane | null;\n polarity: () => number;\n confirmations: () => number;\n};\n\n/** Group state: members, the smoothed estimate, and polarity hysteresis. */\nexport function createGroupState(sink: GroupSink): GroupState {\n const members = new Map<string, GroupMember>();\n let plane: GroupPlane | null = null;\n let pending = 0;\n let polarity = 1;\n\n const measure = (): GroupDecision | null => {\n const next = aggregate([...members.values()]);\n if (!next) {\n pending = 0;\n plane = null;\n sink.plane(null);\n return null;\n }\n plane = smoothPlane(plane, next.plane);\n sink.plane(plane);\n return next.decision;\n };\n\n return {\n report(id, x, y, sample, legibility) {\n members.set(id, { x, y, sample, legibility });\n const decision = measure();\n if (!decision) return;\n if (!wantsPolarityChange(decision, polarity)) {\n pending = 0;\n return;\n }\n pending += 1;\n if (pending < CONFIRMATIONS) return;\n pending = 0;\n polarity = polarity === 1 ? 0 : 1;\n sink.flip(polarity);\n },\n // Only recomputes the estimate: losing a member isn't a backdrop sample and can't count as a\n // polarity confirmation — unmounting the group used to rack up CONFIRMATIONS instantly and\n // trigger a recolor nobody was left to cancel.\n release(id) {\n if (members.delete(id)) measure();\n },\n plane: () => plane,\n polarity: () => polarity,\n confirmations: () => pending,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/accent.ts","../src/appear.ts","../src/shadow-tint.ts","../src/touch-response.ts","../src/accessibility.ts","../src/glass-scale.ts","../src/scroll-edge.ts","../src/concentric.ts","../src/group-model.ts"],"names":["clamp01","k","luma"],"mappings":";;;;AAaA,IAAM,OAAA,GAAU,CAAC,CAAA,KAAe,CAA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OAAO;AAAA,IACL,MAAA,CAAO,EAAA,EAAI,CAAA,EAAG,CAAA,EAAG,QAAQ,UAAA,EAAY;AACnC,MAAA,OAAA,CAAQ,IAAI,EAAA,EAAI,EAAE,GAAG,CAAA,EAAG,MAAA,EAAQ,YAAY,CAAA;AAC5C,MAAA,MAAM,WAAW,OAAA,EAAQ;AACzB,MAAA,IAAI,CAAC,QAAA,EAAU;AACf,MAAA,IAAI,CAAC,mBAAA,CAAoB,QAAA,EAAU,QAAQ,CAAA,EAAG;AAC5C,QAAA,OAAA,GAAU,CAAA;AACV,QAAA;AAAA,MACF;AACA,MAAA,OAAA,IAAW,CAAA;AACX,MAAA,IAAI,UAAU,aAAA,EAAe;AAC7B,MAAA,OAAA,GAAU,CAAA;AACV,MAAA,QAAA,GAAW,QAAA,KAAa,IAAI,CAAA,GAAI,CAAA;AAChC,MAAA,IAAA,CAAK,KAAK,QAAQ,CAAA;AAAA,IACpB,CAAA;AAAA;AAAA;AAAA;AAAA,IAIA,QAAQ,EAAA,EAAI;AACV,MAAA,IAAI,OAAA,CAAQ,MAAA,CAAO,EAAE,CAAA,EAAG,OAAA,EAAQ;AAAA,IAClC,CAAA;AAAA,IACA,OAAO,MAAM,KAAA;AAAA,IACb,UAAU,MAAM,QAAA;AAAA,IAChB,eAAe,MAAM;AAAA,GACvB;AACF","file":"chunk-CTTZNZFV.js","sourcesContent":["// Tinting (docs/reference.md §7, 219 @16:31): \"Selecting a color generates a range of tones that\n// are mapped to content brightness underneath the tinted element. It draws inspiration from how\n// colored glass works in reality: changing its hue, brightness and saturation depending on what's\n// behind without deviating too much from the intended color.\"\n//\n// So a tint is not a fill. @17:03 is explicit about what a fill costs: \"it is completely opaque\n// and breaks the visual character of Liquid Glass.\" The colour has to be a property of the medium,\n// and the content has to keep coming through it.\n//\n// JS twin of the accent block in the lens shader.\nimport type { VireGlassAccent } from './adapters';\nimport { ACCENT } from './law';\n\nconst clamp01 = (v: number) => (v < 0 ? 0 : v > 1 ? 1 : v);\n\n/**\n * The tone this accent takes over a backdrop of the given lightness — deeper over dark, lighter\n * over light, which is what \"a range of tones mapped to content brightness\" means.\n *\n * @17:21: tinting is for the primary action, not for everything. \"When every element is tinted,\n * nothing stands out.\" That is the host's call, not this function's.\n */\nexport function accentTone(\n color: readonly [number, number, number],\n backdropLuma: number,\n): [number, number, number] {\n const k = ACCENT.deep + (ACCENT.light - ACCENT.deep) * clamp01(backdropLuma);\n return [clamp01(color[0] * k), clamp01(color[1] * k), clamp01(color[2] * k)];\n}\n\n/** The fraction of the medium the colour occupies, which is what keeps the content showing\n * through it rather than being covered by it. */\nexport function accentAmount(accent: VireGlassAccent): number {\n return clamp01(accent.amount ?? ACCENT.amount);\n}\n","// Materialising in and out (docs/reference.md §1, 219 @2:55): \"Instead of fading, Liquid Glass\n// objects materialize in and out by gradually modulating the light bending and lensing, ensuring a\n// graceful transition that preserves the optical integrity of the material.\"\n//\n// So an element must not arrive by opacity. Fading it leaves a half-transparent picture OF glass;\n// modulating the lens leaves glass that is not yet bending much light. The difference is visible:\n// a faded element shows the backdrop through a veil, a materialising one shows it undistorted.\n//\n// JS twin of what `u_appear` multiplies in the lens: the lens strength itself, the frost, the\n// body, the dimming layer and the rim's light. Everything that makes the material present, and\n// nothing that makes it opaque.\nimport type { VireGlassOptics } from './material';\n\nconst clamp01 = (v: number) => (v < 0 ? 0 : v > 1 ? 1 : v);\n\n/**\n * `t` of 0 is an element indistinguishable from the backdrop beneath it; 1 is the material at\n * full strength. Between them the glass bends progressively more light.\n */\nexport function applyAppear(optics: VireGlassOptics, t: number): VireGlassOptics {\n const a = clamp01(t);\n if (a === 1) return optics;\n return {\n ...optics,\n refraction: optics.refraction * a,\n blur: optics.blur * a,\n bodyDensity: optics.bodyDensity * a,\n dimming: optics.dimming * a,\n edgeLight: optics.edgeLight * a,\n // A floor on how far the element must stand out from its backdrop (§3). Left alone it holds\n // the element visible at t = 0, which is the opposite of what materialising means.\n presence: optics.presence * a,\n // The spectral trio is lensing too — §1's \"light bending and lensing\" is not only the\n // displacement. The fringe map and the per-channel split are drawn from these, and a filter\n // graph that still paints them is an element that is not there but is casting a rainbow.\n dispersion: optics.dispersion * a,\n iridescence: optics.iridescence * a,\n diffraction: optics.diffraction * a,\n tintStrength: optics.tintStrength * a,\n // Legibility is a REQUIREMENT, not an effect: an element still arriving has no ink on it yet,\n // and holding a demand it cannot meet would darken the body exactly while it should be\n // clearing. It fades with the rest.\n legibility: optics.legibility * a,\n };\n}\n","// The colour that bleeds into a shadow (docs/reference.md §4, 219 @8:22): \"the light reflects,\n// scatters, and bleeds into the shadow as well — much like it would in the physical world.\"\n//\n// JS twin of the lens surface's `vgShadowTint`. A shadow that is simply black leaves an element\n// over colourful content hanging above a grey blob, which reads as pasted on rather than resting\n// there.\n\nconst LUMA: readonly [number, number, number] = [0.2126, 0.7152, 0.0722];\n\nconst luma = (c: readonly [number, number, number]) => c[0] * LUMA[0] + c[1] * LUMA[1] + c[2] * LUMA[2];\n\n/**\n * Hue without lightness, scaled by how much light there is to bleed. Lightness is subtracted out\n * of the hue on purpose: left in, the shadow PALES and loses its depth instead of warming up. And\n * over a nearly black backdrop there is nothing to spill, so the result goes to zero on its own.\n */\nexport function shadowTint(ambient: readonly [number, number, number]): [number, number, number] {\n const peak = Math.max(ambient[0], ambient[1], ambient[2], 0.001);\n const hue: [number, number, number] = [ambient[0] / peak, ambient[1] / peak, ambient[2] / peak];\n const grey = luma(hue);\n const available = luma(ambient);\n return [(hue[0] - grey) * available, (hue[1] - grey) * available, (hue[2] - grey) * available];\n}\n","// The element's response to a finger — PART OF THE MATERIAL, not the app: the springs here\n// describe what the medium feels like, exactly the way ior describes what it looks like through.\n// Keeping them with the consumer would mean web and Android end up with two different glasses\n// under one name.\n//\n// It's the FIELD around the touch point that deforms (vgTouchWarp in sdf.ts), so four values are\n// computed here: where it was touched, how far it's being dragged, how deep the press is, and\n// what wave is currently running.\n//\n// The key point: drag is anchored to the touch BLOB. Pull the right edge and the right edge\n// moves, the left stays put; the finger has area, not a point — the plateau inside `vgTouchWarp`.\n// Scaling the shape's bounding box isn't an option: that would make a rightward pull also bulge\n// the left side, which liquid doesn't do.\n//\n// PRESS is viscous: it dents shallow and releases slowly.\n// DRAG is thick: the body noticeably lags the finger, travel is short, and on release it snaps\n// back quickly with almost no overshoot. A wide, springy overshoot would be liquid jelly, not\n// dense glass.\n// WAVE: touch and lift-off each throw a short ring that decays within a quarter second.\n\nimport { ACCESSIBILITY, SPRING } from './law';\n\nexport type DeformSample = {\n /** Touch point relative to the element's center, CSS pixels. */\n touchX: number;\n touchY: number;\n pullX: number;\n pullY: number;\n press: number;\n active: number;\n /** Wave amplitude in CSS pixels and its phase in turns. */\n waveAmp: number;\n wavePhase: number;\n};\n\n/**\n * `elastic: false` is reduced motion (§9): the spring and the ripple are the material's elastic\n * properties and stop, the press stays and is damped. An element that goes dead under the setting\n * would not be reduced motion — it would be no feedback at all, and the press is what lights the\n * element from within (§5), which is light rather than movement.\n */\nexport type DeformOptions = { elastic?: boolean };\n\nexport function createDeform(options: DeformOptions = {}) {\n let elastic = options.elastic !== false;\n let pressCeiling = elastic ? 1 : ACCESSIBILITY.stillPress;\n let touchX = 0;\n let touchY = 0;\n let targetTouchX = 0;\n let targetTouchY = 0;\n let pullX = 0;\n let pullY = 0;\n let vx = 0;\n let vy = 0;\n let targetX = 0;\n let targetY = 0;\n let held = false;\n let press = 0;\n let active = 0;\n let waveAmp = 0;\n let wavePhase = 0;\n\n /** `x`, `y` — touch point relative to the element's center, CSS pixels. */\n function grab(x: number, y: number, waveStart: number): void {\n // Rest is checked BEFORE the grab: idle() looks at !held, and after `held = true` it's\n // always false — the point would then jump even on a first touch of a resting element.\n const atRest = idle();\n held = true;\n targetTouchX = x;\n targetTouchY = y;\n // On a resting element the finger lands instantly; if it hasn't settled yet from the\n // previous touch, the point travels there over a couple of frames. An instant jump tears the\n // deformation, and on rapid taps that reads as jitter.\n if (atRest) {\n touchX = x;\n touchY = y;\n }\n targetX = 0;\n targetY = 0;\n // Impulses ADD UP rather than restart, and phase isn't reset: resetting it would cut off a\n // running wave mid-period, which is exactly what causes a jolt on rapid clicks.\n if (elastic) waveAmp = Math.min(waveAmp + waveStart, waveStart * SPRING.waveCapOnGrab);\n }\n\n function drag(dx: number, dy: number, limit: number): void {\n if (!held || !elastic) return;\n const len = Math.hypot(dx, dy);\n // Travel saturates rather than clips: near the limit the finger keeps moving while the field\n // barely does — that's how a thick liquid behaves once it hits its limit.\n const scale = len > 1e-3 ? (limit * Math.tanh(len / limit)) / len : 0;\n targetX = dx * scale;\n targetY = dy * scale;\n }\n\n /** Lifting the finger throws a second wave — weaker than the one from touching down. */\n function release(waveStart: number): void {\n held = false;\n targetX = 0;\n targetY = 0;\n if (elastic) waveAmp = Math.min(waveAmp + waveStart, waveStart * SPRING.waveCapOnRelease);\n }\n\n function integrate(dt: number): void {\n const k = held ? SPRING.holdStiffness : SPRING.releaseStiffness;\n const c = held ? SPRING.holdDamping : SPRING.releaseDamping;\n vx += (k * (targetX - pullX) - c * vx) * dt;\n vy += (k * (targetY - pullY) - c * vy) * dt;\n pullX += vx * dt;\n pullY += vy * dt;\n\n const pressTarget = held ? pressCeiling : 0;\n const tau = held ? SPRING.pressAttack : SPRING.pressRelease;\n press += (pressTarget - press) * (1 - Math.exp(-dt / tau));\n active += (pressTarget - active) * (1 - Math.exp(-dt / SPRING.activeFollow));\n\n // The touch point catches up to the finger fast, but not instantly — see grab().\n const follow = 1 - Math.exp(-dt / SPRING.pointFollow);\n touchX += (targetTouchX - touchX) * follow;\n touchY += (targetTouchY - touchY) * follow;\n\n wavePhase += dt * SPRING.waveTurnsPerSecond;\n waveAmp *= Math.exp(-dt / SPRING.waveDecay);\n if (waveAmp < 0.01) waveAmp = 0;\n }\n\n /**\n * The step is fixed, the frame isn't: on a software renderer there can be as few as ten frames\n * a second, and integrating \"however much time passed\" makes the response lag behind real time\n * (and at a large step the spring can even diverge). So time is caught up in sub-steps.\n */\n function step(dt: number): void {\n let rest = Math.min(Math.max(dt, 0), 0.25);\n const h = 1 / 120;\n while (rest > 1e-6) {\n const slice = Math.min(h, rest);\n integrate(slice);\n rest -= slice;\n }\n // Settled means exactly at rest. The `idle()` threshold stops rendering, but the values\n // themselves only approach zero asymptotically, and the element would stay forever very\n // slightly deformed: invisible to the eye, but a frame-vs-reference comparison would flag the\n // mismatch forever.\n if (idle()) {\n pullX = 0;\n pullY = 0;\n vx = 0;\n vy = 0;\n press = 0;\n active = 0;\n wavePhase = 0;\n }\n }\n\n /** Whether the element has settled — the bench uses this to decide whether to keep drawing frames. */\n function idle(): boolean {\n return (\n !held &&\n Math.abs(pullX) < 0.05 &&\n Math.abs(pullY) < 0.05 &&\n Math.hypot(vx, vy) < 0.5 &&\n press < 0.004 &&\n active < 0.004 &&\n waveAmp === 0\n );\n }\n\n /** The setting can be turned on while the page is open, and a deformation already in flight has\n * to stop rather than finish. */\n function setElastic(on: boolean): void {\n if (on === elastic) return;\n elastic = on;\n pressCeiling = on ? 1 : ACCESSIBILITY.stillPress;\n if (!on) {\n pullX = 0;\n pullY = 0;\n vx = 0;\n vy = 0;\n targetX = 0;\n targetY = 0;\n waveAmp = 0;\n wavePhase = 0;\n }\n }\n\n function sample(): DeformSample {\n return { touchX, touchY, pullX, pullY, press, active, waveAmp, wavePhase };\n }\n\n return { grab, drag, release, step, idle, sample, setElastic };\n}\n\n/**\n * RAISING INTO GLASS (reference §5, M 4:10–4:30). A control that isn't glass at rest — a switch\n * knob, a slider handle — stops being frosted under the finger and becomes a lens: whatever is\n * beneath it shows through.\n *\n * Glass comes in FASTER than frost leaves: the two fractions overlap, otherwise midway through\n * the transition the backdrop flashes through the knob for an instant — a hole where the control\n * should be.\n *\n * Lifting off the backdrop is NOT part of this. The shader's `u_lift` is a direction (\"this kind\n * of element sinks in or rises\"), not a magnitude — how far it has already risen is carried by\n * the press value that `u_lift` gets multiplied by. Returning a third fraction here would mean\n * multiplying press by itself — which is exactly what happened the first time the web bench wired\n * this up.\n */\nexport function raiseIntoGlass(press: number): { glass: number; solid: number } {\n const t = press < 0 ? 0 : press > 1 ? 1 : press;\n return { glass: Math.pow(t, 0.6), solid: 1 - Math.pow(t, 1.4) };\n}\n","// System accessibility settings change the material's LAYERS, they don't override it (reference\n// 219 @18:15). So what's adjusted here are EFFECTS, like with toggles: the shader knows nothing\n// about accessibility.\nimport { ACCESSIBILITY, BODY } from './law';\nimport type { VireGlassOptics } from './material';\n\nexport type VireGlassAccessibility = {\n /** The glass becomes more frosted and hides content beneath it more strongly (219 @18:22). */\n reduceTransparency: boolean;\n /** The element moves nearly to black or white and picks up a contrasting border (219 @18:29). */\n increaseContrast: boolean;\n /** The material's springiness is turned off, effects are quieter (219 @18:35). */\n reduceMotion: boolean;\n};\n\nexport const NO_ACCESSIBILITY: VireGlassAccessibility = {\n reduceTransparency: false,\n increaseContrast: false,\n reduceMotion: false,\n};\n\n/** A system setting acts on the whole glass and outranks the material preset (219 @18:45): even\n * a transparent preset moves to the edge of the scale under contrast — the user needs contrast\n * more than they need aesthetics. */\nexport function applyAccessibility(\n optics: VireGlassOptics,\n mods: VireGlassAccessibility = NO_ACCESSIBILITY,\n): VireGlassOptics {\n if (!mods.reduceTransparency && !mods.increaseContrast) return optics;\n const out = { ...optics };\n if (mods.reduceTransparency) {\n out.blur = Math.max(out.blur, ACCESSIBILITY.frostMinDp);\n out.bodyDensity = Math.max(out.bodyDensity, ACCESSIBILITY.obscureMin);\n }\n if (mods.increaseContrast) {\n out.bodyDensity = Math.max(out.bodyDensity, ACCESSIBILITY.contrastDensity);\n out.presence = Math.max(out.presence, ACCESSIBILITY.contrastPresence);\n out.legibility = 1;\n }\n return out;\n}\n\n/**\n * The lightness of the contrasting border §9 asks for, for a body sitting at `tintLuma`.\n *\n * It is the one place the rim stops being an environmental thing. Everywhere else the hairline\n * takes its colour from what is around the element — \"over a yellow flower the rim is yellow\"\n * (§2) — and a hairline the colour of its surroundings is not a border that contrasts with the\n * element it outlines. Under this setting it is measured from the body instead.\n */\nexport function contrastRimLuma(tintLuma: number): number {\n const light = tintLuma < 0.5;\n return light\n ? Math.min(tintLuma + ACCESSIBILITY.contrastRim, BODY.tintLight)\n : Math.max(tintLuma - ACCESSIBILITY.contrastRim, BODY.tintDark);\n}\n\n/**\n * Whether the material may deform. §9: reduced motion \"disables any elastic properties for the\n * material\" — the spring and the ripple. It does NOT disable the response: the press that lights\n * an element from within (§5) is light, not motion, and survives at reduced intensity.\n */\nexport function elasticAllowed(mods: VireGlassAccessibility = NO_ACCESSIBILITY): boolean {\n return !mods.reduceMotion;\n}\n","// User-facing glass transparency scale: iOS 26.1 gave a choice between two options (\"default clear\n// look\" or \"tinted look which increases opacity of the material\"), iOS 27 a continuous slider\n// \"ultra clear → fully tinted\", and apps get it without recompiling.\n//\n// It adjusts EFFECTS, not causes, and that's not a compromise. The cause \"medium density\" is\n// deliberately absent from the model: the glass has no color of its own, `bodyDensity` is derived\n// from absorption through the body and never exceeds 0.03, and the visible density is held by the\n// legibility requirement and scattering. A thickness scale would move a number that isn't visible\n// in the frame (measured by the `check:optics` gate).\nimport { SCALE } from './law';\nimport type { VireGlassOptics } from './material';\n\n/** The point on the scale where the material stays exactly as it is today. */\nexport const GLASS_SCALE_DEFAULT = SCALE.default;\n\nconst clamp01 = (v: number) => (v < 0 ? 0 : v > 1 ? 1 : v);\n\n/**\n * `scale` 0 is ultra clear, 1 is fully tinted. Toward the transparent end, the legibility\n * requirement and the dimming layer are relaxed (the user chose clarity); toward the tinted end,\n * body density grows.\n *\n * Accessibility settings apply AFTER the scale: they set floors, and the user's chosen clarity\n * does not override them (219 @18:45).\n */\nexport function applyGlassScale(optics: VireGlassOptics, scale: number): VireGlassOptics {\n const s = clamp01(scale);\n if (s === GLASS_SCALE_DEFAULT) return optics;\n if (s < GLASS_SCALE_DEFAULT) {\n const k = s / GLASS_SCALE_DEFAULT;\n return { ...optics, legibility: optics.legibility * k, dimming: optics.dimming * k };\n }\n const k = (s - GLASS_SCALE_DEFAULT) / (1 - GLASS_SCALE_DEFAULT);\n return { ...optics, bodyDensity: Math.max(optics.bodyDensity, SCALE.tintedDensity * k) };\n}\n","// Scroll edge effect (reference 219 @8:52) — the SCREEN's job, not the material's: it sits over\n// the content beneath the panel, and the glass sees an already-dimmed backdrop. Only the general\n// rules live here.\nimport { SCROLL_EDGE } from './law';\n\n/**\n * 356 @11:48 names two styles across the system, \"soft and hard\", and says not to mix or stack\n * them. Soft is the default; hard is \"a stronger, more opaque boundary\", mostly macOS, for pinned\n * table headers and controls without backgrounds.\n *\n * Soft has two forms, and which one is in play is not a choice: 219 @9:16 dissolves the content\n * into the background, and @9:33, when darker content scrolls under and the glass itself turns to\n * its dark style, \"the effect intelligently switches to apply a subtle dimming instead\". Same\n * trigger as ink polarity, because it is the same problem — dark content under dark glass merges\n * with it unless the content is pushed down.\n */\nexport type ScrollEdgeStyle = 'dissolve' | 'dim' | 'hard';\n\nexport function scrollEdgeStyle(inkLight: boolean, pinned = false): ScrollEdgeStyle {\n if (pinned) return 'hard';\n return inkLight ? 'dim' : 'dissolve';\n}\n\n/** How far the content has to slide under the panel for the effect to fully engage, dp. */\nexport const SCROLL_EDGE_ENGAGE_DP = SCROLL_EDGE.engageDp;\n\n/**\n * How tall to make the edge, given the bar it sits under. The host positions the element; without\n * this it has to guess a height, and the reference has an answer — measured off the footage rather\n * than chosen (see `SCROLL_EDGE.reachOfBarHeight`).\n */\nexport function scrollEdgeReachDp(barHeightDp: number): number {\n return Math.max(barHeightDp, 0) * SCROLL_EDGE.reachOfBarHeight;\n}\n\n/**\n * Edge strength as a function of scroll. With no scroll, content near the top doesn't slide\n * under the panel yet — so there's no effect (a mail screen at the top: the header sits on a\n * clean background). At the bottom, content slides under it for as long as there's room left\n * to scroll.\n */\nexport function scrollEdgeStrength(side: 'top' | 'bottom', scroll: number, maxScroll: number): number {\n const room = side === 'top' ? scroll : maxScroll - scroll;\n return Math.min(Math.max(room / SCROLL_EDGE_ENGAGE_DP, 0), 1);\n}\n","// Concentricity (reference 219 @7:53): nested shapes share the CENTER of curvature, not the radius.\n// So the inner shape's radius is smaller by exactly the inset — otherwise the corners don't run\n// parallel and the gap between the shapes either gets eaten or spreads apart.\n\n/**\n * Radius of a nested shape: outer radius minus inset. Zero is a square corner; it never goes\n * negative — once the inset exceeds the outer radius, the corner is simply a right angle.\n *\n * `minimum` — a floor on the radius (analogous to `concentric(minimum:)` in SwiftUI): far from\n * the edge, honest concentricity yields zero and the nested element drops out of the family with\n * a sharp corner. The floor breaks concentricity on purpose — here kinship between shapes matters\n * more than a shared center of curvature.\n */\nexport function concentricRadius(outerRadius: number, inset: number, minimum = 0): number {\n return Math.max(outerRadius - inset, Math.max(minimum, 0));\n}\n\n/**\n * The inset at which an inner shape with a given radius stays concentric with the outer one.\n * The inverse problem: the element's radius is known (its size dictates it), and what's needed\n * is the margin around it.\n */\nexport function concentricInset(outerRadius: number, innerRadius: number): number {\n return Math.max(outerRadius - innerRadius, 0);\n}\n\n/**\n * The three shape types the design system builds concentric layouts from (356 @3:42): \"fixed\n * shapes have a constant corner radius. Capsules use a radius that's half the height of the\n * container. And concentric shapes calculate their radius by subtracting padding from the\n * parent's.\"\n *\n * Naming them is the point. 356 @5:09: \"using the three shape types we covered earlier helps keep\n * your components aligned with the system.\" A host that only has a number has to decide what that\n * number means every time the layout changes; a host that has the type gets the number recomputed\n * for it.\n */\nexport type ShapeSpec =\n | { type: 'fixed'; radius: number }\n | { type: 'capsule' }\n /**\n * `fallback` is 356 @6:00: \"a neat trick for managing components that need to work both inside a\n * container and on their own: use a concentric shape with a fallback radius. The concentric value\n * adapts when nested, and the fallback kicks in when the component stands alone.\"\n *\n * It is not the same as `minimum`. A minimum is a floor that applies while nested and breaks\n * concentricity on purpose; a fallback applies only when there is no parent to be concentric\n * with, and never overrides a parent that exists.\n */\n | { type: 'concentric'; inset: number; minimum?: number; fallback?: number };\n\n/** What is around a shape, when there is something around it. */\nexport type ShapeParent = { cornerRadius: number };\n\n/**\n * The corner radius a shape takes in the place it finds itself. `height` is the shape's own, which\n * is what a capsule's radius is measured from; `parent` is absent when the shape stands alone.\n */\nexport function resolveShape(spec: ShapeSpec, height: number, parent?: ShapeParent): number {\n switch (spec.type) {\n case 'fixed':\n return Math.max(spec.radius, 0);\n case 'capsule':\n return Math.max(height, 0) / 2;\n case 'concentric':\n return parent\n ? concentricRadius(parent.cornerRadius, spec.inset, spec.minimum)\n : Math.max(spec.fallback ?? 0, 0);\n }\n}\n\n/**\n * Whether two nested shapes are concentric, and which way they are wrong when they are not.\n * 356 @5:19: \"keep an eye out for corners that feel too pinched — or flared. They can create\n * tension and break the sense of balance.\"\n *\n * Pinched is an inner radius smaller than concentricity asks for: the gap between the corners\n * widens through the curve. Flared is larger: the gap narrows and the corners crowd each other.\n * The defect is visible to the eye and usually goes unnamed, which is why this names it.\n */\nexport function concentricFit(\n outerRadius: number,\n inset: number,\n innerRadius: number,\n tolerance = 0.5,\n): 'concentric' | 'pinched' | 'flared' {\n const want = concentricRadius(outerRadius, inset);\n if (innerRadius < want - tolerance) return 'pinched';\n if (innerRadius > want + tolerance) return 'flared';\n return 'concentric';\n}\n","import { CONFIRMATIONS, FLIP_LUMA, RETURN_LUMA, type BackdropSample } from './adaptation';\n\n/**\n * GLASS GROUP ESTIMATE — the pure part of the surface group (`glass-group.tsx`).\n *\n * Everything that decides lives here: the lightness plane from members' samples, the group's\n * aggregates, the polarity requirement and its hysteresis. None of these rules need React or the\n * native layer, so they live apart from the component and are checked by a unit test.\n */\n\nexport type GroupMember = { x: number; y: number; sample: BackdropSample; legibility: number };\n\n/** Group estimate: center and average lightness, slope along x, the lightest spot, and the\n * measurement values shared by everyone — [variegation, lo, hi, r, g, b]. */\nexport type GroupPlane = {\n mx: number;\n ml: number;\n slope: number;\n base: number;\n rest: number[];\n};\n\n/** Input to the polarity decision: the lightness the group judges by, and the strictest of the requirements. */\nexport type GroupDecision = { decisive: number; legibility: number };\n\n/** Fraction of a new sample in the smoothed estimate. Samples come in from every member, so the\n * group collects roughly twenty a second — a quarter is enough for a response within ~200 ms. */\nexport const SMOOTH = 0.25;\n\n/** The remainder below which smoothing snaps the value to the sample. An exponential never\n * actually reaches its target, and the estimate kept \"changing\" by denormals for two more\n * minutes after the backdrop had settled. */\nexport const SETTLE = 1e-6;\n\n/**\n * Fraction of the slope that reaches the members.\n *\n * A plane through four points nearly interpolates them: right at a black/white border, buttons\n * were getting 0.0, 0.3, 0.7 and 1.0 — that is, exactly their own individual values, and the\n * group fell apart into independent elements again. Density is set by the group's LIGHTEST spot;\n * the slope only lets it off slightly at the dark end.\n */\nexport const GRADIENT = 0.35;\n\nconst clamp01 = (v: number) => (v < 0 ? 0 : v > 1 ? 1 : v);\n\n/**\n * Lightness plane from members' samples. The slope is a least-squares fit along x: the group's\n * members stand in a row, and one axis is enough — there's no vertical spread among them. The\n * coordinates are centered, so the normal equations decouple.\n */\nfunction fitLuma(members: readonly GroupMember[]): {\n mx: number;\n ml: number;\n slope: number;\n} {\n const n = members.length;\n let mx = 0;\n let ml = 0;\n for (const m of members) {\n mx += m.x;\n ml += m.sample.luma;\n }\n mx /= n;\n ml /= n;\n let sxx = 0;\n let sxl = 0;\n for (const m of members) {\n const dx = m.x - mx;\n sxx += dx * dx;\n sxl += dx * m.sample.luma;\n }\n return { mx, ml, slope: sxx > 1e-6 ? sxl / sxx : 0 };\n}\n\n/** Group estimate from its members. An empty group has nothing to estimate — that's `null`. */\nexport function aggregate(\n members: readonly GroupMember[],\n): { plane: GroupPlane; decision: GroupDecision } | null {\n if (members.length === 0) return null;\n\n const { mx, ml, slope } = fitLuma(members);\n let busy = 0;\n let lo = 1;\n let hi = 0;\n // The group's lightest SPOT: density for everyone is computed from it. Otherwise, right at a\n // black/white border the group would hold to the average, a light ink would never darken\n // against anything, and it would drown over the light half.\n let base = 0;\n let r = 0;\n let g = 0;\n let b = 0;\n // The legibility requirement is the group's strictest: polarity is one for all, and going by\n // the weakest requirement would leave a neighbor with pickier optics illegible.\n let legibility = 0;\n for (const m of members) {\n busy = Math.max(busy, m.sample.busy);\n lo = Math.min(lo, m.sample.lo);\n hi = Math.max(hi, m.sample.hi);\n base = Math.max(base, m.sample.luma);\n r += m.sample.r;\n g += m.sample.g;\n b += m.sample.b;\n legibility = Math.max(legibility, m.legibility);\n }\n const k = members.length;\n return {\n plane: { mx, ml, slope, base, rest: [busy, lo, hi, r / k, g / k, b / k] },\n // The polarity decision is one per group, by its AVERAGE lightness. Deciding on its own,\n // each button used to end up a different color over a busy backdrop.\n decision: { decisive: ml * 0.75 + hi * 0.25, legibility },\n };\n}\n\n/**\n * Smoothing runs over samples, not frames: the native lens smooths ITS OWN estimate, and the\n * group estimate overrides it with an already-finished value. Without this the group's tone\n * changed in steps — the probe's 180 ms cadence is too coarse for the adaptation to read as\n * unnoticeable.\n */\nexport function smoothPlane(prev: GroupPlane | null, next: GroupPlane): GroupPlane {\n if (!prev) return next;\n const e = (was: number, now: number) =>\n Math.abs(now - was) < SETTLE ? now : was + (now - was) * SMOOTH;\n const ml = e(prev.ml, next.ml);\n const slope = e(prev.slope, next.slope);\n const base = e(prev.base, next.base);\n const rest = next.rest.map((v, i) => e(prev.rest[i], v));\n // A converged estimate is handed back as the same object: otherwise `setPlane` would repaint\n // the group on every sample — twenty times a second, even on a still screen.\n const same =\n next.mx === prev.mx &&\n ml === prev.ml &&\n slope === prev.slope &&\n base === prev.base &&\n rest.every((v, i) => v === prev.rest[i]);\n return same ? prev : { mx: next.mx, ml, slope, base, rest };\n}\n\n/** The sample a member at position `x` hands its own lens — in the order of its prop. */\nexport function probeValuesAt(plane: GroupPlane, x: number): number[] {\n // Down from the group's lightest spot — by exactly as much as that spot is darker along the\n // plane, and even then only a GRADIENT fraction of it. This lets the dark end off on density,\n // without canceling it: the group stays a single material.\n const here = plane.ml + plane.slope * (x - plane.mx);\n const luma = clamp01(plane.base - (plane.base - here) * GRADIENT);\n // The slope doesn't carry over into the lens: the group's is measured in screen dp, while the\n // shader multiplies `u_probeSlope` by a normalized position within the element — different\n // units.\n return [luma, plane.rest[0], plane.rest[1], plane.rest[2], 0, 0, plane.rest[3], plane.rest[4], plane.rest[5]];\n}\n\n/** Whether the group needs to flip ink polarity given the current one (1 light, 0 dark). */\nfunction wantsPolarityChange(decision: GroupDecision, polarity: number): boolean {\n return polarity === 1 ? decision.decisive >= FLIP_LUMA : decision.decisive < RETURN_LUMA;\n}\n\nexport type GroupSink = {\n /** The group estimate has been recomputed: members take their values from it. */\n plane: (plane: GroupPlane | null) => void;\n /** The group flips ink polarity for everyone at once. */\n flip: (polarity: number) => void;\n};\n\nexport type GroupState = {\n report: (\n id: string,\n x: number,\n y: number,\n sample: BackdropSample,\n legibility: number,\n ) => void;\n release: (id: string) => void;\n plane: () => GroupPlane | null;\n polarity: () => number;\n confirmations: () => number;\n};\n\n/** Group state: members, the smoothed estimate, and polarity hysteresis. */\nexport function createGroupState(sink: GroupSink): GroupState {\n const members = new Map<string, GroupMember>();\n let plane: GroupPlane | null = null;\n let pending = 0;\n let polarity = 1;\n\n const measure = (): GroupDecision | null => {\n const next = aggregate([...members.values()]);\n if (!next) {\n pending = 0;\n plane = null;\n sink.plane(null);\n return null;\n }\n plane = smoothPlane(plane, next.plane);\n sink.plane(plane);\n return next.decision;\n };\n\n return {\n report(id, x, y, sample, legibility) {\n members.set(id, { x, y, sample, legibility });\n const decision = measure();\n if (!decision) return;\n if (!wantsPolarityChange(decision, polarity)) {\n pending = 0;\n return;\n }\n pending += 1;\n if (pending < CONFIRMATIONS) return;\n pending = 0;\n polarity = polarity === 1 ? 0 : 1;\n sink.flip(polarity);\n },\n // Only recomputes the estimate: losing a member isn't a backdrop sample and can't count as a\n // polarity confirmation — unmounting the group used to rack up CONFIRMATIONS instantly and\n // trigger a recolor nobody was left to cancel.\n release(id) {\n if (members.delete(id)) measure();\n },\n plane: () => plane,\n polarity: () => polarity,\n confirmations: () => pending,\n };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { bevelDp, thicknessDp, rimDp, surfacePadDp, shadowReachDp, bevelFraction, halfMinDp } from './chunk-
|
|
2
|
-
import { DERIVE, TOUCH, EPSILON, BEVEL, LENS, BODY, MEDIUM, SPECTRAL, DISPERSION, RIM, ACCENT, MORPH } from './chunk-
|
|
1
|
+
import { bevelDp, thicknessDp, rimDp, surfacePadDp, shadowReachDp, bevelFraction, halfMinDp } from './chunk-SLRPHDV7.js';
|
|
2
|
+
import { DERIVE, TOUCH, EPSILON, BEVEL, LENS, BODY, MEDIUM, SPECTRAL, DISPERSION, RIM, ACCENT, MORPH } from './chunk-MMPK6DCK.js';
|
|
3
3
|
|
|
4
4
|
// src/optics.ts
|
|
5
5
|
var clamp = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
@@ -1339,5 +1339,5 @@ function morphOutOf(source, target, offsetX, offsetY, t) {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
|
|
1341
1341
|
export { ACCENT_AMOUNT, ADAPT_RADIUS, ALL_EFFECTS_ON, DEBUG_MODES, DYNAMIC_UNIFORMS, EFFECTS, FRESNEL_EXPONENT, ICON_UNIFORMS, LEGACY_NAMES, LEGACY_OPTICS, LENS_SHADER, MATERIAL_PRESETS, MATERIAL_RANGES, OVERLAY_UNIFORMS, PRESET_NAMES, PRODUCT_DIM, REST_LIGHT, SURFACE_LENGTH_UNIFORMS, VG_FALLOFF, VG_SDF, VIREGLASS_CLEAR_MATERIAL, VIREGLASS_CONTROL_MATERIAL, VIREGLASS_LYRICS_MATERIAL, VIREGLASS_MATERIAL, VIREGLASS_MATERIAL_V4, VIREGLASS_MATERIAL_V5, VIREGLASS_SHEET_MATERIAL, absorption, activeMaterial, applyToggles, blur, bodyDensity, colorPickup, debugIndex, diffraction, dispersion, edgeDensity, edgeLight, fresnelF0, fresnelStrength, gatherRadius, iorSpread, iridescence, lensMagnify, materialForInk, mediumTint, morphBetween, morphOutOf, neckToBridge, refractionScale, refractionStrength, resolveMaterial, resolveOptics, sceneDistance, sceneGradient, sdfRoundedRect, sdfRoundedRectGradient, smin, specularPower, specularStrength, toDeviceSurfaceUniforms, toLensProps, toSurfaceUniforms, touchWarp };
|
|
1342
|
-
//# sourceMappingURL=chunk-
|
|
1343
|
-
//# sourceMappingURL=chunk-
|
|
1342
|
+
//# sourceMappingURL=chunk-H5QTBF67.js.map
|
|
1343
|
+
//# sourceMappingURL=chunk-H5QTBF67.js.map
|