fancy-ui-vue 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +12 -12
  2. package/dist/components/animated-testimonials/AnimatedTestimonials.vue.js +23 -12
  3. package/dist/components/bg-falling-stars/FallingStarsBg.vue.js +10 -1
  4. package/dist/components/bg-falling-stars/bg-falling-stars-core.d.ts +6 -0
  5. package/dist/components/bg-falling-stars/bg-falling-stars-core.js +24 -2
  6. package/dist/components/bg-stars/StarsBackground.vue.js +1 -1
  7. package/dist/components/bg-stars/StarsBackground.vue2.js +13 -1
  8. package/dist/components/bg-stars/bg-stars-core.d.ts +6 -0
  9. package/dist/components/bg-stars/bg-stars-core.js +21 -1
  10. package/dist/components/book/Book.vue.js +5 -83
  11. package/dist/components/book/Book.vue2.js +82 -1
  12. package/dist/components/box-reveal/BoxReveal.vue.js +5 -47
  13. package/dist/components/box-reveal/BoxReveal.vue2.js +48 -1
  14. package/dist/components/compare/StarField.vue.js +1 -1
  15. package/dist/components/container-text-flip/ContainerTextFlip.vue.js +1 -1
  16. package/dist/components/container-text-flip/ContainerTextFlip.vue2.js +14 -5
  17. package/dist/components/flickering-grid/FlickeringGrid.vue.js +19 -1
  18. package/dist/components/flickering-grid/flickering-grid-core.d.ts +6 -0
  19. package/dist/components/flickering-grid/flickering-grid-core.js +30 -1
  20. package/dist/components/flip-words/FlipWords.vue.js +1 -1
  21. package/dist/components/flip-words/FlipWords.vue2.js +14 -7
  22. package/dist/components/frost-glass/FrostGlass.vue.d.ts +31 -0
  23. package/dist/components/frost-glass/FrostGlass.vue.js +90 -0
  24. package/dist/components/frost-glass/FrostGlass.vue2.js +4 -0
  25. package/dist/components/frost-glass/frost-glass-core.d.ts +155 -0
  26. package/dist/components/frost-glass/frost-glass-core.js +820 -0
  27. package/dist/components/frost-glass/index.d.ts +2 -0
  28. package/dist/components/gift-reveal/GiftReveal.vue.d.ts +50 -0
  29. package/dist/components/gift-reveal/GiftReveal.vue.js +7 -0
  30. package/dist/components/gift-reveal/GiftReveal.vue2.js +177 -0
  31. package/dist/components/gift-reveal/gift-reveal-core.d.ts +109 -0
  32. package/dist/components/gift-reveal/gift-reveal-core.js +116 -0
  33. package/dist/components/gift-reveal/index.d.ts +2 -0
  34. package/dist/components/hyper-text/HyperText.vue.js +6 -97
  35. package/dist/components/hyper-text/HyperText.vue2.js +101 -0
  36. package/dist/components/letter-pullup/LetterPullup.vue.js +6 -38
  37. package/dist/components/letter-pullup/LetterPullup.vue2.js +40 -0
  38. package/dist/components/logo-cloud/AnimatedLogoCloud.vue.js +1 -1
  39. package/dist/components/matrix-rain/MatrixRain.vue.js +20 -1
  40. package/dist/components/matrix-rain/matrix-rain-core.d.ts +6 -0
  41. package/dist/components/matrix-rain/matrix-rain-core.js +28 -6
  42. package/dist/components/noise-reveal/NoiseReveal.vue.js +7 -0
  43. package/dist/components/noise-reveal/noise-reveal-core.js +23 -7
  44. package/dist/components/ornament/Ornament.vue.d.ts +29 -0
  45. package/dist/components/ornament/Ornament.vue.js +112 -0
  46. package/dist/components/ornament/Ornament.vue2.js +4 -0
  47. package/dist/components/ornament/index.d.ts +2 -0
  48. package/dist/components/ornament/ornament-core.d.ts +177 -0
  49. package/dist/components/ornament/ornament-core.js +861 -0
  50. package/dist/components/ripple/Ripple.vue.js +1 -1
  51. package/dist/components/ripple/Ripple.vue2.js +6 -1
  52. package/dist/components/snowfall/Snowfall.vue.d.ts +29 -0
  53. package/dist/components/snowfall/Snowfall.vue.js +81 -0
  54. package/dist/components/snowfall/Snowfall.vue2.js +4 -0
  55. package/dist/components/snowfall/index.d.ts +2 -0
  56. package/dist/components/snowfall/snowfall-core.d.ts +119 -0
  57. package/dist/components/snowfall/snowfall-core.js +483 -0
  58. package/dist/components/sparkles/Sparkles.vue.js +10 -1
  59. package/dist/components/sparkles/sparkles-core.d.ts +6 -0
  60. package/dist/components/sparkles/sparkles-core.js +26 -2
  61. package/dist/components/sparkles-text/SparklesText.vue.js +6 -88
  62. package/dist/components/sparkles-text/SparklesText.vue2.js +100 -0
  63. package/dist/components/string-lights/StringLights.vue.d.ts +35 -0
  64. package/dist/components/string-lights/StringLights.vue.js +7 -0
  65. package/dist/components/string-lights/StringLights.vue2.js +98 -0
  66. package/dist/components/string-lights/index.d.ts +2 -0
  67. package/dist/components/string-lights/string-lights-core.d.ts +157 -0
  68. package/dist/components/string-lights/string-lights-core.js +228 -0
  69. package/dist/components/terminal-text/TerminalText.vue.js +1 -1
  70. package/dist/components/terminal-text/TerminalText.vue2.js +36 -4
  71. package/dist/components/text-generate-effect/TextGenerateEffect.vue.js +5 -72
  72. package/dist/components/text-generate-effect/TextGenerateEffect.vue2.js +74 -1
  73. package/dist/components/text-reveal-card/TextRevealCard.vue.js +5 -101
  74. package/dist/components/text-reveal-card/TextRevealCard.vue2.js +98 -1
  75. package/dist/components/text-reveal-card/TextRevealStars.vue.js +1 -1
  76. package/dist/components/text-reveal-card/TextRevealStars.vue2.js +29 -12
  77. package/dist/index.d.ts +5 -0
  78. package/dist/index.js +393 -386
  79. package/dist/styles.css +1669 -185
  80. package/package.json +2 -2
  81. package/dist/components/hyper-text/HyperText.vue3.js +0 -5
  82. package/dist/components/letter-pullup/LetterPullup.vue3.js +0 -5
  83. package/dist/components/sparkles-text/SparklesText.vue3.js +0 -5
@@ -1,4 +1,51 @@
1
- import _sfc_main from "./BoxReveal.vue.js";
1
+ import { defineComponent, useAttrs, useTemplateRef, computed, createElementBlock, openBlock, mergeProps, unref, createElementVNode, normalizeStyle, renderSlot } from "vue";
2
+ import { cn } from "../../utils.js";
3
+ import { useInView } from "../../internals/motion/use-in-view.js";
4
+ const _sfc_main = /* @__PURE__ */ defineComponent({
5
+ ...{ name: "BoxReveal", inheritAttrs: false },
6
+ __name: "BoxReveal",
7
+ props: {
8
+ color: { default: "#5046e6" },
9
+ duration: { default: 0.5 },
10
+ delay: { default: 0.25 },
11
+ class: { type: [Boolean, null, String, Object, Array] }
12
+ },
13
+ setup(__props) {
14
+ const attrs = useAttrs();
15
+ const containerRef = useTemplateRef("containerRef");
16
+ const isInView = useInView(containerRef, () => ({ threshold: 0.1, once: true }));
17
+ const contentStyle = computed(() => ({
18
+ opacity: isInView.value ? "1" : "0",
19
+ transform: `translateY(${isInView.value ? 0 : 25}px)`,
20
+ "--box-reveal-duration": `${__props.duration}s`,
21
+ "--box-reveal-delay": `${__props.delay * 2}s`
22
+ }));
23
+ const overlayStyle = computed(() => ({
24
+ background: `${__props.color}`,
25
+ left: isInView.value ? "100%" : "0%",
26
+ "--box-reveal-duration": `${__props.duration}s`,
27
+ "--box-reveal-delay": `${__props.delay}s`
28
+ }));
29
+ return (_ctx, _cache) => {
30
+ return openBlock(), createElementBlock("div", mergeProps(unref(attrs), {
31
+ ref_key: "containerRef",
32
+ ref: containerRef,
33
+ class: unref(cn)("box-reveal relative overflow-hidden", __props.class)
34
+ }), [
35
+ createElementVNode("div", {
36
+ class: "box-reveal-content",
37
+ style: normalizeStyle(contentStyle.value)
38
+ }, [
39
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
40
+ ], 4),
41
+ createElementVNode("div", {
42
+ class: "box-reveal-overlay absolute inset-0 z-20",
43
+ style: normalizeStyle(overlayStyle.value)
44
+ }, null, 4)
45
+ ], 16);
46
+ };
47
+ }
48
+ });
2
49
  export {
3
50
  _sfc_main as default
4
51
  };
@@ -1,7 +1,7 @@
1
1
  import _sfc_main from "./StarField.vue2.js";
2
2
  /* empty css */
3
3
  import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
4
- const StarField = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-9fadc287"]]);
4
+ const StarField = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-06a2b4e6"]]);
5
5
  export {
6
6
  StarField as default
7
7
  };
@@ -2,7 +2,7 @@ import _sfc_main from "./ContainerTextFlip.vue2.js";
2
2
  /* empty css */
3
3
  /* empty css */
4
4
  import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
5
- const ContainerTextFlip = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-58f10267"]]);
5
+ const ContainerTextFlip = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ad8bc4bd"]]);
6
6
  export {
7
7
  ContainerTextFlip as default
8
8
  };
@@ -1,5 +1,6 @@
1
- import { defineComponent, useAttrs, ref, computed, onMounted, onBeforeUnmount, createElementBlock, openBlock, mergeProps, unref, createElementVNode, normalizeClass, Fragment, renderList, normalizeStyle, toDisplayString } from "vue";
1
+ import { defineComponent, useAttrs, ref, computed, onMounted, watch, createElementBlock, openBlock, mergeProps, unref, createElementVNode, normalizeClass, Fragment, renderList, normalizeStyle, toDisplayString } from "vue";
2
2
  import { cn } from "../../utils.js";
3
+ import { useReducedMotion } from "../../internals/motion/use-media-query.js";
3
4
  const _hoisted_1 = { class: "inline-block" };
4
5
  const _sfc_main = /* @__PURE__ */ defineComponent({
5
6
  ...{ name: "ContainerTextFlip", inheritAttrs: false },
@@ -16,11 +17,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16
17
  const currentWordIndex = ref(0);
17
18
  const currentWord = computed(() => __props.words[currentWordIndex.value] ?? "");
18
19
  const letters = computed(() => currentWord.value.split(""));
20
+ const reducedMotion = useReducedMotion();
19
21
  onMounted(() => {
20
- const id = setInterval(() => {
21
- currentWordIndex.value = (currentWordIndex.value + 1) % __props.words.length;
22
- }, __props.interval);
23
- onBeforeUnmount(() => clearInterval(id));
22
+ watch(
23
+ reducedMotion,
24
+ (reduced, _old, onCleanup) => {
25
+ if (reduced) return;
26
+ const id = setInterval(() => {
27
+ currentWordIndex.value = (currentWordIndex.value + 1) % __props.words.length;
28
+ }, __props.interval);
29
+ onCleanup(() => clearInterval(id));
30
+ },
31
+ { flush: "post", immediate: true }
32
+ );
24
33
  });
25
34
  return (_ctx, _cache) => {
26
35
  return openBlock(), createElementBlock("p", mergeProps(unref(attrs), {
@@ -1,5 +1,6 @@
1
1
  import { defineComponent, useTemplateRef, watch, onMounted, onBeforeUnmount, createElementBlock, openBlock, normalizeClass, unref, createElementVNode } from "vue";
2
2
  import { cn } from "../../utils.js";
3
+ import { useReducedMotion } from "../../internals/motion/use-media-query.js";
3
4
  import { createFlickeringGrid } from "./flickering-grid-core.js";
4
5
  const _hoisted_1 = {
5
6
  ref: "canvas",
@@ -24,6 +25,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
24
25
  let engine = null;
25
26
  let resizeObserver = null;
26
27
  let intersectionObserver = null;
28
+ const reducedMotion = useReducedMotion();
27
29
  watch(
28
30
  () => ({ squareSize: __props.squareSize, gridGap: __props.gridGap, flickerChance: __props.flickerChance, color: __props.color, maxOpacity: __props.maxOpacity, width: __props.width, height: __props.height }),
29
31
  (next) => {
@@ -37,7 +39,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
37
39
  if (!container || !canvas) return;
38
40
  engine = createFlickeringGrid(
39
41
  { container, canvas },
40
- { squareSize: __props.squareSize, gridGap: __props.gridGap, flickerChance: __props.flickerChance, color: __props.color, maxOpacity: __props.maxOpacity, width: __props.width, height: __props.height }
42
+ {
43
+ squareSize: __props.squareSize,
44
+ gridGap: __props.gridGap,
45
+ flickerChance: __props.flickerChance,
46
+ color: __props.color,
47
+ maxOpacity: __props.maxOpacity,
48
+ width: __props.width,
49
+ height: __props.height,
50
+ reducedMotion: reducedMotion.value
51
+ }
41
52
  );
42
53
  if (!engine) return;
43
54
  resizeObserver = new ResizeObserver(() => {
@@ -60,6 +71,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
60
71
  engine?.destroy();
61
72
  engine = null;
62
73
  });
74
+ watch(
75
+ reducedMotion,
76
+ (next) => {
77
+ engine?.setOptions({ reducedMotion: next });
78
+ },
79
+ { flush: "post" }
80
+ );
63
81
  return (_ctx, _cache) => {
64
82
  return openBlock(), createElementBlock("div", {
65
83
  ref: "container",
@@ -27,6 +27,12 @@ export interface FlickeringGridLiveOptions {
27
27
  width?: number;
28
28
  /** Fixed height in pixels (defaults to container height) */
29
29
  height?: number;
30
+ /**
31
+ * Reduced-motion preference, owned by the wrapper (the core never reads
32
+ * `matchMedia`). When true the grid paints one still frame while in view and
33
+ * idles; a flip back to false resumes the flicker.
34
+ */
35
+ reducedMotion?: boolean;
30
36
  }
31
37
  export interface FlickeringGridEngine {
32
38
  setOptions(next: Partial<FlickeringGridLiveOptions>): void;
@@ -56,7 +56,10 @@ function createColorResolver(el) {
56
56
  function createFlickeringGrid(el, options, random = Math.random) {
57
57
  const ctx = el.canvas.getContext("2d");
58
58
  if (!ctx) return null;
59
- const opts = { ...DEFAULTS, ...options };
59
+ const opts = {
60
+ ...DEFAULTS,
61
+ ...options
62
+ };
60
63
  let isInView = false;
61
64
  let animationFrameId;
62
65
  let lastTime = 0;
@@ -112,14 +115,38 @@ function createFlickeringGrid(el, options, random = Math.random) {
112
115
  if (!isInView || destroyed) return;
113
116
  const deltaTime = (time - lastTime) / 1e3;
114
117
  lastTime = time;
118
+ if (opts.reducedMotion) {
119
+ drawGrid();
120
+ animationFrameId = void 0;
121
+ return;
122
+ }
115
123
  updateSquares(deltaTime);
116
124
  drawGrid();
117
125
  animationFrameId = requestAnimationFrame(animate);
118
126
  }
127
+ function repaintIdle() {
128
+ if (opts.reducedMotion && isInView && animationFrameId === void 0) drawGrid();
129
+ }
119
130
  updateCanvasSize();
131
+ const themeObserver = typeof MutationObserver !== "undefined" ? new MutationObserver(() => {
132
+ if (CURRENT_COLOR.test(opts.color)) repaintIdle();
133
+ }) : null;
134
+ themeObserver?.observe(document.documentElement, {
135
+ attributes: true,
136
+ attributeFilter: ["class"]
137
+ });
120
138
  return {
121
139
  setOptions(next) {
140
+ if (destroyed) return;
141
+ const wasReduced = opts.reducedMotion;
122
142
  Object.assign(opts, next);
143
+ if (wasReduced && !opts.reducedMotion) {
144
+ if (isInView && animationFrameId === void 0) {
145
+ animationFrameId = requestAnimationFrame(animate);
146
+ }
147
+ } else {
148
+ repaintIdle();
149
+ }
123
150
  },
124
151
  setInView(nextIsInView) {
125
152
  if (destroyed) return;
@@ -131,10 +158,12 @@ function createFlickeringGrid(el, options, random = Math.random) {
131
158
  resize() {
132
159
  if (destroyed) return;
133
160
  updateCanvasSize();
161
+ repaintIdle();
134
162
  },
135
163
  destroy() {
136
164
  if (destroyed) return;
137
165
  destroyed = true;
166
+ themeObserver?.disconnect();
138
167
  if (animationFrameId !== void 0) {
139
168
  cancelAnimationFrame(animationFrameId);
140
169
  animationFrameId = void 0;
@@ -2,7 +2,7 @@ import _sfc_main from "./FlipWords.vue2.js";
2
2
  /* empty css */
3
3
  /* empty css */
4
4
  import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
5
- const FlipWords = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-2d9070d7"]]);
5
+ const FlipWords = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-8436152b"]]);
6
6
  export {
7
7
  FlipWords as default
8
8
  };
@@ -1,5 +1,6 @@
1
1
  import { defineComponent, ref, computed, watch, onMounted, onBeforeUnmount, createElementBlock, openBlock, normalizeClass, unref, Fragment, renderList, normalizeStyle, createTextVNode, createElementVNode, toDisplayString } from "vue";
2
2
  import { cn } from "../../utils.js";
3
+ import { useReducedMotion } from "../../internals/motion/use-media-query.js";
3
4
  const _hoisted_1 = { class: "flip-words relative inline-block px-2" };
4
5
  const _sfc_main = /* @__PURE__ */ defineComponent({
5
6
  ...{ name: "FlipWords", inheritAttrs: false },
@@ -13,6 +14,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
13
14
  const EXIT_MS = 600;
14
15
  const currentIndex = ref(0);
15
16
  const isExiting = ref(false);
17
+ const reducedMotion = useReducedMotion();
16
18
  let timeoutId = null;
17
19
  let exitTimeoutId = null;
18
20
  const currentWord = computed(() => __props.words[currentIndex.value] ?? "");
@@ -37,8 +39,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
37
39
  timeoutId = setTimeout(startAnimation, d);
38
40
  }
39
41
  watch(
40
- () => [currentIndex.value, isExiting.value, __props.words.length, __props.duration],
41
- ([index, exiting, , d]) => {
42
+ () => [currentIndex.value, isExiting.value, __props.words.length, __props.duration, reducedMotion.value],
43
+ ([index, exiting, , d, reduced]) => {
44
+ if (reduced) {
45
+ if (timeoutId) clearTimeout(timeoutId);
46
+ timeoutId = null;
47
+ return;
48
+ }
42
49
  if (!exiting) {
43
50
  scheduleNext(index, d);
44
51
  }
@@ -46,7 +53,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
46
53
  { flush: "post" }
47
54
  );
48
55
  onMounted(() => {
49
- if (!isExiting.value) {
56
+ if (!isExiting.value && !reducedMotion.value) {
50
57
  scheduleNext(currentIndex.value, __props.duration);
51
58
  }
52
59
  });
@@ -69,14 +76,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
69
76
  (openBlock(true), createElementBlock(Fragment, null, renderList(splitWords.value, (wordObj, wordIndex) => {
70
77
  return openBlock(), createElementBlock("span", {
71
78
  key: wordObj.word + wordIndex,
72
- class: "flip-words-word inline-block whitespace-nowrap opacity-0",
73
- style: normalizeStyle(`animation:flipFadeInWord 0.3s ease forwards;animation-delay:${wordIndex * 0.3}s`)
79
+ class: "flip-words-word inline-block whitespace-nowrap",
80
+ style: normalizeStyle({ "--flip-words-word-delay": `${wordIndex * 0.3}s` })
74
81
  }, [
75
82
  (openBlock(true), createElementBlock(Fragment, null, renderList(wordObj.letters, (letter, letterIndex) => {
76
83
  return openBlock(), createElementBlock("span", {
77
84
  key: wordObj.word + letterIndex,
78
- class: "inline-block opacity-0",
79
- style: normalizeStyle(`animation:flipFadeInLetter 0.2s ease forwards;animation-delay:${wordIndex * 0.3 + letterIndex * 0.05}s`)
85
+ class: "flip-words-letter inline-block",
86
+ style: normalizeStyle({ "--flip-words-letter-delay": `${wordIndex * 0.3 + letterIndex * 0.05}s` })
80
87
  }, toDisplayString(letter), 5);
81
88
  }), 128)),
82
89
  _cache[0] || (_cache[0] = createTextVNode(toDisplayString(" "), -1)),
@@ -0,0 +1,31 @@
1
+ import type { HTMLAttributes } from "vue";
2
+ export interface FrostGlassProps {
3
+ /** How far the frost reaches toward the centre, 0..1 of the half short side. */
4
+ coverage?: number;
5
+ /** Seconds the frost takes to grow in from the edges on mount. 0 shows it grown. */
6
+ growth?: number;
7
+ /** The pointer melts a trail through the frost. */
8
+ melt?: boolean;
9
+ /** Seconds a fully melted spot takes to freeze over again. */
10
+ refreeze?: number;
11
+ /** Cold tint of the ice, `#rgb` or `#rrggbb`. */
12
+ tint?: string;
13
+ /** Strength of the slow glints on the crystal ridges, 0..1. */
14
+ sparkle?: number;
15
+ /** Blur behind the frost, in pixels. 0 turns it off. */
16
+ blur?: number;
17
+ /** Picks the crystal layout. The same seed always grows the same frost. */
18
+ seed?: number;
19
+ /** Additional CSS classes */
20
+ class?: HTMLAttributes["class"];
21
+ }
22
+ declare const _default: typeof __VLS_export;
23
+ export default _default;
24
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<FrostGlassProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FrostGlassProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
25
+ default?: () => unknown;
26
+ }>;
27
+ type __VLS_WithSlots<T, S> = T & {
28
+ new (): {
29
+ $slots: S;
30
+ };
31
+ };
@@ -0,0 +1,90 @@
1
+ import { defineComponent, useTemplateRef, computed, shallowRef, onMounted, onBeforeUnmount, watch, createElementBlock, openBlock, mergeProps, unref, renderSlot, createElementVNode, createCommentVNode, normalizeStyle } from "vue";
2
+ import { cn } from "../../utils.js";
3
+ import { useReducedMotion } from "../../internals/motion/use-media-query.js";
4
+ import { FROST_GLASS_DEFAULTS, blurLayerDeclarations, createFrostGlass, fallbackBackground } from "./frost-glass-core.js";
5
+ const _hoisted_1 = ["data-ready"];
6
+ const _hoisted_2 = {
7
+ ref: "canvas",
8
+ class: "pointer-events-none absolute inset-0 block h-full w-full rounded-[inherit]",
9
+ "aria-hidden": "true"
10
+ };
11
+ const _sfc_main = /* @__PURE__ */ defineComponent({
12
+ ...{ name: "FrostGlass", inheritAttrs: false },
13
+ __name: "FrostGlass",
14
+ props: {
15
+ coverage: { default: () => FROST_GLASS_DEFAULTS.coverage },
16
+ growth: { default: () => FROST_GLASS_DEFAULTS.growth },
17
+ melt: { type: Boolean, default: () => FROST_GLASS_DEFAULTS.melt },
18
+ refreeze: { default: () => FROST_GLASS_DEFAULTS.refreeze },
19
+ tint: { default: () => FROST_GLASS_DEFAULTS.tint },
20
+ sparkle: { default: () => FROST_GLASS_DEFAULTS.sparkle },
21
+ blur: { default: () => FROST_GLASS_DEFAULTS.blur },
22
+ seed: { default: () => FROST_GLASS_DEFAULTS.seed },
23
+ class: { type: [Boolean, null, String, Object, Array], default: "" }
24
+ },
25
+ setup(__props) {
26
+ const rootRef = useTemplateRef("root");
27
+ const canvasRef = useTemplateRef("canvas");
28
+ const blurRef = useTemplateRef("blurLayer");
29
+ const blurStyle = computed(() => Object.fromEntries(blurLayerDeclarations(__props.blur, __props.coverage)));
30
+ const engine = shallowRef(null);
31
+ const reducedMotion = useReducedMotion();
32
+ function liveOptions() {
33
+ return {
34
+ coverage: __props.coverage,
35
+ growth: __props.growth,
36
+ melt: __props.melt,
37
+ refreeze: __props.refreeze,
38
+ tint: __props.tint,
39
+ sparkle: __props.sparkle,
40
+ reducedMotion: reducedMotion.value
41
+ };
42
+ }
43
+ onMounted(() => {
44
+ const canvas = canvasRef.value;
45
+ const root = rootRef.value;
46
+ if (!canvas || !root) return;
47
+ engine.value = createFrostGlass(
48
+ { canvas, root, blurLayer: blurRef.value },
49
+ { ...liveOptions(), seed: __props.seed }
50
+ );
51
+ });
52
+ onBeforeUnmount(() => {
53
+ const instance = engine.value;
54
+ if (!instance) return;
55
+ engine.value = null;
56
+ instance.destroy();
57
+ });
58
+ watch(
59
+ [engine, liveOptions],
60
+ ([currentEngine, options]) => {
61
+ currentEngine?.setOptions(options);
62
+ },
63
+ { flush: "post" }
64
+ );
65
+ return (_ctx, _cache) => {
66
+ return openBlock(), createElementBlock("div", mergeProps({ ref: "root" }, _ctx.$attrs, {
67
+ class: unref(cn)("fancy-frost-glass relative isolate overflow-hidden", __props.class),
68
+ "data-ready": engine.value ? "" : void 0
69
+ }), [
70
+ renderSlot(_ctx.$slots, "default"),
71
+ createElementVNode("div", {
72
+ ref: "blurLayer",
73
+ class: "fancy-frost-glass-blur pointer-events-none absolute inset-0 rounded-[inherit]",
74
+ style: normalizeStyle(blurStyle.value),
75
+ "aria-hidden": "true"
76
+ }, null, 4),
77
+ !engine.value ? (openBlock(), createElementBlock("div", {
78
+ key: 0,
79
+ class: "fancy-frost-glass-fallback pointer-events-none absolute inset-0 rounded-[inherit]",
80
+ style: normalizeStyle({ background: unref(fallbackBackground)(__props.tint, __props.coverage) }),
81
+ "aria-hidden": "true"
82
+ }, null, 4)) : createCommentVNode("", true),
83
+ createElementVNode("canvas", _hoisted_2, null, 512)
84
+ ], 16, _hoisted_1);
85
+ };
86
+ }
87
+ });
88
+ export {
89
+ _sfc_main as default
90
+ };
@@ -0,0 +1,4 @@
1
+ import _sfc_main from "./FrostGlass.vue.js";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -0,0 +1,155 @@
1
+ /**
2
+ * FrostGlass engine: ice crystals growing inward from the edges of a pane,
3
+ * drawn by one WebGL fragment shader over whatever the pane holds.
4
+ *
5
+ * Framework-free and shared byte-for-byte by the Svelte, React and Vue
6
+ * wrappers (see shared-cores.json). Nothing here touches the DOM at import
7
+ * time; `createFrostGlass` is the only entry that needs a browser.
8
+ *
9
+ * The ice has a thickness: 1 at the border, 0 at a lobed front (the distance
10
+ * to the edge, warped by noise). Where it is thick, fine grains of rime merge
11
+ * into a continuous translucent crust; toward the front they break up into
12
+ * specks. Dendrites are rooted on the border at three spacings and grow along
13
+ * the edge normal, branching at about 60 degrees; each family only exists
14
+ * where the ice is thick enough, so every crystal stays attached to the frozen
15
+ * zone and growth simply moves the front inward.
16
+ *
17
+ * Warmth from the pointer is kept in a small grid of cells on the CPU and
18
+ * uploaded as a byte texture. Warmth subtracts from the thickness, so a warm
19
+ * trail is clear glass with a wet rim, and as it cools the ice creeps back in
20
+ * from the trail's edges.
21
+ */
22
+ export interface FrostGlassElements {
23
+ /** The canvas the frost is drawn on. It should cover `root`. */
24
+ canvas: HTMLCanvasElement;
25
+ /** The element that hears the pointer. Usually the pane itself. */
26
+ root: HTMLElement;
27
+ /**
28
+ * Optional layer carrying `backdrop-filter: blur()`. The engine writes the
29
+ * frost's shape into its `--fancy-frost-mask` custom property, so the blur
30
+ * follows the frost, including melted trails.
31
+ */
32
+ blurLayer?: HTMLElement | null;
33
+ }
34
+ export interface FrostGlassLiveOptions {
35
+ /** How far the frost reaches toward the centre, 0..1 of the half short side. */
36
+ coverage?: number;
37
+ /** Seconds the frost takes to grow from the edges on mount. 0 shows it grown. */
38
+ growth?: number;
39
+ /** The pointer melts a trail through the frost. */
40
+ melt?: boolean;
41
+ /** Seconds a fully melted spot takes to freeze over again. */
42
+ refreeze?: number;
43
+ /** Cold tint of the ice, `#rgb` or `#rrggbb`. */
44
+ tint?: string;
45
+ /** Strength of the slow glints on the crystal ridges, 0..1. 0 lets the loop sleep. */
46
+ sparkle?: number;
47
+ /** Frost fully grown and still: no growth, no glints, no melting. */
48
+ reducedMotion?: boolean;
49
+ }
50
+ export interface FrostGlassInitOptions extends FrostGlassLiveOptions {
51
+ /** Picks the crystal layout. The same seed always grows the same frost. */
52
+ seed?: number;
53
+ /**
54
+ * Lose the WebGL context on destroy. Leave on unless the same canvas element
55
+ * is handed to a second engine afterwards (a context cannot be un-lost).
56
+ */
57
+ releaseContext?: boolean;
58
+ }
59
+ export interface FrostGlassEngine {
60
+ setOptions(options: FrostGlassLiveOptions): void;
61
+ /** Growth progress 0..1 and whether any warmth is left, for tests. */
62
+ getState(): {
63
+ grown: number;
64
+ warm: boolean;
65
+ };
66
+ destroy(): void;
67
+ }
68
+ export declare const FROST_GLASS_DEFAULTS: {
69
+ readonly coverage: 0.45;
70
+ readonly growth: 2.4;
71
+ readonly melt: true;
72
+ readonly refreeze: 4;
73
+ readonly tint: "#cfe6ff";
74
+ readonly sparkle: 0.5;
75
+ readonly blur: 3;
76
+ readonly seed: 7;
77
+ };
78
+ /** Device pixel ratio above this is not worth its fill cost for a soft effect. */
79
+ export declare const MAX_PIXEL_RATIO = 2;
80
+ /** Longest step the clock integrates, so a background tab does not jump ahead. */
81
+ export declare const MAX_STEP: number;
82
+ /** Side of one warmth cell, in CSS pixels. */
83
+ export declare const HEAT_CELL = 6;
84
+ /** Most warmth cells along the longer side of the pane. */
85
+ export declare const HEAT_MAX_CELLS = 128;
86
+ /** Radius of the warm spot the pointer leaves, in CSS pixels. */
87
+ export declare const MELT_RADIUS = 26;
88
+ /** Shortest wait between two updates of the blur mask, in milliseconds. */
89
+ export declare const MASK_INTERVAL = 66;
90
+ /** Frames per second while only the glints move. They are slow; 30 is plenty. */
91
+ export declare const SPARKLE_FPS = 30;
92
+ /** Parse `#rgb` / `#rrggbb` to 0..1 components; anything else gives the fallback. */
93
+ export declare function parseHexColor(value: string | undefined, fallback: readonly [number, number, number]): [number, number, number];
94
+ /** The `coverage` prop as used: clamped to 0..1, NaN as 0. */
95
+ export declare function clampCoverage(coverage: number): number;
96
+ /**
97
+ * Frost front after `elapsed` seconds of a `growth`-second spread, 0..1.
98
+ * Fast at first and settling at the end, the way frost slows as the pane cools.
99
+ */
100
+ export declare function growthProgress(elapsed: number, growth: number): number;
101
+ /**
102
+ * The CSS stand-in for the frost, shown on the server, before the first frame
103
+ * and without WebGL: a cold vignette reaching `coverage` toward the centre.
104
+ */
105
+ export declare function fallbackBackground(tint: string, coverage: number): string;
106
+ /** The CSS mask that shapes the blur layer until the engine draws a real one. */
107
+ export declare function fallbackMask(coverage: number): string;
108
+ /**
109
+ * CSS declarations for the blur layer, as `[property, value]` pairs in
110
+ * kebab-case. The mask reads `--fancy-frost-mask`, which the engine fills with
111
+ * the live frost shape; until then the CSS mask above stands in. `blur` of 0
112
+ * (or less) hides the layer.
113
+ */
114
+ export declare function blurLayerDeclarations(blur: number, coverage: number): Array<[string, string]>;
115
+ /** `blurLayerDeclarations` as one inline style string. */
116
+ export declare function blurLayerStyle(blur: number, coverage: number): string;
117
+ /**
118
+ * How frosted a point is, 0..1, from its distance to the nearest edge as a
119
+ * fraction of the half short side, for a front that has reached `reach`.
120
+ * The broad shape the shader's crystals fill; the blur mask uses it directly.
121
+ */
122
+ export declare function frostAmount(edgeDistance: number, reach: number): number;
123
+ /** Smooth value noise in 0..1, for the ragged edge of the blur mask. */
124
+ export declare function valueNoise(x: number, y: number, seed: number): number;
125
+ /** Warmth left by the pointer, one value per cell, 0 (frozen) to 1 (melted). */
126
+ export interface HeatGrid {
127
+ cols: number;
128
+ rows: number;
129
+ /** Side of one cell in CSS pixels. */
130
+ cell: number;
131
+ data: Float32Array;
132
+ }
133
+ /** A cold grid sized for a `width` × `height` pane in CSS pixels. */
134
+ export declare function createHeatGrid(width: number, height: number): HeatGrid;
135
+ /**
136
+ * Warm the grid along the segment from (x0, y0) to (x1, y1), CSS pixels, with
137
+ * a soft round brush of `radius`. Warmth adds up to 1 and never beyond, so a
138
+ * slow pointer clears the frost while a quick swipe only thins it.
139
+ */
140
+ export declare function depositHeat(grid: HeatGrid, x0: number, y0: number, x1: number, y1: number, radius: number, amount: number): void;
141
+ /**
142
+ * Cool the grid by `dt` seconds: a fully melted cell takes `refreeze` seconds
143
+ * to freeze again. Returns true while any warmth is left.
144
+ */
145
+ export declare function coolHeat(grid: HeatGrid, dt: number, refreeze: number): boolean;
146
+ /** Seeded generator, so a `seed` always lays out the same frost. */
147
+ export declare function mulberry32(seed: number): () => number;
148
+ export declare const VERTEX_SHADER = "\nattribute vec2 aPos;\nvoid main() { gl_Position = vec4(aPos, 0.0, 1.0); }\n";
149
+ export declare const FRAGMENT_SHADER = "\nprecision highp float;\n\nuniform vec2 uRes;\nuniform float uScale;\nuniform float uReach;\nuniform float uTime;\nuniform float uSparkle;\nuniform vec3 uTint;\nuniform vec2 uSeed;\nuniform sampler2D uHeat;\nuniform vec2 uHeatSpan;\nuniform vec2 uHeatCells;\nuniform float uRadius;\n\nvec2 size;\nfloat halfSide;\n\nfloat hash(vec2 p) {\n\tp = fract(p * vec2(123.34, 456.21) + uSeed);\n\tp += dot(p, p + 45.32);\n\treturn fract(p.x * p.y);\n}\n\nfloat noise(vec2 p) {\n\tvec2 i = floor(p);\n\tvec2 f = fract(p);\n\tvec2 u = f * f * (3.0 - 2.0 * f);\n\treturn mix(mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),\n\t\tmix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x), u.y);\n}\n\nfloat fbm(vec2 p) {\n\tfloat v = 0.0;\n\tfloat a = 0.5;\n\tfor (int i = 0; i < 4; i++) {\n\t\tv += a * noise(p);\n\t\tp = mat2(1.6, 1.2, -1.2, 1.6) * p;\n\t\ta *= 0.5;\n\t}\n\treturn v;\n}\n\n// Distance to the nearest edge, as a fraction of the half short side.\n// Distance inside the pane's rounded rectangle, in CSS pixels, so the ice\n// follows the corners instead of piling up in the clipped-off square ones.\nfloat inset(vec2 p) {\n\tvec2 h = size * 0.5;\n\tfloat r = min(uRadius, min(h.x, h.y));\n\tvec2 q = abs(p - h) - (h - r);\n\treturn r - length(max(q, 0.0)) - min(max(q.x, q.y), 0.0);\n}\n\nfloat edgeDistance(vec2 p) {\n\treturn inset(p) / halfSide;\n}\n\n// Unit vector pointing away from the nearest edge.\nvec2 inward(vec2 p) {\n\tfloat dx = min(p.x, size.x - p.x);\n\tfloat dy = min(p.y, size.y - p.y);\n\tif (dx < dy) return vec2(p.x < size.x * 0.5 ? 1.0 : -1.0, 0.0);\n\treturn vec2(0.0, p.y < size.y * 0.5 ? 1.0 : -1.0);\n}\n\n// Warmth between cell centres, blended with a smoothstep weight instead of the\n// hardware's straight line, so a warm spot is round rather than octagonal.\nfloat heatAt(vec2 p) {\n\tvec2 g = p / (uHeatSpan / uHeatCells) - 0.5;\n\tvec2 i = floor(g);\n\tvec2 f = g - i;\n\tf = f * f * (3.0 - 2.0 * f);\n\tvec2 inv = 1.0 / uHeatCells;\n\tfloat a = texture2D(uHeat, (i + 0.5) * inv).r;\n\tfloat b = texture2D(uHeat, (i + vec2(1.5, 0.5)) * inv).r;\n\tfloat c = texture2D(uHeat, (i + vec2(0.5, 1.5)) * inv).r;\n\tfloat d = texture2D(uHeat, (i + 1.5) * inv).r;\n\treturn mix(mix(a, b, f.x), mix(c, d, f.x), f.y);\n}\n\n// Where p sits relative to its nearest edge: x runs along that edge, y is the\n// distance into the pane in CSS pixels. Each edge gets its own stretch of x so\n// the four borders do not repeat one another.\nvec2 edgeFrame(vec2 p) {\n\tfloat left = p.x;\n\tfloat right = size.x - p.x;\n\tfloat top = p.y;\n\tfloat bottom = size.y - p.y;\n\tfloat m = min(min(left, right), min(top, bottom));\n\tfloat r = inset(p);\n\tif (m == left) return vec2(p.y, r);\n\tif (m == right) return vec2(p.y + 3000.0, r);\n\tif (m == top) return vec2(p.x + 6000.0, r);\n\treturn vec2(p.x + 9000.0, r);\n}\n\n// One family of dendrites rooted on the border, every `spacing` pixels along\n// it. Each has a spine growing inward (bent by noise, leaning a little), and\n// side branches leaving it at about 60 degrees, longest where the ice is\n// thick. `reachT` is how thick the ice must be for this family to exist, so\n// small growth only fills in behind the big dendrites.\n// x: bright ridge, y: shadow beside it (the side away from the light).\nvec2 dendrites(vec2 f, float spacing, float salt, float thick, float lead, float width) {\n\tvec2 acc = vec2(0.0);\n\tfloat aa = 0.8 / uScale;\n\tfloat k0 = floor(f.x / spacing);\n\tfor (int i = -1; i <= 1; i++) {\n\t\tfloat k = k0 + float(i);\n\t\tfloat h1 = hash(vec2(k, salt));\n\t\tfloat h2 = hash(vec2(k, salt + 7.0));\n\t\tfloat h3 = hash(vec2(k, salt + 13.0));\n\t\t// Some roots never sprout, so the border is not a comb.\n\t\tif (h3 < 0.18) continue;\n\t\tfloat h4 = hash(vec2(k, salt + 19.0));\n\t\t// Some dendrites stop short near the border; others run past the haze\n\t\t// front by up to `lead`.\n\t\tfloat alive = thick - (1.0 - h4) * 0.4 + lead * h2;\n\t\tif (alive <= 0.0) continue;\n\t\tfloat r = f.y;\n\t\tfloat centre = (k + 0.2 + 0.6 * h1) * spacing;\n\t\tfloat lean = (h2 - 0.5) * 0.7;\n\t\tfloat bend = (noise(vec2(r * 0.02, k * 3.1 + salt)) - 0.5) * spacing * 0.28;\n\t\t// A slow curve on top of the lean, different for every dendrite.\n\t\tfloat curve = (h4 - 0.5) * 0.004 * r * r;\n\t\tfloat x = f.x - centre - r * lean - bend - curve;\n\t\tfloat ax = abs(x);\n\t\tfloat tipFade = smoothstep(0.0, 0.12, alive);\n\t\tfloat w = width * mix(0.45, 1.0, clamp(thick, 0.0, 1.0));\n\t\tfloat spine = 1.0 - smoothstep(w, w + aa * 2.0, ax);\n\t\t// Shadow on one side of the spine only: that is what reads as relief.\n\t\tfloat sx = x * sign(lean + 1e-3);\n\t\tfloat spineShade = smoothstep(w, w + aa, sx) * (1.0 - smoothstep(w + 0.8, w + 2.0, sx));\n\t\t// Side branches, swept toward the growth direction.\n\t\tfloat gap = spacing * (0.09 + 0.05 * h1);\n\t\t// The two sides alternate, and some branches never grow.\n\t\tfloat side = x > 0.0 ? 0.5 : 0.0;\n\t\tfloat b = (r - ax * 0.58) / gap + side;\n\t\tfloat bi = floor(b);\n\t\tfloat hb = hash(vec2(bi + side * 2.0, k + salt));\n\t\tfloat hb2 = hash(vec2(bi + side * 2.0, k + salt + 5.0));\n\t\tfloat reach = spacing * (0.12 + 0.4 * hb * hb) * smoothstep(-0.05, 0.7, thick);\n\t\tfloat branch = 0.0;\n\t\tfloat branchShade = 0.0;\n\t\tif (ax < reach && hb > 0.22) {\n\t\t\t// Each branch sits off-centre in its slot and leaves at its own angle.\n\t\t\tfloat at = 0.5 + (hb2 - 0.5) * 0.5 + ax * (hb - 0.5) * 0.12 / gap;\n\t\t\tfloat fb = (fract(b) - at) * gap * 0.86;\n\t\t\tfloat bw = width * 0.55 * (1.0 - 0.6 * ax / reach);\n\t\t\tfloat fade = 1.0 - ax / reach;\n\t\t\tbranch = (1.0 - smoothstep(bw, bw + aa * 2.0, abs(fb))) * fade;\n\t\t\tbranchShade = smoothstep(bw, bw + aa, fb) * (1.0 - smoothstep(bw + 0.7, bw + 1.6, fb)) * fade;\n\t\t}\n\t\tacc.x = max(acc.x, max(spine, branch * 0.85) * tipFade);\n\t\tacc.y = max(acc.y, max(spineShade, branchShade * 0.7) * tipFade);\n\t}\n\treturn acc;\n}\n\nvoid main() {\n\tsize = uRes / uScale;\n\thalfSide = 0.5 * min(size.x, size.y);\n\tvec2 p = vec2(gl_FragCoord.x, uRes.y - gl_FragCoord.y) / uScale;\n\n\tfloat heat = heatAt(p);\n\n\t// Thickness of the ice: 1 at the border, 0 at the front. The front is lobed:\n\t// the distance to the edge is warped by two octaves of noise.\n\tfloat d = edgeDistance(p) + (fbm(p * 0.006) - 0.5) * 0.5 + (fbm(p * 0.03 + 5.0) - 0.5) * 0.08;\n\tfloat thick = (uReach - d) / 0.45;\n\t// Warmth thins the ice. A warm spot loses its edge first on the way in and\n\t// gets it back last, so refreezing creeps in from the rim of the trail.\n\t// The melt edge wanders like the frost front, so a trail is never a clean blob.\n\tfloat melted = max(0.0, heat * 2.2 + (fbm(p * 0.035 + 7.0) - 0.5) * 0.9 * smoothstep(0.0, 0.2, heat));\n\tfloat t = thick - melted;\n\n\t// Dendrites follow the edge normal, with a light warp so no spine is straight.\n\tvec2 warp = vec2(fbm(p * 0.013 + 3.1), fbm(p * 0.013 + 8.7)) - 0.5;\n\tvec2 f = edgeFrame(p + warp * 18.0);\n\tvec2 big = dendrites(f, 96.0, 1.0, t, 0.22, 0.85);\n\tvec2 mid = dendrites(f + vec2(31.0, 0.0), 41.0, 2.0, t - 0.25, 0.08, 0.6);\n\tvec2 fine = dendrites(f + vec2(13.0, 0.0), 17.0, 3.0, t - 0.5, 0.0, 0.42);\n\tfloat ridge = max(big.x, max(mid.x * 0.75, fine.x * 0.5));\n\t// Shadow only where there is ice, so no grey halo forms past the front.\n\tfloat shade = max(big.y, max(mid.y * 0.7, fine.y * 0.45)) * (1.0 - ridge) * smoothstep(0.0, 0.3, t);\n\t// Roots fade into the rime right at the border, so no crystal is cut off\n\t// as a bright sliver where the rounded corner clips the pane.\n\t// Corners are left to the rime: there the two edge frames meet and a\n\t// leaning spine would be stretched into a bright wedge.\n\tvec2 toCorner = min(p, size - p);\n\tfloat corner = smoothstep(8.0, 30.0 + uRadius, length(toCorner));\n\tfloat rooted = smoothstep(0.5, 6.0, inset(p)) * corner;\n\tridge *= rooted;\n\tshade *= rooted;\n\t// Thin ice is faint and cool; thick ice is bright.\n\tfloat body = clamp(t, 0.0, 1.0);\n\tridge *= 0.35 + 0.65 * body;\n\n\t// Rime: fine grains, thresholded by thickness, so the ice is a continuous\n\t// granular crust at the border that breaks up into specks toward the front.\n\tfloat grain = noise(p * 1.1 + 11.0) * 0.55 + noise(p * 2.6 + 4.0) * 0.45;\n\tfloat rime = smoothstep(0.98 - body * 0.8, 1.2 - body * 0.8, grain) * smoothstep(0.0, 0.08, t);\n\tfloat haze = smoothstep(0.02, 0.45, t) * (0.55 + 0.45 * fbm(p * 0.03 + 2.0));\n\n\t// Three inks: a cold blue-grey for the haze and rime, white for the ridges,\n\t// and a deeper blue-grey for their shadow side. The greys are what make the\n\t// ice read on a white pane; the whites carry it on a dark one.\n\tvec3 frostInk = mix(vec3(0.80, 0.86, 0.93), uTint, 0.5);\n\tvec3 deep = mix(vec3(0.34, 0.43, 0.56), uTint * 0.5, 0.35);\n\tfloat aHaze = haze * 0.2 + rime * (0.06 + 0.12 * body);\n\tfloat aRidge = ridge * 0.8;\n\tfloat aShade = shade * (0.3 + 0.2 * body);\n\n\t// The melted trail: clear glass inside, a thin bright meniscus where the\n\t// water meets the ice, and a slightly darker water edge just inside it.\n\tfloat e = 3.0;\n\tvec2 grad = vec2(heatAt(p + vec2(e, 0.0)) - heatAt(p - vec2(e, 0.0)),\n\t\theatAt(p + vec2(0.0, e)) - heatAt(p - vec2(0.0, e))) / (2.0 * e);\n\tfloat slope = max(length(grad) * 2.2, 1e-3);\n\t// Pixels from the line where the trail just clears the ice.\n\tfloat edge = (melted - thick) / slope;\n\tfloat wetZone = step(0.02, heat) * smoothstep(0.05, 0.25, thick);\n\tfloat meniscus = (1.0 - smoothstep(0.0, 1.1, abs(edge))) * wetZone;\n\tfloat waterEdge = (1.0 - smoothstep(0.0, 2.5, abs(edge - 3.0))) * wetZone;\n\t// The rim is not a drawn outline: it comes and goes along its length.\n\tfloat along = smoothstep(0.3, 0.75, fbm(p * 0.045 + 13.0));\n\tfloat aMeniscus = meniscus * 0.4 * along;\n\tfloat aWater = waterEdge * 0.14 * (0.4 + 0.6 * along);\n\n\tvec3 col = frostInk * aHaze + vec3(1.0) * aRidge + deep * aShade\n\t\t+ vec3(1.0) * aMeniscus + deep * aWater;\n\tfloat alpha = aHaze + aRidge + aShade + aMeniscus + aWater;\n\n\t// Slow glints, only on thick ridges: a tiny four-pointed star in a few cells.\n\tvec2 sc = floor(p / 13.0);\n\tfloat sh = hash(sc + 71.0);\n\tif (uSparkle > 0.0 && sh > 0.9 && ridge > 0.45) {\n\t\tvec2 sp = (sc + 0.5) * 13.0;\n\t\tvec2 dd = abs(p - sp);\n\t\tfloat star = exp(-dot(dd, dd) / 2.0) + (exp(-dd.x * dd.x / 0.35) * exp(-dd.y / 3.0) + exp(-dd.y * dd.y / 0.35) * exp(-dd.x / 3.0)) * 0.5;\n\t\tfloat phase = sh * 91.0 + uTime * (0.35 + 0.5 * hash(sc + 3.0));\n\t\tfloat glint = pow(max(0.0, sin(phase)), 18.0) * uSparkle * body;\n\t\tcol += vec3(1.0) * star * glint;\n\t\talpha += star * glint;\n\t}\n\n\talpha = clamp(alpha, 0.0, 0.94);\n\tcol = min(col, vec3(alpha));\n\tgl_FragColor = vec4(col, alpha);\n}\n";
150
+ /**
151
+ * Start the frost on `canvas`, listening to the pointer on `root`. Returns
152
+ * `null` when WebGL is unavailable or the shader does not compile, so a
153
+ * wrapper can leave its fallback showing.
154
+ */
155
+ export declare function createFrostGlass(elements: FrostGlassElements, options?: FrostGlassInitOptions): FrostGlassEngine | null;