vireglass 2.3.1 → 3.0.1
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-BOPIRMnL.d.cts → adapters--bXcGvhW.d.cts} +2 -2
- package/dist/{adapters-B_amRBqc.d.ts → adapters-BlMhc6pI.d.ts} +2 -2
- package/dist/{chunk-MMPK6DCK.js → chunk-CPSIY2DZ.js} +58 -8
- package/dist/chunk-CPSIY2DZ.js.map +1 -0
- package/dist/{chunk-UDPJLNFW.js → chunk-RWUR3OV6.js} +4 -4
- package/dist/{chunk-UDPJLNFW.js.map → chunk-RWUR3OV6.js.map} +1 -1
- 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-V47YU75P.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 +185 -58
- package/dist/dom.cjs.map +1 -1
- package/dist/dom.d.cts +73 -26
- package/dist/dom.d.ts +73 -26
- package/dist/dom.js +121 -57
- 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 +92 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- 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 +91 -39
- 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/dom/body.ts +93 -39
- package/src/dom/index.ts +50 -21
- package/src/dom/probe.ts +1 -1
- package/src/dom/rim.ts +69 -32
- 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/dist/chunk-MMPK6DCK.js.map +0 -1
- package/dist/chunk-V47YU75P.js.map +0 -1
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,30 +520,48 @@ 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
|
-
function contrastRimCss(bodyLuma, rimLuma) {
|
|
560
|
+
function contrastRimCss(bodyLuma, rimLuma, appear = 1) {
|
|
520
561
|
const v = to2552(rimLuma);
|
|
521
|
-
|
|
562
|
+
const present = clamp012(appear);
|
|
563
|
+
const colour = present >= 1 ? `rgb(${v},${v},${v})` : `rgba(${v},${v},${v},${present.toFixed(3)})`;
|
|
564
|
+
return `conic-gradient(${colour} 0deg, ${colour} 360deg)`;
|
|
522
565
|
}
|
|
523
566
|
|
|
524
567
|
// src/dom/nesting.ts
|
|
@@ -535,6 +578,15 @@ function warnIfNested(el) {
|
|
|
535
578
|
);
|
|
536
579
|
}
|
|
537
580
|
|
|
581
|
+
// src/dom/style-hold.ts
|
|
582
|
+
function holdProperty(style, name) {
|
|
583
|
+
const saved = style.getPropertyValue(name);
|
|
584
|
+
return () => {
|
|
585
|
+
if (saved) style.setProperty(name, saved);
|
|
586
|
+
else style.removeProperty(name);
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
|
|
538
590
|
// src/dom/scroll-edge.ts
|
|
539
591
|
function paintFor(style, side) {
|
|
540
592
|
const direction = side === "top" ? "to top" : "to bottom";
|
|
@@ -806,16 +858,16 @@ var to2553 = (v) => Math.round(Math.min(Math.max(v, 0), 1) * 255);
|
|
|
806
858
|
function rgbCss(r, g, b) {
|
|
807
859
|
return `rgb(${to2553(r)} ${to2553(g)} ${to2553(b)})`;
|
|
808
860
|
}
|
|
809
|
-
function bodyCss(optics, sample, ink, accent) {
|
|
810
|
-
const body = withPresence(resolveBody(optics, sample, ink), optics, sample);
|
|
861
|
+
function bodyCss(optics, sample, ink, accent, appear) {
|
|
811
862
|
if (accent) {
|
|
812
|
-
const
|
|
863
|
+
const settled = applyAppear(optics, appear);
|
|
864
|
+
const body = withPresence(resolveBody(settled, sample, ink), settled);
|
|
865
|
+
const [r, g, b] = accentTone(accent.color, sample.luma);
|
|
813
866
|
const amount = Math.max(accentAmount(accent), body.density);
|
|
814
|
-
return `rgba(${to2553(
|
|
867
|
+
return `rgba(${to2553(r)}, ${to2553(g)}, ${to2553(b)}, ${amount.toFixed(3)})`;
|
|
815
868
|
}
|
|
816
|
-
const
|
|
817
|
-
|
|
818
|
-
return `rgba(${to2553(hue(r))}, ${to2553(hue(g))}, ${to2553(hue(b))}, ${body.density.toFixed(3)})`;
|
|
869
|
+
const layer = bodyLayer(optics, sample, ink, ambientFrom(sample), appear);
|
|
870
|
+
return `rgba(${to2553(layer.r)}, ${to2553(layer.g)}, ${to2553(layer.b)}, ${layer.alpha.toFixed(3)})`;
|
|
819
871
|
}
|
|
820
872
|
function attachGlass(el, opts = {}) {
|
|
821
873
|
if (typeof document === "undefined") {
|
|
@@ -832,6 +884,7 @@ function attachGlass(el, opts = {}) {
|
|
|
832
884
|
const onlyWhenTouched = opts.variant === "interactive";
|
|
833
885
|
let appear = onlyWhenTouched ? 0 : opts.appear ?? 1;
|
|
834
886
|
let accent = opts.accent;
|
|
887
|
+
let supplied = opts.sample;
|
|
835
888
|
let a11y = systemAccessibility();
|
|
836
889
|
const stopWatchingA11y = watchAccessibility((next) => {
|
|
837
890
|
a11y = next;
|
|
@@ -843,13 +896,16 @@ function attachGlass(el, opts = {}) {
|
|
|
843
896
|
const host = hostFor(el);
|
|
844
897
|
ensureRimStyles(host);
|
|
845
898
|
el.setAttribute(GLASS_ATTR, "");
|
|
899
|
+
const restoreBackground = holdProperty(el.style, "background-color");
|
|
846
900
|
const positionWasStatic = getComputedStyle(el).position === "static";
|
|
847
901
|
if (positionWasStatic) el.style.setProperty("position", "relative");
|
|
848
|
-
function
|
|
902
|
+
function settledOptics(patch) {
|
|
849
903
|
const base = resolveOptics(patch ?? opts.material);
|
|
850
904
|
const scaled = applyGlassScale(base, opts.scale ?? GLASS_SCALE_DEFAULT);
|
|
851
|
-
|
|
852
|
-
|
|
905
|
+
return applyAccessibility(scaled, opts.accessibility ?? a11y);
|
|
906
|
+
}
|
|
907
|
+
function optics(patch) {
|
|
908
|
+
return applyAppear(settledOptics(patch), appear);
|
|
853
909
|
}
|
|
854
910
|
function morphState() {
|
|
855
911
|
if (!morph) return {};
|
|
@@ -864,7 +920,10 @@ function attachGlass(el, opts = {}) {
|
|
|
864
920
|
if (destroyed) return;
|
|
865
921
|
const geometry = opts.geometry ?? measureGeometry(el);
|
|
866
922
|
const opticsNow = optics();
|
|
867
|
-
const sample =
|
|
923
|
+
const sample = supplied ?? probeBackdrop(el);
|
|
924
|
+
const light = shouldInkBeLight(sample, wasLight);
|
|
925
|
+
wasLight = light;
|
|
926
|
+
const body = opts.body === false ? null : bodyCss(settledOptics(), sample, light ? 1 : 0, accent, appear);
|
|
868
927
|
if (svgSupported) {
|
|
869
928
|
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
929
|
if (key !== mapKey || !filterEl) {
|
|
@@ -882,10 +941,8 @@ function attachGlass(el, opts = {}) {
|
|
|
882
941
|
} else {
|
|
883
942
|
el.style.setProperty("backdrop-filter", fallbackFilterCss(opticsNow));
|
|
884
943
|
el.style.setProperty("-webkit-backdrop-filter", fallbackFilterCss(opticsNow));
|
|
885
|
-
el.style.backgroundColor = bodyCss(opticsNow, sample, wasLight ? 1 : 0, accent);
|
|
886
944
|
}
|
|
887
|
-
|
|
888
|
-
wasLight = light;
|
|
945
|
+
if (body) el.style.backgroundColor = body;
|
|
889
946
|
const [tr, tg, tb] = ambientFrom(sample);
|
|
890
947
|
el.style.setProperty("--vireglass-ink", light ? "1" : "0");
|
|
891
948
|
el.style.setProperty("--vireglass-tint", `${tr} ${tg} ${tb}`);
|
|
@@ -893,11 +950,14 @@ function attachGlass(el, opts = {}) {
|
|
|
893
950
|
const inkLevel = Math.round((light ? INK_LIGHT : INK_DARK) * 255);
|
|
894
951
|
el.style.setProperty("--vireglass-ink-color", `rgb(${inkLevel} ${inkLevel} ${inkLevel})`);
|
|
895
952
|
el.style.setProperty("--vireglass-tint-color", rgbCss(tr, tg, tb));
|
|
896
|
-
el.style.setProperty(
|
|
897
|
-
|
|
953
|
+
el.style.setProperty(
|
|
954
|
+
"--vireglass-body-color",
|
|
955
|
+
body ?? bodyCss(settledOptics(), sample, light ? 1 : 0, accent, appear)
|
|
956
|
+
);
|
|
957
|
+
const pole = withPresence(resolveBody(opticsNow, sample, light ? 1 : 0), opticsNow).tintLuma;
|
|
898
958
|
el.style.setProperty(
|
|
899
959
|
"--vireglass-rim",
|
|
900
|
-
(opts.accessibility ?? a11y).increaseContrast ? contrastRimCss(pole, contrastRimLuma(pole)) : rimGradientCss(opticsNow, [tr, tg, tb], opts.light ?? REST_LIGHT, appear)
|
|
960
|
+
(opts.accessibility ?? a11y).increaseContrast ? contrastRimCss(pole, contrastRimLuma(pole), appear) : rimGradientCss(opticsNow, [tr, tg, tb], opts.light ?? REST_LIGHT, appear)
|
|
901
961
|
);
|
|
902
962
|
el.style.setProperty("--vireglass-rim-width", `${RIM_WIDTH_PX}px`);
|
|
903
963
|
el.style.setProperty("--vireglass-radius", `${geometry.cornerRadius}px`);
|
|
@@ -955,7 +1015,7 @@ function attachGlass(el, opts = {}) {
|
|
|
955
1015
|
el.style.setProperty("--vireglass-glow-opacity", "0");
|
|
956
1016
|
return;
|
|
957
1017
|
}
|
|
958
|
-
const [gr, gg, gb] = ambientFrom(
|
|
1018
|
+
const [gr, gg, gb] = ambientFrom(supplied ?? probeBackdrop(el));
|
|
959
1019
|
const cx = (x + geometry.width / 2) / geometry.width * 100;
|
|
960
1020
|
const cy = (y + geometry.height / 2) / geometry.height * 100;
|
|
961
1021
|
const reach = halfMinDp(geometry) * TOUCH_RADIUS_FRACTION;
|
|
@@ -1045,7 +1105,7 @@ function attachGlass(el, opts = {}) {
|
|
|
1045
1105
|
mapKey = "";
|
|
1046
1106
|
el.style.removeProperty("backdrop-filter");
|
|
1047
1107
|
el.style.removeProperty("-webkit-backdrop-filter");
|
|
1048
|
-
|
|
1108
|
+
if (opts.body !== false) restoreBackground();
|
|
1049
1109
|
el.style.removeProperty("--vireglass-ink");
|
|
1050
1110
|
el.style.removeProperty("--vireglass-tint");
|
|
1051
1111
|
el.style.removeProperty("--vireglass-body-density");
|
|
@@ -1093,12 +1153,16 @@ function attachGlass(el, opts = {}) {
|
|
|
1093
1153
|
mapKey = "";
|
|
1094
1154
|
apply();
|
|
1095
1155
|
},
|
|
1156
|
+
setSample(next) {
|
|
1157
|
+
supplied = next ?? void 0;
|
|
1158
|
+
apply();
|
|
1159
|
+
},
|
|
1096
1160
|
destroy
|
|
1097
1161
|
};
|
|
1098
1162
|
attached.set(el, handle);
|
|
1099
1163
|
return handle;
|
|
1100
1164
|
}
|
|
1101
1165
|
|
|
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 };
|
|
1166
|
+
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
1167
|
//# sourceMappingURL=dom.js.map
|
|
1104
1168
|
//# sourceMappingURL=dom.js.map
|