vireglass 2.3.0 → 3.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/README.md +37 -6
- package/dist/{adapters-DugC6Qri.d.cts → adapters--bXcGvhW.d.cts} +5 -3
- package/dist/{adapters-BfeAopGO.d.ts → adapters-BlMhc6pI.d.ts} +5 -3
- package/dist/{chunk-MMPK6DCK.js → chunk-CPSIY2DZ.js} +58 -8
- package/dist/chunk-CPSIY2DZ.js.map +1 -0
- package/dist/{chunk-PM2SWCSF.js → chunk-RWUR3OV6.js} +26 -6
- package/dist/chunk-RWUR3OV6.js.map +1 -0
- package/dist/{chunk-CTTZNZFV.js → chunk-VLDD655U.js} +3 -3
- package/dist/{chunk-CTTZNZFV.js.map → chunk-VLDD655U.js.map} +1 -1
- package/dist/{chunk-H5QTBF67.js → chunk-YAN2OK4H.js} +31 -38
- package/dist/chunk-YAN2OK4H.js.map +1 -0
- package/dist/{chunk-SLRPHDV7.js → chunk-Z4FKYY47.js} +3 -3
- package/dist/{chunk-SLRPHDV7.js.map → chunk-Z4FKYY47.js.map} +1 -1
- package/dist/dom.cjs +180 -55
- package/dist/dom.cjs.map +1 -1
- package/dist/dom.d.cts +72 -25
- package/dist/dom.d.ts +72 -25
- package/dist/dom.js +116 -54
- package/dist/dom.js.map +1 -1
- package/dist/{geometry-RhKd7CM5.d.cts → geometry-ip9WSlZv.d.cts} +1 -1
- package/dist/{geometry-GvXtt-_S.d.ts → geometry-pabkYV7w.d.ts} +1 -1
- package/dist/{group-model-z4N27qsC.d.ts → group-model-CQiI5cCe.d.ts} +1 -1
- package/dist/{group-model-DwtixGhG.d.cts → group-model-DX2_W9J_.d.cts} +1 -1
- package/dist/index.cjs +114 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -8
- package/dist/index.d.ts +13 -8
- package/dist/index.js +5 -5
- package/dist/law.cjs +56 -6
- package/dist/law.cjs.map +1 -1
- package/dist/law.d.cts +54 -4
- package/dist/law.d.ts +54 -4
- package/dist/law.js +1 -1
- package/dist/{material-CnUmdKg1.d.ts → material-D9m1EN47.d.cts} +9 -6
- package/dist/{material-CnUmdKg1.d.cts → material-D9m1EN47.d.ts} +9 -6
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/reference.d.cts +2 -2
- package/dist/reference.d.ts +2 -2
- package/dist/reference.js +2 -2
- package/dist/web/index.cjs +112 -40
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts +3 -3
- package/dist/web/index.d.ts +3 -3
- package/dist/web/index.js +4 -4
- package/docs/dom.md +49 -3
- package/docs/law.md +1 -1
- package/package.json +1 -1
- package/src/adapters.ts +3 -1
- package/src/dom/body.ts +93 -39
- package/src/dom/index.ts +49 -20
- package/src/dom/probe.ts +1 -1
- package/src/dom/rim.ts +63 -28
- package/src/dom/style-hold.ts +8 -0
- package/src/law.ts +54 -4
- package/src/lens-shader.ts +26 -33
- package/src/material.ts +10 -7
- package/src/targets/glsl.ts +27 -2
- package/dist/chunk-H5QTBF67.js.map +0 -1
- package/dist/chunk-MMPK6DCK.js.map +0 -1
- package/dist/chunk-PM2SWCSF.js.map +0 -1
package/dist/dom.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { B as BackdropSample } from './adaptation-BSbbdExK.cjs';
|
|
2
|
-
import { V as VireGlassGeometry } from './geometry-
|
|
3
|
-
import { V as VireGlassOptics, a as VireGlassMaterial } from './material-
|
|
4
|
-
import { T as TouchWarp, M as MorphShape, V as VireGlassAccessibility, S as ScrollEdgeStyle, G as GroupPlane } from './group-model-
|
|
5
|
-
import { V as VireGlassAccent } from './adapters
|
|
2
|
+
import { V as VireGlassGeometry } from './geometry-ip9WSlZv.cjs';
|
|
3
|
+
import { V as VireGlassOptics, a as VireGlassMaterial } from './material-D9m1EN47.cjs';
|
|
4
|
+
import { T as TouchWarp, M as MorphShape, V as VireGlassAccessibility, S as ScrollEdgeStyle, G as GroupPlane } from './group-model-DX2_W9J_.cjs';
|
|
5
|
+
import { V as VireGlassAccent } from './adapters--bXcGvhW.cjs';
|
|
6
6
|
|
|
7
7
|
/** Any `backdrop-filter` at all (e.g. `blur()`) — the fallback path's own requirement. */
|
|
8
8
|
declare function supportsBackdropFilter(): boolean;
|
|
@@ -32,7 +32,9 @@ declare function parseColor(value: string): RgbColor | null;
|
|
|
32
32
|
* formula here would mean the ink-polarity decision quietly drifts between renderers on the same
|
|
33
33
|
* page. `samples` are 0..255 per channel, matching what `parseColor` returns.
|
|
34
34
|
*/
|
|
35
|
-
declare function statsFromSamples(samples: readonly RgbColor
|
|
35
|
+
declare function statsFromSamples(samples: readonly (Omit<RgbColor, 'a'> & {
|
|
36
|
+
a?: number;
|
|
37
|
+
})[]): BackdropSample;
|
|
36
38
|
/**
|
|
37
39
|
* Composites a stack of backgrounds front to back, the way the compositor does.
|
|
38
40
|
*
|
|
@@ -100,13 +102,26 @@ declare function lightConicAngle(light: readonly [number, number]): number;
|
|
|
100
102
|
* the light. Both arcs come out of this one expression — that is why they are opposed. */
|
|
101
103
|
declare function rimLobe(deltaDeg: number, specular: number): number;
|
|
102
104
|
type RimAmbient = readonly [number, number, number];
|
|
105
|
+
/** Lightness of an ambient colour, the weights the lens uses. */
|
|
106
|
+
declare function ambientLuma(ambient: RimAmbient): number;
|
|
107
|
+
/** How strongly the line is drawn over a surround of this lightness (§2, §6). */
|
|
108
|
+
declare function rimStrength(luma: number): number;
|
|
103
109
|
/**
|
|
104
|
-
* The
|
|
105
|
-
*
|
|
106
|
-
*
|
|
110
|
+
* The line's opacity where the rim's normal sits `deltaDeg` from the light: a floor all the way
|
|
111
|
+
* round and the key-light lobe on top of it, all of it scaled by the medium's reflectance up to
|
|
112
|
+
* the reference material's.
|
|
113
|
+
*/
|
|
114
|
+
declare function rimLineAlpha(deltaDeg: number, optics: VireGlassOptics, luma: number): number;
|
|
115
|
+
/**
|
|
116
|
+
* The gradient for the hairline: a light line round the whole contour, brighter toward the key
|
|
117
|
+
* light, drawn over the dark edge. Its colour comes from the environment — "over a yellow flower
|
|
118
|
+
* the rim is yellow, over sky it is blue" (§2) — lifted toward white, and its strength follows how
|
|
119
|
+
* light the environment is.
|
|
107
120
|
*
|
|
108
121
|
* The opposing arc carries an iridescent fringe (§2), so `iridescence` pulls its channels apart
|
|
109
122
|
* rather than lifting them together.
|
|
123
|
+
*
|
|
124
|
+
* Two layers, the line first: `--vireglass-rim` is a background list and paints as one.
|
|
110
125
|
*/
|
|
111
126
|
declare function rimGradientCss(optics: VireGlassOptics, ambient: RimAmbient, light: readonly [number, number], appear?: number): string;
|
|
112
127
|
declare const RIM_WIDTH_PX: 1;
|
|
@@ -151,6 +166,9 @@ type GlassBody = {
|
|
|
151
166
|
density: number;
|
|
152
167
|
/** Lightness the body tints toward. */
|
|
153
168
|
tintLuma: number;
|
|
169
|
+
/** The part of the density the ink's legibility asked for, and the pole it asked toward. */
|
|
170
|
+
need: number;
|
|
171
|
+
pole: number;
|
|
154
172
|
};
|
|
155
173
|
/**
|
|
156
174
|
* `ink` is POLARITY, 1 light and 0 dark, matching the shader's uniform. The requirements are
|
|
@@ -160,23 +178,37 @@ type GlassBody = {
|
|
|
160
178
|
declare function resolveBody(optics: VireGlassOptics, sample: BodyBackdrop, ink: number): GlassBody;
|
|
161
179
|
/**
|
|
162
180
|
* PRESENCE (§3): over a uniform backdrop there is nothing to refract and the glass honestly
|
|
163
|
-
* disappears — right for a piece of background, wrong for a control. It is a MINIMUM
|
|
164
|
-
*
|
|
181
|
+
* disappears — right for a piece of background, wrong for a control. It is a MINIMUM on the
|
|
182
|
+
* density, toward light whatever the ink, and it does not read the backdrop: the lift it gives is
|
|
183
|
+
* `presence` times the room left under the light pole, so it fades out as the room does and has no
|
|
184
|
+
* step anywhere on the scale.
|
|
185
|
+
*/
|
|
186
|
+
declare function withPresence(body: GlassBody, optics: VireGlassOptics, _sample?: BodyBackdrop): GlassBody;
|
|
187
|
+
type BodyLayer = {
|
|
188
|
+
/** Straight (not premultiplied) colour, 0…1 per channel. */
|
|
189
|
+
r: number;
|
|
190
|
+
g: number;
|
|
191
|
+
b: number;
|
|
192
|
+
alpha: number;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* The body as ONE translucent layer over the backdrop, which is the form the DOM can draw it in.
|
|
196
|
+
*
|
|
197
|
+
* The lens does not paint a body, it transforms what it refracts, in a chain that stays affine in
|
|
198
|
+
* the backdrop: a mix toward the tint at `density`, the matte lift, the medium's pull toward its
|
|
199
|
+
* own lightness, the ambient spill and the concentration of light (§3, `MEDIUM`). Composing it
|
|
200
|
+
* gives `out = A * backdrop + B` per channel, and a layer of colour `B / (1 - A)` at opacity
|
|
201
|
+
* `1 - A` over the backdrop is that, except where the colour clamps to 0..1: over a saturated dark
|
|
202
|
+
* backdrop (dark blue) a channel is off by up to 0.024.
|
|
165
203
|
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* the body at 0.07 against a backdrop of 0.12: already separating, downward, and the clamp pulled
|
|
170
|
-
* it back onto the backdrop. Measured on the default material at presence 0.08: exactly 0.0000 at
|
|
171
|
-
* backdrops of 0.12, 0.20 and 0.35.
|
|
204
|
+
* This is what lifts the body over a dark backdrop. The tint alone, under light ink, is darker
|
|
205
|
+
* than the dark it sits on; the medium's pull, the matte lift and the concentration are what make
|
|
206
|
+
* it read lighter, as in the reference (M 2:29, A 2:17).
|
|
172
207
|
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* wherever the two are close — enough to drive it to the ceiling over a dark backdrop and stop the
|
|
176
|
-
* glass being a window at all, which check:optics says plainly. Presence is a floor on visibility,
|
|
177
|
-
* not a licence to go opaque.
|
|
208
|
+
* `appear` multiplies the layers exactly where the lens's `u_appear` does, so `optics` is the
|
|
209
|
+
* element's optics BEFORE `applyAppear`: scaling both would count it twice.
|
|
178
210
|
*/
|
|
179
|
-
declare function
|
|
211
|
+
declare function bodyLayer(optics: VireGlassOptics, sample: BodyBackdrop, ink: number, ambient: readonly [number, number, number], appear?: number): BodyLayer;
|
|
180
212
|
|
|
181
213
|
declare function systemAccessibility(): VireGlassAccessibility;
|
|
182
214
|
/** Fires whenever any of the three changes. The material has to follow a setting turned on while
|
|
@@ -320,9 +352,19 @@ type AttachGlassOptions = {
|
|
|
320
352
|
} | null) => void;
|
|
321
353
|
/** Pointer response (§5). On by default. */
|
|
322
354
|
interactive?: boolean;
|
|
323
|
-
/**
|
|
324
|
-
*
|
|
355
|
+
/**
|
|
356
|
+
* Overrides the probe entirely. The probe reads declared backgrounds, so images, video and
|
|
357
|
+
* canvases are invisible to it; a host that knows its backdrop (a cover's accent, a gradient)
|
|
358
|
+
* states it here, and changes it later with `setSample`. `statsFromSamples` builds one from
|
|
359
|
+
* a handful of colours.
|
|
360
|
+
*/
|
|
325
361
|
sample?: BackdropSample;
|
|
362
|
+
/**
|
|
363
|
+
* Whether `attachGlass` paints the body as the element's `background-color`. On by default;
|
|
364
|
+
* turn it off if the host owns that property — `--vireglass-body-color` is always emitted
|
|
365
|
+
* either way and carries the same colour.
|
|
366
|
+
*/
|
|
367
|
+
body?: boolean;
|
|
326
368
|
};
|
|
327
369
|
/**
|
|
328
370
|
* Shapes this element flows into (docs/reference.md §5): merging with a neighbour, or splitting
|
|
@@ -363,8 +405,13 @@ type GlassHandle = {
|
|
|
363
405
|
strength: number;
|
|
364
406
|
} | null): void;
|
|
365
407
|
setMorph(morph: GlassMorph | null): void;
|
|
408
|
+
/**
|
|
409
|
+
* Replaces the backdrop the glass adapts to, without re-attaching, and repaints. The same
|
|
410
|
+
* object as `sample` in the options; `null` goes back to probing declared backgrounds.
|
|
411
|
+
*/
|
|
412
|
+
setSample(sample: BackdropSample | null): void;
|
|
366
413
|
destroy(): void;
|
|
367
414
|
};
|
|
368
415
|
declare function attachGlass(el: HTMLElement, opts?: AttachGlassOptions): GlassHandle;
|
|
369
416
|
|
|
370
|
-
export { type AttachGlassOptions, type BodyBackdrop, type DisplacementMap, type DisplacementState, type EdgePaint, type GlassBody, type GlassGroupHandle, type GlassGroupOptions, type GlassHandle, type GlassMorph, type GroupEntry, type ProbeOptions, RIM_WIDTH_PX, type RgbColor, type RimAmbient, type ScrollEdgeHandle, type ScrollEdgeOptions, type SpectralMap, attachGlass, attachScrollEdge, boxShadowCss, buildDisplacementMap, buildSpectralMap, cached, clearMapCache, compositeLayers, contrastRimCss, createGlassGroup, hasSpectralEdge, lightConicAngle, mapCacheSize, paintFor, parseColor, probeBackdrop, renderDisplacementPixels, renderSpectralPixels, resetSupportCache, resolveBody, rimGradientCss, rimLobe, shadowAlphaFrom, statsFromSamples, supportsBackdropFilter, supportsSvgBackdropFilter, systemAccessibility, watchAccessibility, withPresence };
|
|
417
|
+
export { type AttachGlassOptions, type BodyBackdrop, type BodyLayer, type DisplacementMap, type DisplacementState, type EdgePaint, type GlassBody, type GlassGroupHandle, type GlassGroupOptions, type GlassHandle, type GlassMorph, type GroupEntry, type ProbeOptions, RIM_WIDTH_PX, type RgbColor, type RimAmbient, type ScrollEdgeHandle, type ScrollEdgeOptions, type SpectralMap, ambientLuma, attachGlass, attachScrollEdge, bodyLayer, boxShadowCss, buildDisplacementMap, buildSpectralMap, cached, clearMapCache, compositeLayers, contrastRimCss, createGlassGroup, hasSpectralEdge, lightConicAngle, mapCacheSize, paintFor, parseColor, probeBackdrop, renderDisplacementPixels, renderSpectralPixels, resetSupportCache, resolveBody, rimGradientCss, rimLineAlpha, rimLobe, rimStrength, shadowAlphaFrom, statsFromSamples, supportsBackdropFilter, supportsSvgBackdropFilter, systemAccessibility, watchAccessibility, withPresence };
|
package/dist/dom.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { B as BackdropSample } from './adaptation-BSbbdExK.js';
|
|
2
|
-
import { V as VireGlassGeometry } from './geometry-
|
|
3
|
-
import { V as VireGlassOptics, a as VireGlassMaterial } from './material-
|
|
4
|
-
import { T as TouchWarp, M as MorphShape, V as VireGlassAccessibility, S as ScrollEdgeStyle, G as GroupPlane } from './group-model-
|
|
5
|
-
import { V as VireGlassAccent } from './adapters-
|
|
2
|
+
import { V as VireGlassGeometry } from './geometry-pabkYV7w.js';
|
|
3
|
+
import { V as VireGlassOptics, a as VireGlassMaterial } from './material-D9m1EN47.js';
|
|
4
|
+
import { T as TouchWarp, M as MorphShape, V as VireGlassAccessibility, S as ScrollEdgeStyle, G as GroupPlane } from './group-model-CQiI5cCe.js';
|
|
5
|
+
import { V as VireGlassAccent } from './adapters-BlMhc6pI.js';
|
|
6
6
|
|
|
7
7
|
/** Any `backdrop-filter` at all (e.g. `blur()`) — the fallback path's own requirement. */
|
|
8
8
|
declare function supportsBackdropFilter(): boolean;
|
|
@@ -32,7 +32,9 @@ declare function parseColor(value: string): RgbColor | null;
|
|
|
32
32
|
* formula here would mean the ink-polarity decision quietly drifts between renderers on the same
|
|
33
33
|
* page. `samples` are 0..255 per channel, matching what `parseColor` returns.
|
|
34
34
|
*/
|
|
35
|
-
declare function statsFromSamples(samples: readonly RgbColor
|
|
35
|
+
declare function statsFromSamples(samples: readonly (Omit<RgbColor, 'a'> & {
|
|
36
|
+
a?: number;
|
|
37
|
+
})[]): BackdropSample;
|
|
36
38
|
/**
|
|
37
39
|
* Composites a stack of backgrounds front to back, the way the compositor does.
|
|
38
40
|
*
|
|
@@ -100,13 +102,26 @@ declare function lightConicAngle(light: readonly [number, number]): number;
|
|
|
100
102
|
* the light. Both arcs come out of this one expression — that is why they are opposed. */
|
|
101
103
|
declare function rimLobe(deltaDeg: number, specular: number): number;
|
|
102
104
|
type RimAmbient = readonly [number, number, number];
|
|
105
|
+
/** Lightness of an ambient colour, the weights the lens uses. */
|
|
106
|
+
declare function ambientLuma(ambient: RimAmbient): number;
|
|
107
|
+
/** How strongly the line is drawn over a surround of this lightness (§2, §6). */
|
|
108
|
+
declare function rimStrength(luma: number): number;
|
|
103
109
|
/**
|
|
104
|
-
* The
|
|
105
|
-
*
|
|
106
|
-
*
|
|
110
|
+
* The line's opacity where the rim's normal sits `deltaDeg` from the light: a floor all the way
|
|
111
|
+
* round and the key-light lobe on top of it, all of it scaled by the medium's reflectance up to
|
|
112
|
+
* the reference material's.
|
|
113
|
+
*/
|
|
114
|
+
declare function rimLineAlpha(deltaDeg: number, optics: VireGlassOptics, luma: number): number;
|
|
115
|
+
/**
|
|
116
|
+
* The gradient for the hairline: a light line round the whole contour, brighter toward the key
|
|
117
|
+
* light, drawn over the dark edge. Its colour comes from the environment — "over a yellow flower
|
|
118
|
+
* the rim is yellow, over sky it is blue" (§2) — lifted toward white, and its strength follows how
|
|
119
|
+
* light the environment is.
|
|
107
120
|
*
|
|
108
121
|
* The opposing arc carries an iridescent fringe (§2), so `iridescence` pulls its channels apart
|
|
109
122
|
* rather than lifting them together.
|
|
123
|
+
*
|
|
124
|
+
* Two layers, the line first: `--vireglass-rim` is a background list and paints as one.
|
|
110
125
|
*/
|
|
111
126
|
declare function rimGradientCss(optics: VireGlassOptics, ambient: RimAmbient, light: readonly [number, number], appear?: number): string;
|
|
112
127
|
declare const RIM_WIDTH_PX: 1;
|
|
@@ -151,6 +166,9 @@ type GlassBody = {
|
|
|
151
166
|
density: number;
|
|
152
167
|
/** Lightness the body tints toward. */
|
|
153
168
|
tintLuma: number;
|
|
169
|
+
/** The part of the density the ink's legibility asked for, and the pole it asked toward. */
|
|
170
|
+
need: number;
|
|
171
|
+
pole: number;
|
|
154
172
|
};
|
|
155
173
|
/**
|
|
156
174
|
* `ink` is POLARITY, 1 light and 0 dark, matching the shader's uniform. The requirements are
|
|
@@ -160,23 +178,37 @@ type GlassBody = {
|
|
|
160
178
|
declare function resolveBody(optics: VireGlassOptics, sample: BodyBackdrop, ink: number): GlassBody;
|
|
161
179
|
/**
|
|
162
180
|
* PRESENCE (§3): over a uniform backdrop there is nothing to refract and the glass honestly
|
|
163
|
-
* disappears — right for a piece of background, wrong for a control. It is a MINIMUM
|
|
164
|
-
*
|
|
181
|
+
* disappears — right for a piece of background, wrong for a control. It is a MINIMUM on the
|
|
182
|
+
* density, toward light whatever the ink, and it does not read the backdrop: the lift it gives is
|
|
183
|
+
* `presence` times the room left under the light pole, so it fades out as the room does and has no
|
|
184
|
+
* step anywhere on the scale.
|
|
185
|
+
*/
|
|
186
|
+
declare function withPresence(body: GlassBody, optics: VireGlassOptics, _sample?: BodyBackdrop): GlassBody;
|
|
187
|
+
type BodyLayer = {
|
|
188
|
+
/** Straight (not premultiplied) colour, 0…1 per channel. */
|
|
189
|
+
r: number;
|
|
190
|
+
g: number;
|
|
191
|
+
b: number;
|
|
192
|
+
alpha: number;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* The body as ONE translucent layer over the backdrop, which is the form the DOM can draw it in.
|
|
196
|
+
*
|
|
197
|
+
* The lens does not paint a body, it transforms what it refracts, in a chain that stays affine in
|
|
198
|
+
* the backdrop: a mix toward the tint at `density`, the matte lift, the medium's pull toward its
|
|
199
|
+
* own lightness, the ambient spill and the concentration of light (§3, `MEDIUM`). Composing it
|
|
200
|
+
* gives `out = A * backdrop + B` per channel, and a layer of colour `B / (1 - A)` at opacity
|
|
201
|
+
* `1 - A` over the backdrop is that, except where the colour clamps to 0..1: over a saturated dark
|
|
202
|
+
* backdrop (dark blue) a channel is off by up to 0.024.
|
|
165
203
|
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* the body at 0.07 against a backdrop of 0.12: already separating, downward, and the clamp pulled
|
|
170
|
-
* it back onto the backdrop. Measured on the default material at presence 0.08: exactly 0.0000 at
|
|
171
|
-
* backdrops of 0.12, 0.20 and 0.35.
|
|
204
|
+
* This is what lifts the body over a dark backdrop. The tint alone, under light ink, is darker
|
|
205
|
+
* than the dark it sits on; the medium's pull, the matte lift and the concentration are what make
|
|
206
|
+
* it read lighter, as in the reference (M 2:29, A 2:17).
|
|
172
207
|
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* wherever the two are close — enough to drive it to the ceiling over a dark backdrop and stop the
|
|
176
|
-
* glass being a window at all, which check:optics says plainly. Presence is a floor on visibility,
|
|
177
|
-
* not a licence to go opaque.
|
|
208
|
+
* `appear` multiplies the layers exactly where the lens's `u_appear` does, so `optics` is the
|
|
209
|
+
* element's optics BEFORE `applyAppear`: scaling both would count it twice.
|
|
178
210
|
*/
|
|
179
|
-
declare function
|
|
211
|
+
declare function bodyLayer(optics: VireGlassOptics, sample: BodyBackdrop, ink: number, ambient: readonly [number, number, number], appear?: number): BodyLayer;
|
|
180
212
|
|
|
181
213
|
declare function systemAccessibility(): VireGlassAccessibility;
|
|
182
214
|
/** Fires whenever any of the three changes. The material has to follow a setting turned on while
|
|
@@ -320,9 +352,19 @@ type AttachGlassOptions = {
|
|
|
320
352
|
} | null) => void;
|
|
321
353
|
/** Pointer response (§5). On by default. */
|
|
322
354
|
interactive?: boolean;
|
|
323
|
-
/**
|
|
324
|
-
*
|
|
355
|
+
/**
|
|
356
|
+
* Overrides the probe entirely. The probe reads declared backgrounds, so images, video and
|
|
357
|
+
* canvases are invisible to it; a host that knows its backdrop (a cover's accent, a gradient)
|
|
358
|
+
* states it here, and changes it later with `setSample`. `statsFromSamples` builds one from
|
|
359
|
+
* a handful of colours.
|
|
360
|
+
*/
|
|
325
361
|
sample?: BackdropSample;
|
|
362
|
+
/**
|
|
363
|
+
* Whether `attachGlass` paints the body as the element's `background-color`. On by default;
|
|
364
|
+
* turn it off if the host owns that property — `--vireglass-body-color` is always emitted
|
|
365
|
+
* either way and carries the same colour.
|
|
366
|
+
*/
|
|
367
|
+
body?: boolean;
|
|
326
368
|
};
|
|
327
369
|
/**
|
|
328
370
|
* Shapes this element flows into (docs/reference.md §5): merging with a neighbour, or splitting
|
|
@@ -363,8 +405,13 @@ type GlassHandle = {
|
|
|
363
405
|
strength: number;
|
|
364
406
|
} | null): void;
|
|
365
407
|
setMorph(morph: GlassMorph | null): void;
|
|
408
|
+
/**
|
|
409
|
+
* Replaces the backdrop the glass adapts to, without re-attaching, and repaints. The same
|
|
410
|
+
* object as `sample` in the options; `null` goes back to probing declared backgrounds.
|
|
411
|
+
*/
|
|
412
|
+
setSample(sample: BackdropSample | null): void;
|
|
366
413
|
destroy(): void;
|
|
367
414
|
};
|
|
368
415
|
declare function attachGlass(el: HTMLElement, opts?: AttachGlassOptions): GlassHandle;
|
|
369
416
|
|
|
370
|
-
export { type AttachGlassOptions, type BodyBackdrop, type DisplacementMap, type DisplacementState, type EdgePaint, type GlassBody, type GlassGroupHandle, type GlassGroupOptions, type GlassHandle, type GlassMorph, type GroupEntry, type ProbeOptions, RIM_WIDTH_PX, type RgbColor, type RimAmbient, type ScrollEdgeHandle, type ScrollEdgeOptions, type SpectralMap, attachGlass, attachScrollEdge, boxShadowCss, buildDisplacementMap, buildSpectralMap, cached, clearMapCache, compositeLayers, contrastRimCss, createGlassGroup, hasSpectralEdge, lightConicAngle, mapCacheSize, paintFor, parseColor, probeBackdrop, renderDisplacementPixels, renderSpectralPixels, resetSupportCache, resolveBody, rimGradientCss, rimLobe, shadowAlphaFrom, statsFromSamples, supportsBackdropFilter, supportsSvgBackdropFilter, systemAccessibility, watchAccessibility, withPresence };
|
|
417
|
+
export { type AttachGlassOptions, type BodyBackdrop, type BodyLayer, type DisplacementMap, type DisplacementState, type EdgePaint, type GlassBody, type GlassGroupHandle, type GlassGroupOptions, type GlassHandle, type GlassMorph, type GroupEntry, type ProbeOptions, RIM_WIDTH_PX, type RgbColor, type RimAmbient, type ScrollEdgeHandle, type ScrollEdgeOptions, type SpectralMap, ambientLuma, attachGlass, attachScrollEdge, bodyLayer, boxShadowCss, buildDisplacementMap, buildSpectralMap, cached, clearMapCache, compositeLayers, contrastRimCss, createGlassGroup, hasSpectralEdge, lightConicAngle, mapCacheSize, paintFor, parseColor, probeBackdrop, renderDisplacementPixels, renderSpectralPixels, resetSupportCache, resolveBody, rimGradientCss, rimLineAlpha, rimLobe, rimStrength, shadowAlphaFrom, statsFromSamples, supportsBackdropFilter, supportsSvgBackdropFilter, systemAccessibility, watchAccessibility, withPresence };
|
package/dist/dom.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { shadowTint, NO_ACCESSIBILITY, createGroupState, createDeform, elasticAllowed, contrastRimLuma, concentricRadius, scrollEdgeStrength, scrollEdgeStyle,
|
|
1
|
+
import { shadowTint, NO_ACCESSIBILITY, createGroupState, createDeform, elasticAllowed, contrastRimLuma, concentricRadius, scrollEdgeStrength, scrollEdgeStyle, applyAppear, accentTone, accentAmount, applyGlassScale, GLASS_SCALE_DEFAULT, applyAccessibility, raiseIntoGlass } from './chunk-VLDD655U.js';
|
|
2
2
|
import { ambientFrom, shouldInkBeLight, INK_LIGHT, INK_DARK } from './chunk-JNRZNMJJ.js';
|
|
3
|
-
import { touchWarp, sceneDistance, sceneGradient, sdfRoundedRect, VIREGLASS_MATERIAL, REST_LIGHT, resolveOptics, refractionStrength } from './chunk-
|
|
4
|
-
import { shadowOpacity, bevelDp, thicknessDp, rimDp, shadowOpacityFrom, shadowReachDp, halfMinDp, MAX_STRETCH, roundedRectGeometry } from './chunk-
|
|
5
|
-
import { LENS, BODY, RIM, TOUCH, SHADOW, SHADOW_GAP, SCROLL_EDGE, BEVEL, SPECTRAL, DISPERSION } from './chunk-
|
|
3
|
+
import { touchWarp, sceneDistance, sceneGradient, sdfRoundedRect, VIREGLASS_MATERIAL, REST_LIGHT, resolveOptics, refractionStrength } from './chunk-YAN2OK4H.js';
|
|
4
|
+
import { shadowOpacity, bevelDp, thicknessDp, rimDp, shadowOpacityFrom, shadowReachDp, halfMinDp, MAX_STRETCH, roundedRectGeometry } from './chunk-Z4FKYY47.js';
|
|
5
|
+
import { LENS, BODY, RIM, TOUCH, SHADOW, SHADOW_GAP, MEDIUM, SCROLL_EDGE, BEVEL, SPECTRAL, DISPERSION } from './chunk-CPSIY2DZ.js';
|
|
6
6
|
|
|
7
7
|
// src/dom/displacement.ts
|
|
8
8
|
var SCALE_GAIN = 0.75;
|
|
@@ -392,8 +392,10 @@ var {
|
|
|
392
392
|
tintLight: TINT_LIGHT,
|
|
393
393
|
groundSpan: GROUND_SPAN,
|
|
394
394
|
busyEdge: BUSY_EDGE,
|
|
395
|
-
|
|
396
|
-
|
|
395
|
+
inkBusyFrom: INK_BUSY_FROM,
|
|
396
|
+
inkBusyTo: INK_BUSY_TO,
|
|
397
|
+
inkPoleTo: INK_POLE_TO,
|
|
398
|
+
presenceDemand: PRESENCE_DEMAND,
|
|
397
399
|
maxDemand: MAX_DEMAND
|
|
398
400
|
} = BODY;
|
|
399
401
|
var clamp = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
@@ -402,6 +404,10 @@ function smoothstep2(edge0, edge1, x) {
|
|
|
402
404
|
const t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
|
|
403
405
|
return t * t * (3 - 2 * t);
|
|
404
406
|
}
|
|
407
|
+
function tintFor(density, need, pole) {
|
|
408
|
+
const asked = Math.max(clamp(need / Math.max(density, 1e-4), 0, 1), smoothstep2(PRESENCE_DEMAND, INK_POLE_TO, density));
|
|
409
|
+
return mix(TINT_LIGHT, pole, asked);
|
|
410
|
+
}
|
|
405
411
|
function resolveBody(optics, sample, ink) {
|
|
406
412
|
const strict = clamp(optics.legibility * 2, 0, 1);
|
|
407
413
|
const capLight = mix(BODY_CAP_LOOSE, BODY_CAP_TIGHT, strict);
|
|
@@ -410,33 +416,45 @@ function resolveBody(optics, sample, ink) {
|
|
|
410
416
|
const demand = clamp(optics.legibility * 4, 0, 1);
|
|
411
417
|
const mean = clamp(sample.luma, 0, 1);
|
|
412
418
|
const busy = Math.max(sample.busy, 0);
|
|
413
|
-
const
|
|
414
|
-
const away = mix(TINT_LIGHT, TINT_DARK, darkSide);
|
|
415
|
-
const tintLuma = mix(away, mix(TINT_LIGHT, TINT_DARK, pol), demand);
|
|
419
|
+
const pole = mix(TINT_LIGHT, TINT_DARK, pol);
|
|
416
420
|
const edge = busy * BUSY_EDGE;
|
|
417
421
|
const inkHi = Math.min(mean + edge, 1);
|
|
418
422
|
const inkLo = Math.max(mean - edge, 0);
|
|
419
423
|
const needForLight = inkHi > capLight ? clamp((inkHi - capLight) / Math.max(inkHi - TINT_DARK, 1e-4), 0, MAX_DEMAND) : 0;
|
|
420
424
|
const needForDark = inkLo < floorDark ? clamp((floorDark - inkLo) / Math.max(TINT_LIGHT - inkLo, 1e-4), 0, MAX_DEMAND) : 0;
|
|
421
|
-
const
|
|
425
|
+
const structured = smoothstep2(INK_BUSY_FROM, INK_BUSY_TO, busy);
|
|
426
|
+
const needForInk = mix(needForDark, needForLight, pol) * demand * structured;
|
|
422
427
|
const ground = busy * optics.legibility * GROUND_SPAN;
|
|
423
|
-
|
|
428
|
+
const density = Math.max(Math.max(optics.bodyDensity, ground), needForInk);
|
|
429
|
+
return { density, tintLuma: tintFor(density, needForInk, pole), need: needForInk, pole };
|
|
424
430
|
}
|
|
425
|
-
function withPresence(body, optics,
|
|
431
|
+
function withPresence(body, optics, _sample) {
|
|
426
432
|
if (optics.presence <= 0) return body;
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
const
|
|
432
|
-
if (
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
433
|
+
const density = Math.max(body.density, Math.min(optics.presence / TINT_LIGHT, PRESENCE_DEMAND));
|
|
434
|
+
return { ...body, density, tintLuma: tintFor(density, body.need, body.pole) };
|
|
435
|
+
}
|
|
436
|
+
function hueOf(c) {
|
|
437
|
+
const l = 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];
|
|
438
|
+
if (l < 0.02) return [1, 1, 1];
|
|
439
|
+
return [clamp(c[0] / l, 0, 2), clamp(c[1] / l, 0, 2), clamp(c[2] / l, 0, 2)];
|
|
440
|
+
}
|
|
441
|
+
function bodyLayer(optics, sample, ink, ambient, appear = 1) {
|
|
442
|
+
const a = clamp(appear, 0, 1);
|
|
443
|
+
const body = withPresence(resolveBody(optics, sample, ink), optics);
|
|
444
|
+
const hue = hueOf(ambient);
|
|
445
|
+
const pickup = clamp(optics.colorPickup, 0, 1);
|
|
446
|
+
const density = clamp(body.density * a, 0, 1);
|
|
447
|
+
const matte = optics.legibility * MEDIUM.matteLift * a;
|
|
448
|
+
const pull = MEDIUM.pull * a;
|
|
449
|
+
const spill = optics.edgeLight * MEDIUM.ambientSpill * a;
|
|
450
|
+
const lift = MEDIUM.concentrate * a;
|
|
451
|
+
const alpha = 1 - (1 - lift) * (1 - pull) * (1 - density);
|
|
452
|
+
const channel = (i) => {
|
|
453
|
+
const tintHue = mix(1, hue[i], pickup);
|
|
454
|
+
const added = (1 - pull) * (density * tintHue * body.tintLuma + matte * tintHue) + pull * hue[i] * MEDIUM.luma + ambient[i] * spill;
|
|
455
|
+
return alpha > 1e-6 ? clamp(((1 - lift) * added + lift) / alpha, 0, 1) : 0;
|
|
439
456
|
};
|
|
457
|
+
return { r: channel(0), g: channel(1), b: channel(2), alpha };
|
|
440
458
|
}
|
|
441
459
|
|
|
442
460
|
// src/dom/preferences.ts
|
|
@@ -480,7 +498,14 @@ function watchAccessibility(onChange) {
|
|
|
480
498
|
}
|
|
481
499
|
|
|
482
500
|
// src/dom/rim.ts
|
|
483
|
-
var {
|
|
501
|
+
var {
|
|
502
|
+
lobeExponent: LOBE_EXPONENT,
|
|
503
|
+
opposingArc: OPPOSING_ARC,
|
|
504
|
+
darkEdge: DARK_EDGE,
|
|
505
|
+
contour: CONTOUR,
|
|
506
|
+
whiteShare: WHITE_SHARE,
|
|
507
|
+
reflectanceRef: REFLECTANCE_REF
|
|
508
|
+
} = RIM;
|
|
484
509
|
var STOPS = 48;
|
|
485
510
|
function lightConicAngle(light) {
|
|
486
511
|
const [lx, ly] = light;
|
|
@@ -495,25 +520,41 @@ function rimLobe(deltaDeg, specular) {
|
|
|
495
520
|
}
|
|
496
521
|
var clamp012 = (v) => v < 0 ? 0 : v > 1 ? 1 : v;
|
|
497
522
|
var to2552 = (v) => Math.round(clamp012(v) * 255);
|
|
523
|
+
var mixTo = (a, b, t) => a + (b - a) * t;
|
|
524
|
+
function smoothstep3(edge0, edge1, x) {
|
|
525
|
+
const t = clamp012((x - edge0) / (edge1 - edge0));
|
|
526
|
+
return t * t * (3 - 2 * t);
|
|
527
|
+
}
|
|
528
|
+
function ambientLuma(ambient) {
|
|
529
|
+
return 0.2126 * ambient[0] + 0.7152 * ambient[1] + 0.0722 * ambient[2];
|
|
530
|
+
}
|
|
531
|
+
function rimStrength(luma2) {
|
|
532
|
+
return mixTo(RIM.strengthDark, RIM.strengthLight, smoothstep3(RIM.ambientFrom, RIM.ambientTo, luma2));
|
|
533
|
+
}
|
|
534
|
+
function rimLineAlpha(deltaDeg, optics, luma2) {
|
|
535
|
+
const reflect = Math.min(optics.fresnel / REFLECTANCE_REF, 1);
|
|
536
|
+
const damping = optics.fresnel > 0 ? optics.specular / optics.fresnel : 0;
|
|
537
|
+
const lobe = rimLobe(deltaDeg, damping);
|
|
538
|
+
return clamp012(rimStrength(luma2) * reflect * (CONTOUR + (1 - CONTOUR) * lobe));
|
|
539
|
+
}
|
|
498
540
|
function rimGradientCss(optics, ambient, light, appear = 1) {
|
|
499
541
|
const present = clamp012(appear);
|
|
500
542
|
const start = lightConicAngle(light);
|
|
501
543
|
const [ar, ag, ab] = ambient;
|
|
502
|
-
const
|
|
544
|
+
const luma2 = ambientLuma(ambient);
|
|
545
|
+
const line = [];
|
|
503
546
|
for (let i = 0; i <= STOPS; i += 1) {
|
|
504
547
|
const angle = i / STOPS * 360;
|
|
505
|
-
const key = rimLobe(angle, optics.specular);
|
|
506
548
|
const facing = Math.cos(angle * Math.PI / 180);
|
|
507
549
|
const fringe = facing < 0 ? optics.iridescence * OPPOSING_ARC : 0;
|
|
508
|
-
const
|
|
509
|
-
const
|
|
510
|
-
const
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
const colour = lift > 1e-3 ? `rgba(${to2552(r)},${to2552(g)},${to2552(b)},${alpha.toFixed(3)})` : `rgba(0,0,0,${alpha.toFixed(3)})`;
|
|
514
|
-
stops.push(`${colour} ${angle.toFixed(1)}deg`);
|
|
550
|
+
const r = ar + (1 - ar) * clamp012(WHITE_SHARE + fringe);
|
|
551
|
+
const g = ag + (1 - ag) * WHITE_SHARE;
|
|
552
|
+
const b = ab + (1 - ab) * clamp012(WHITE_SHARE - fringe);
|
|
553
|
+
const alpha = rimLineAlpha(angle, optics, luma2) * present;
|
|
554
|
+
line.push(`rgba(${to2552(r)},${to2552(g)},${to2552(b)},${alpha.toFixed(3)}) ${angle.toFixed(1)}deg`);
|
|
515
555
|
}
|
|
516
|
-
|
|
556
|
+
const dark = `rgba(0,0,0,${(DARK_EDGE * present).toFixed(3)})`;
|
|
557
|
+
return `conic-gradient(from ${start.toFixed(1)}deg, ${line.join(", ")}), conic-gradient(${dark} 0deg, ${dark} 360deg)`;
|
|
517
558
|
}
|
|
518
559
|
var RIM_WIDTH_PX = RIM.widthPx;
|
|
519
560
|
function contrastRimCss(bodyLuma, rimLuma) {
|
|
@@ -535,6 +576,15 @@ function warnIfNested(el) {
|
|
|
535
576
|
);
|
|
536
577
|
}
|
|
537
578
|
|
|
579
|
+
// src/dom/style-hold.ts
|
|
580
|
+
function holdProperty(style, name) {
|
|
581
|
+
const saved = style.getPropertyValue(name);
|
|
582
|
+
return () => {
|
|
583
|
+
if (saved) style.setProperty(name, saved);
|
|
584
|
+
else style.removeProperty(name);
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
|
|
538
588
|
// src/dom/scroll-edge.ts
|
|
539
589
|
function paintFor(style, side) {
|
|
540
590
|
const direction = side === "top" ? "to top" : "to bottom";
|
|
@@ -806,16 +856,16 @@ var to2553 = (v) => Math.round(Math.min(Math.max(v, 0), 1) * 255);
|
|
|
806
856
|
function rgbCss(r, g, b) {
|
|
807
857
|
return `rgb(${to2553(r)} ${to2553(g)} ${to2553(b)})`;
|
|
808
858
|
}
|
|
809
|
-
function bodyCss(optics, sample, ink, accent) {
|
|
810
|
-
const body = withPresence(resolveBody(optics, sample, ink), optics, sample);
|
|
859
|
+
function bodyCss(optics, sample, ink, accent, appear) {
|
|
811
860
|
if (accent) {
|
|
812
|
-
const
|
|
861
|
+
const settled = applyAppear(optics, appear);
|
|
862
|
+
const body = withPresence(resolveBody(settled, sample, ink), settled);
|
|
863
|
+
const [r, g, b] = accentTone(accent.color, sample.luma);
|
|
813
864
|
const amount = Math.max(accentAmount(accent), body.density);
|
|
814
|
-
return `rgba(${to2553(
|
|
865
|
+
return `rgba(${to2553(r)}, ${to2553(g)}, ${to2553(b)}, ${amount.toFixed(3)})`;
|
|
815
866
|
}
|
|
816
|
-
const
|
|
817
|
-
|
|
818
|
-
return `rgba(${to2553(hue(r))}, ${to2553(hue(g))}, ${to2553(hue(b))}, ${body.density.toFixed(3)})`;
|
|
867
|
+
const layer = bodyLayer(optics, sample, ink, ambientFrom(sample), appear);
|
|
868
|
+
return `rgba(${to2553(layer.r)}, ${to2553(layer.g)}, ${to2553(layer.b)}, ${layer.alpha.toFixed(3)})`;
|
|
819
869
|
}
|
|
820
870
|
function attachGlass(el, opts = {}) {
|
|
821
871
|
if (typeof document === "undefined") {
|
|
@@ -832,6 +882,7 @@ function attachGlass(el, opts = {}) {
|
|
|
832
882
|
const onlyWhenTouched = opts.variant === "interactive";
|
|
833
883
|
let appear = onlyWhenTouched ? 0 : opts.appear ?? 1;
|
|
834
884
|
let accent = opts.accent;
|
|
885
|
+
let supplied = opts.sample;
|
|
835
886
|
let a11y = systemAccessibility();
|
|
836
887
|
const stopWatchingA11y = watchAccessibility((next) => {
|
|
837
888
|
a11y = next;
|
|
@@ -843,13 +894,16 @@ function attachGlass(el, opts = {}) {
|
|
|
843
894
|
const host = hostFor(el);
|
|
844
895
|
ensureRimStyles(host);
|
|
845
896
|
el.setAttribute(GLASS_ATTR, "");
|
|
897
|
+
const restoreBackground = holdProperty(el.style, "background-color");
|
|
846
898
|
const positionWasStatic = getComputedStyle(el).position === "static";
|
|
847
899
|
if (positionWasStatic) el.style.setProperty("position", "relative");
|
|
848
|
-
function
|
|
900
|
+
function settledOptics(patch) {
|
|
849
901
|
const base = resolveOptics(patch ?? opts.material);
|
|
850
902
|
const scaled = applyGlassScale(base, opts.scale ?? GLASS_SCALE_DEFAULT);
|
|
851
|
-
|
|
852
|
-
|
|
903
|
+
return applyAccessibility(scaled, opts.accessibility ?? a11y);
|
|
904
|
+
}
|
|
905
|
+
function optics(patch) {
|
|
906
|
+
return applyAppear(settledOptics(patch), appear);
|
|
853
907
|
}
|
|
854
908
|
function morphState() {
|
|
855
909
|
if (!morph) return {};
|
|
@@ -864,7 +918,10 @@ function attachGlass(el, opts = {}) {
|
|
|
864
918
|
if (destroyed) return;
|
|
865
919
|
const geometry = opts.geometry ?? measureGeometry(el);
|
|
866
920
|
const opticsNow = optics();
|
|
867
|
-
const sample =
|
|
921
|
+
const sample = supplied ?? probeBackdrop(el);
|
|
922
|
+
const light = shouldInkBeLight(sample, wasLight);
|
|
923
|
+
wasLight = light;
|
|
924
|
+
const body = opts.body === false ? null : bodyCss(settledOptics(), sample, light ? 1 : 0, accent, appear);
|
|
868
925
|
if (svgSupported) {
|
|
869
926
|
const key = `a${appear.toFixed(3)}|m${morphKey()}|${geometry.width}x${geometry.height}r${geometry.cornerRadius}@${devicePixelRatio()}:${opticsNow.refraction}:${opticsNow.refractionScale}:${opticsNow.bevelDp}:${opticsNow.blur}`;
|
|
870
927
|
if (key !== mapKey || !filterEl) {
|
|
@@ -882,10 +939,8 @@ function attachGlass(el, opts = {}) {
|
|
|
882
939
|
} else {
|
|
883
940
|
el.style.setProperty("backdrop-filter", fallbackFilterCss(opticsNow));
|
|
884
941
|
el.style.setProperty("-webkit-backdrop-filter", fallbackFilterCss(opticsNow));
|
|
885
|
-
el.style.backgroundColor = bodyCss(opticsNow, sample, wasLight ? 1 : 0, accent);
|
|
886
942
|
}
|
|
887
|
-
|
|
888
|
-
wasLight = light;
|
|
943
|
+
if (body) el.style.backgroundColor = body;
|
|
889
944
|
const [tr, tg, tb] = ambientFrom(sample);
|
|
890
945
|
el.style.setProperty("--vireglass-ink", light ? "1" : "0");
|
|
891
946
|
el.style.setProperty("--vireglass-tint", `${tr} ${tg} ${tb}`);
|
|
@@ -893,8 +948,11 @@ function attachGlass(el, opts = {}) {
|
|
|
893
948
|
const inkLevel = Math.round((light ? INK_LIGHT : INK_DARK) * 255);
|
|
894
949
|
el.style.setProperty("--vireglass-ink-color", `rgb(${inkLevel} ${inkLevel} ${inkLevel})`);
|
|
895
950
|
el.style.setProperty("--vireglass-tint-color", rgbCss(tr, tg, tb));
|
|
896
|
-
el.style.setProperty(
|
|
897
|
-
|
|
951
|
+
el.style.setProperty(
|
|
952
|
+
"--vireglass-body-color",
|
|
953
|
+
body ?? bodyCss(settledOptics(), sample, light ? 1 : 0, accent, appear)
|
|
954
|
+
);
|
|
955
|
+
const pole = withPresence(resolveBody(opticsNow, sample, light ? 1 : 0), opticsNow).tintLuma;
|
|
898
956
|
el.style.setProperty(
|
|
899
957
|
"--vireglass-rim",
|
|
900
958
|
(opts.accessibility ?? a11y).increaseContrast ? contrastRimCss(pole, contrastRimLuma(pole)) : rimGradientCss(opticsNow, [tr, tg, tb], opts.light ?? REST_LIGHT, appear)
|
|
@@ -955,7 +1013,7 @@ function attachGlass(el, opts = {}) {
|
|
|
955
1013
|
el.style.setProperty("--vireglass-glow-opacity", "0");
|
|
956
1014
|
return;
|
|
957
1015
|
}
|
|
958
|
-
const [gr, gg, gb] = ambientFrom(
|
|
1016
|
+
const [gr, gg, gb] = ambientFrom(supplied ?? probeBackdrop(el));
|
|
959
1017
|
const cx = (x + geometry.width / 2) / geometry.width * 100;
|
|
960
1018
|
const cy = (y + geometry.height / 2) / geometry.height * 100;
|
|
961
1019
|
const reach = halfMinDp(geometry) * TOUCH_RADIUS_FRACTION;
|
|
@@ -1045,7 +1103,7 @@ function attachGlass(el, opts = {}) {
|
|
|
1045
1103
|
mapKey = "";
|
|
1046
1104
|
el.style.removeProperty("backdrop-filter");
|
|
1047
1105
|
el.style.removeProperty("-webkit-backdrop-filter");
|
|
1048
|
-
|
|
1106
|
+
if (opts.body !== false) restoreBackground();
|
|
1049
1107
|
el.style.removeProperty("--vireglass-ink");
|
|
1050
1108
|
el.style.removeProperty("--vireglass-tint");
|
|
1051
1109
|
el.style.removeProperty("--vireglass-body-density");
|
|
@@ -1093,12 +1151,16 @@ function attachGlass(el, opts = {}) {
|
|
|
1093
1151
|
mapKey = "";
|
|
1094
1152
|
apply();
|
|
1095
1153
|
},
|
|
1154
|
+
setSample(next) {
|
|
1155
|
+
supplied = next ?? void 0;
|
|
1156
|
+
apply();
|
|
1157
|
+
},
|
|
1096
1158
|
destroy
|
|
1097
1159
|
};
|
|
1098
1160
|
attached.set(el, handle);
|
|
1099
1161
|
return handle;
|
|
1100
1162
|
}
|
|
1101
1163
|
|
|
1102
|
-
export { RIM_WIDTH_PX, attachGlass, attachScrollEdge, boxShadowCss, buildDisplacementMap, buildSpectralMap, cached, clearMapCache, compositeLayers, contrastRimCss, createGlassGroup, hasSpectralEdge, lightConicAngle, mapCacheSize, paintFor, parseColor, probeBackdrop, renderDisplacementPixels, renderSpectralPixels, resetSupportCache, resolveBody, rimGradientCss, rimLobe, shadowAlphaFrom, statsFromSamples, supportsBackdropFilter, supportsSvgBackdropFilter, systemAccessibility, watchAccessibility, withPresence };
|
|
1164
|
+
export { RIM_WIDTH_PX, ambientLuma, attachGlass, attachScrollEdge, bodyLayer, boxShadowCss, buildDisplacementMap, buildSpectralMap, cached, clearMapCache, compositeLayers, contrastRimCss, createGlassGroup, hasSpectralEdge, lightConicAngle, mapCacheSize, paintFor, parseColor, probeBackdrop, renderDisplacementPixels, renderSpectralPixels, resetSupportCache, resolveBody, rimGradientCss, rimLineAlpha, rimLobe, rimStrength, shadowAlphaFrom, statsFromSamples, supportsBackdropFilter, supportsSvgBackdropFilter, systemAccessibility, watchAccessibility, withPresence };
|
|
1103
1165
|
//# sourceMappingURL=dom.js.map
|
|
1104
1166
|
//# sourceMappingURL=dom.js.map
|