@glass-sdk/liquid-glass 0.0.2 → 0.0.3-beta.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.
Files changed (146) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/README.md +66 -149
  3. package/dist/core/concentric.js +20 -3
  4. package/dist/core/corner-options.js +12 -0
  5. package/dist/core/corner-path.js +118 -0
  6. package/dist/core/materials.js +264 -32
  7. package/dist/core/optics.js +1 -2
  8. package/dist/core/progressive.js +1 -2
  9. package/dist/core/shape.js +18 -28
  10. package/dist/core/spring.js +5 -10
  11. package/dist/core.js +5 -6
  12. package/dist/dom/backdrop-glass.js +46 -0
  13. package/dist/dom/compose-layers.js +42 -31
  14. package/dist/dom/composited.js +136 -0
  15. package/dist/dom/control-motion.js +58 -47
  16. package/dist/dom/engine.js +1 -2
  17. package/dist/dom/escaped-layers.js +179 -0
  18. package/dist/dom/filter-bounds.js +42 -13
  19. package/dist/dom/filter-budget.js +1 -2
  20. package/dist/dom/filter-chain.js +40 -0
  21. package/dist/dom/filter-groups.js +33 -14
  22. package/dist/dom/filter-paint-root.js +8 -6
  23. package/dist/dom/filter-patch.js +94 -55
  24. package/dist/dom/filter-reach.js +32 -19
  25. package/dist/dom/filter-stages.js +1 -2
  26. package/dist/dom/fixed-shape.js +23 -16
  27. package/dist/dom/foreground.js +16 -17
  28. package/dist/dom/interaction.js +65 -92
  29. package/dist/dom/layout-rect.js +42 -0
  30. package/dist/dom/layout-size.js +28 -0
  31. package/dist/dom/lens-layers.js +250 -136
  32. package/dist/dom/map-encoder.js +16 -13
  33. package/dist/dom/map-encoder.worker.js +2 -3
  34. package/dist/dom/map-encoding.js +49 -12
  35. package/dist/dom/map-image.js +29 -7
  36. package/dist/dom/map-store.js +1 -2
  37. package/dist/dom/maps.js +133 -83
  38. package/dist/dom/material-graph.js +108 -29
  39. package/dist/dom/media-mirror.js +244 -0
  40. package/dist/dom/page-zoom.js +19 -18
  41. package/dist/dom/png.js +1 -2
  42. package/dist/dom/progressive.js +152 -147
  43. package/dist/dom/renderer.js +1 -2
  44. package/dist/dom/sampling-bounds.js +1 -2
  45. package/dist/dom/selection.js +133 -79
  46. package/dist/dom/shape-attributes.js +9 -0
  47. package/dist/dom/shape-effects.js +14 -0
  48. package/dist/dom/shape-geometry.js +3 -0
  49. package/dist/dom/shape-layout.js +115 -116
  50. package/dist/dom/shared-backdrop.js +33 -25
  51. package/dist/dom/specular.js +116 -0
  52. package/dist/dom/ticker.js +28 -19
  53. package/dist/dom/tint-color.js +24 -0
  54. package/dist/dom/warm.js +63 -59
  55. package/dist/dom.js +591 -505
  56. package/dist/gpu/geometry.js +2 -3
  57. package/dist/gpu/maps.js +1109 -7
  58. package/dist/gpu/planes.js +2 -3
  59. package/dist/gpu.js +66 -64
  60. package/dist/index.js +12 -10
  61. package/dist/react/button.js +12 -11
  62. package/dist/react/color-picker.js +199 -0
  63. package/dist/react/control-thumb.js +4 -5
  64. package/dist/react/menu.js +82 -111
  65. package/dist/react/merged-ref.js +1 -2
  66. package/dist/react/progressive.js +1 -2
  67. package/dist/react/scene.js +71 -55
  68. package/dist/react/shape.js +67 -47
  69. package/dist/react/slider.js +81 -0
  70. package/dist/react/surface.js +90 -56
  71. package/dist/react/switch.js +101 -0
  72. package/dist/react/tabs.js +85 -63
  73. package/dist/react/toolbar.js +38 -123
  74. package/dist/react/value-control-motion.js +1 -2
  75. package/dist/styles.css +517 -111
  76. package/dist/types/core/concentric.d.ts +8 -0
  77. package/dist/types/core/corner-options.d.ts +4 -0
  78. package/dist/types/core/corner-path.d.ts +8 -0
  79. package/dist/types/core/index.d.ts +3 -5
  80. package/dist/types/core/materials.d.ts +100 -28
  81. package/dist/types/core/shape.d.ts +4 -6
  82. package/dist/types/core/spring.d.ts +8 -12
  83. package/dist/types/dom/backdrop-glass.d.ts +38 -0
  84. package/dist/types/dom/compose-layers.d.ts +4 -0
  85. package/dist/types/dom/composited.d.ts +61 -0
  86. package/dist/types/dom/escaped-layers.d.ts +32 -0
  87. package/dist/types/dom/filter-bounds.d.ts +4 -0
  88. package/dist/types/dom/filter-chain.d.ts +6 -0
  89. package/dist/types/dom/filter-groups.d.ts +1 -1
  90. package/dist/types/dom/filter-paint-root.d.ts +3 -0
  91. package/dist/types/dom/filter-patch.d.ts +5 -0
  92. package/dist/types/dom/filter-reach.d.ts +9 -9
  93. package/dist/types/dom/foreground.d.ts +2 -1
  94. package/dist/types/dom/index.d.ts +8 -19
  95. package/dist/types/dom/interaction.d.ts +8 -8
  96. package/dist/types/dom/layout-rect.d.ts +17 -0
  97. package/dist/types/dom/layout-size.d.ts +11 -0
  98. package/dist/types/dom/lens-layers.d.ts +18 -10
  99. package/dist/types/dom/map-encoder.d.ts +5 -2
  100. package/dist/types/dom/map-encoding.d.ts +12 -3
  101. package/dist/types/dom/map-image.d.ts +7 -1
  102. package/dist/types/dom/maps.d.ts +25 -7
  103. package/dist/types/dom/material-graph.d.ts +73 -10
  104. package/dist/types/dom/media-mirror.d.ts +49 -0
  105. package/dist/types/dom/progressive.d.ts +2 -5
  106. package/dist/types/dom/sampling-bounds.d.ts +1 -3
  107. package/dist/types/dom/selection.d.ts +29 -4
  108. package/dist/types/dom/shape-attributes.d.ts +6 -0
  109. package/dist/types/dom/shape-effects.d.ts +10 -0
  110. package/dist/types/dom/shape-geometry.d.ts +6 -0
  111. package/dist/types/dom/shape-layout.d.ts +2 -4
  112. package/dist/types/dom/shared-backdrop.d.ts +7 -3
  113. package/dist/types/dom/specular.d.ts +50 -0
  114. package/dist/types/dom/ticker.d.ts +4 -1
  115. package/dist/types/dom/tint-color.d.ts +11 -0
  116. package/dist/types/dom/warm.d.ts +8 -2
  117. package/dist/types/gpu/geometry.d.ts +2 -0
  118. package/dist/types/gpu/planes.d.ts +3 -2
  119. package/dist/types/index.d.ts +1 -1
  120. package/dist/types/react/button.d.ts +1 -1
  121. package/dist/types/react/color-picker.d.ts +26 -0
  122. package/dist/types/react/index.d.ts +14 -10
  123. package/dist/types/react/menu.d.ts +4 -5
  124. package/dist/types/react/progressive.d.ts +1 -1
  125. package/dist/types/react/scene.d.ts +4 -2
  126. package/dist/types/react/shape.d.ts +11 -1
  127. package/dist/types/react/slider.d.ts +14 -0
  128. package/dist/types/react/surface.d.ts +11 -22
  129. package/dist/types/react/switch.d.ts +9 -0
  130. package/dist/types/react/tabs.d.ts +3 -3
  131. package/dist/types/react/toolbar.d.ts +1 -1
  132. package/package.json +46 -40
  133. package/dist/core/morph-path.js +0 -206
  134. package/dist/core/union.js +0 -117
  135. package/dist/dom/compound-field.js +0 -23
  136. package/dist/dom/exit-handoff.js +0 -14
  137. package/dist/dom/map-blend.js +0 -8
  138. package/dist/dom/morph.js +0 -296
  139. package/dist/react/value-controls.js +0 -176
  140. package/dist/types/core/morph-path.d.ts +0 -110
  141. package/dist/types/core/union.d.ts +0 -20
  142. package/dist/types/dom/compound-field.d.ts +0 -35
  143. package/dist/types/dom/exit-handoff.d.ts +0 -7
  144. package/dist/types/dom/map-blend.d.ts +0 -22
  145. package/dist/types/dom/morph.d.ts +0 -78
  146. package/dist/types/react/value-controls.d.ts +0 -20
@@ -1,41 +1,273 @@
1
- //#region src/core/materials.ts
2
- var e = {
3
- clear: {
4
- blur: 0,
5
- refraction: 60,
6
- light: {
7
- shadowLift: .18,
8
- highlightRolloff: 0
9
- },
10
- dark: {
11
- shadowLift: .15,
12
- highlightRolloff: .2
1
+ // src/core/materials.ts
2
+ function e(e, t, n) {
3
+ let r = Math.min(t, n);
4
+ return e.floating ? Math.max(r, 160) : r;
5
+ }
6
+ function t(e) {
7
+ return Math.max(0, Math.min(1, (e - 64) / 96));
8
+ }
9
+ function n(e) {
10
+ return Math.max(0, Math.min(1, (e - 64) / 40));
11
+ }
12
+ function r(e, t) {
13
+ let n = Math.max(1, t);
14
+ return e === "clear" ? {
15
+ amount: Math.min(.65 * n, 60),
16
+ height: Math.min(.36 * n, 20)
17
+ } : e === "lens" ? {
18
+ amount: .155 * n,
19
+ height: .1 * n
20
+ } : {
21
+ amount: Math.min(n / 2, 60),
22
+ height: Math.min(n / 4, 20)
23
+ };
24
+ }
25
+ var i = 60;
26
+ function a(e, t) {
27
+ return e.material === "lens" && e.aberration ? .053 * t : 0;
28
+ }
29
+ var o = {
30
+ dark: [
31
+ {
32
+ blur: .5,
33
+ fill: 3,
34
+ saturation: 1.15,
35
+ tone: [
36
+ .125,
37
+ .553,
38
+ .725
39
+ ]
40
+ },
41
+ {
42
+ blur: .5,
43
+ fill: 6,
44
+ saturation: 1.15,
45
+ tone: [
46
+ .125,
47
+ .446,
48
+ .574
49
+ ]
50
+ },
51
+ {
52
+ blur: .5,
53
+ fill: 9,
54
+ saturation: 1.15,
55
+ tone: [
56
+ .125,
57
+ .339,
58
+ .424
59
+ ]
60
+ }
61
+ ],
62
+ light: [
63
+ {
64
+ blur: .8,
65
+ fill: 6,
66
+ saturation: 1.5,
67
+ tone: [
68
+ .4,
69
+ .736,
70
+ .992
71
+ ]
72
+ },
73
+ {
74
+ blur: .8,
75
+ fill: 8,
76
+ saturation: 1.5,
77
+ tone: [
78
+ .551,
79
+ .803,
80
+ .994
81
+ ]
82
+ },
83
+ {
84
+ blur: .8,
85
+ fill: 10,
86
+ saturation: 1.5,
87
+ tone: [
88
+ .702,
89
+ .869,
90
+ .996
91
+ ]
13
92
  }
14
- },
15
- regular: {
16
- blur: 7.33,
17
- refraction: 60,
18
- light: {
19
- fillSigma: 23,
20
- fillOpacity: .34,
93
+ ]
94
+ }, s = {
95
+ dark: [
96
+ {
97
+ blur: 7.5,
98
+ fill: 7.5,
99
+ saturation: 1.6,
100
+ tone: [
101
+ .125,
102
+ .5,
103
+ .573
104
+ ]
105
+ },
106
+ {
107
+ blur: 8,
108
+ fill: 8,
109
+ saturation: 1.6,
21
110
  tone: [
22
- .36,
23
- .67,
24
- -.1113,
25
- 1.1031
111
+ .125,
112
+ .4,
113
+ .455
26
114
  ]
27
115
  },
28
- dark: {
29
- fillSigma: 21.8,
30
- fillOpacity: .65,
116
+ {
117
+ blur: 10,
118
+ fill: 10,
119
+ saturation: 1.6,
120
+ tone: [
121
+ .125,
122
+ .305,
123
+ .337
124
+ ]
125
+ }
126
+ ],
127
+ light: [
128
+ {
129
+ blur: 9,
130
+ fill: 9,
131
+ saturation: 1.8,
31
132
  tone: [
32
- .105,
133
+ .408,
134
+ .765,
135
+ 1
136
+ ]
137
+ },
138
+ {
139
+ blur: 11,
140
+ fill: 11,
141
+ saturation: 1.8,
142
+ tone: [
143
+ .566,
33
144
  .83,
34
- -.2091,
35
- 1.0648
145
+ 1
36
146
  ]
147
+ },
148
+ {
149
+ blur: 13,
150
+ fill: 13,
151
+ saturation: 1.8,
152
+ tone: [
153
+ .725,
154
+ .89,
155
+ 1
156
+ ]
157
+ }
158
+ ]
159
+ }, c = {
160
+ blur: 0,
161
+ fill: 0,
162
+ saturation: 1,
163
+ tone: [
164
+ .125,
165
+ .651,
166
+ 1.08
167
+ ]
168
+ }, l = {
169
+ blur: 12,
170
+ fill: 0,
171
+ saturation: 1,
172
+ tone: [
173
+ .125,
174
+ .651,
175
+ 1.08
176
+ ]
177
+ }, u = {
178
+ dark: [
179
+ c,
180
+ c,
181
+ l
182
+ ],
183
+ light: [
184
+ c,
185
+ c,
186
+ l
187
+ ]
188
+ }, d = {
189
+ blur: 0,
190
+ fill: 0,
191
+ saturation: 1,
192
+ tone: [
193
+ 0,
194
+ .551,
195
+ 1
196
+ ]
197
+ }, f = {
198
+ dark: [d],
199
+ light: [d]
200
+ }, p = (e, t, n) => e + (t - e) * n;
201
+ function m(e, t) {
202
+ if (e.length === 1) return e[0];
203
+ let n = Math.max(0, Math.min(1, t)) * (e.length - 1), r = Math.min(e.length - 2, Math.floor(n));
204
+ return h(e[r], e[r + 1], n - r);
205
+ }
206
+ function h(e, t, n) {
207
+ return {
208
+ blur: p(e.blur, t.blur, n),
209
+ fill: p(e.fill, t.fill, n),
210
+ saturation: p(e.saturation, t.saturation, n),
211
+ tone: [
212
+ p(e.tone[0], t.tone[0], n),
213
+ p(e.tone[1], t.tone[1], n),
214
+ p(e.tone[2], t.tone[2], n)
215
+ ]
216
+ };
217
+ }
218
+ function g(e, r) {
219
+ let i = e.material ?? "regular", a = e.appearance ?? "light", c = Math.max(0, Math.min(1, e.frost ?? 0)), l;
220
+ if (i === "regular") {
221
+ let e = m(o[a], c), i = m(s[a], c), u = t(r);
222
+ l = {
223
+ ...h(e, i, a === "dark" ? n(r) : u),
224
+ blur: p(e.blur, i.blur, u)
225
+ };
226
+ } else l = m((i === "clear" ? u : f)[a], c);
227
+ let d = a === "dark";
228
+ return {
229
+ ...l,
230
+ fillBlend: {
231
+ mode: d ? "darken" : "lighten",
232
+ amount: l.fill ? .675 + .225 * Math.min(1, 2 * c) : 0,
233
+ cover: l.fill ? c : 0
37
234
  }
235
+ };
236
+ }
237
+ function _(e, n) {
238
+ if (e.material === "lens") return {
239
+ opacity: .12,
240
+ blur: 3,
241
+ dy: 1
242
+ };
243
+ if ((e.material ?? "regular") !== "regular") return;
244
+ let r = (e.appearance ?? "light") === "dark";
245
+ if (e.floating) return {
246
+ opacity: .3 * (r ? .8 : .6),
247
+ blur: 24,
248
+ dy: 10
249
+ };
250
+ let i = t(n);
251
+ return {
252
+ opacity: .3 * (r ? .04 + .56 * i : .04 + .36 * i),
253
+ blur: 4 + 20 * i,
254
+ dy: 8
255
+ };
256
+ }
257
+ function v(e) {
258
+ return Math.ceil(2.5 * e.blur + Math.abs(e.dy));
259
+ }
260
+ function y(e, n) {
261
+ if ((e.material ?? "regular") === "regular" && (e.appearance ?? "light") === "dark") {
262
+ let e = .255 + .765 * t(n);
263
+ return {
264
+ base: 1 - .5 * e,
265
+ slope: e
266
+ };
38
267
  }
39
- };
40
- //#endregion
41
- export { e as materials };
268
+ return {
269
+ base: 1.5,
270
+ slope: -1
271
+ };
272
+ }
273
+ export { a as aberrationFor, g as glassRecipe, e as glassSize, y as outlineFor, t as panelAmount, i as refraction, r as refractionFor, _ as shadowFor, v as shadowReach };
@@ -1,7 +1,6 @@
1
- //#region src/core/optics.ts
1
+ // src/core/optics.ts
2
2
  function e(e, t, n) {
3
3
  let r = Math.max(0, Math.min(1, -e * n));
4
4
  return t * (1 - Math.max(0, Math.min(1, Math.sqrt((2 - r) * r))));
5
5
  }
6
- //#endregion
7
6
  export { e as edgeDisplacement };
@@ -1,4 +1,4 @@
1
- //#region src/core/progressive.ts
1
+ // src/core/progressive.ts
2
2
  function e(e) {
3
3
  for (let [t, n, r] of [
4
4
  [
@@ -31,5 +31,4 @@ function n(e, t, n, r, i, a, o) {
31
31
  let s = Math.max(0, Math.min(r, a ? r + t : t)), c = Math.max(0, Math.min(i, n)), l = e === "top" ? c : e === "bottom" ? i - c : e === "left" ? s : r - s, u = Math.max(0, Math.min(1, l / Math.max(1, Math.min(o, 32))));
32
32
  return u * u * (3 - 2 * u);
33
33
  }
34
- //#endregion
35
34
  export { t as physicalEdge, n as scrollEdgeStrength, e as validateProgressive };
@@ -1,29 +1,20 @@
1
- import { generateClipPath as e, generatePath as t } from "@lisse/core";
2
- //#region src/core/shape.ts
3
- function n(e) {
4
- if (typeof e != "number" && e !== "capsule" && e !== "circle") throw RangeError("Unknown glass radius.");
5
- if (typeof e == "number" && (!Number.isFinite(e) || e < 0)) throw RangeError("Corner radius must be finite and nonnegative.");
6
- return {
7
- radius: typeof e == "number" ? e : 2 ** 53 - 1,
8
- smoothing: .8125,
9
- preserveSmoothing: !0,
10
- curve: e === "circle" ? "arc" : "squircle"
11
- };
12
- }
13
- var r = /* @__PURE__ */ new Map();
14
- function i(e, t) {
15
- let n = r.get(e);
16
- return n === void 0 && (n = t(), r.size >= 1024 && r.delete(r.keys().next().value), r.set(e, n)), n;
1
+ import { cornerPath as e } from "./corner-path.js";
2
+ import { cornerOptions as t } from "./corner-options.js";
3
+ // src/core/shape.ts
4
+ var n = /* @__PURE__ */ new Map();
5
+ function r(e, t) {
6
+ let r = n.get(e);
7
+ return r === void 0 && (r = t(), n.size >= 1024 && n.delete(n.keys().next().value), n.set(e, r)), r;
17
8
  }
18
- function a(e, r, a) {
19
- return i(`p|${e}|${r}|${a}`, () => t(e, r, n(a)));
9
+ function i(n, i, a) {
10
+ return r(`p|${n}|${i}|${a}`, () => e(n, i, t(a)));
20
11
  }
21
- function o(t, r, a) {
22
- return i(`c|${t}|${r}|${a}`, () => e(t, r, n(a)));
12
+ function a(n, i, a) {
13
+ return r(`c|${n}|${i}|${a}`, () => `path("${e(n, i, t(a))}")`);
23
14
  }
24
- function s(e, t, n) {
25
- let r = a(e, t, n).match(/[a-zA-Z]|[-+]?(?:\d*\.)?\d+(?:e[-+]?\d+)?/g), i = [], o = 0, s = [0, 0], c = [0, 0], l = () => Number(r[o++]), u = () => [l(), l()], d = (e) => {
26
- i.push(e), s = e;
15
+ function o(e, t, n) {
16
+ let r = i(e, t, n).match(/[a-zA-Z]|[-+]?(?:\d*\.)?\d+(?:e[-+]?\d+)?/g), a = [], o = 0, s = [0, 0], c = [0, 0], l = () => Number(r[o++]), u = () => [l(), l()], d = (e) => {
17
+ a.push(e), s = e;
27
18
  };
28
19
  for (; o < r.length;) {
29
20
  let e = r[o++];
@@ -50,10 +41,10 @@ function s(e, t, n) {
50
41
  } else if (e === "Z") d(c);
51
42
  else throw Error(`Unsupported Lisse path command: ${e}`);
52
43
  }
53
- return i;
44
+ return a;
54
45
  }
55
- function c(e, t, n) {
56
- let r = s(e, t, n);
46
+ function s(e, t, n) {
47
+ let r = o(e, t, n);
57
48
  for (let n of r) {
58
49
  for (let t of [0, e]) Math.abs(n[0] - t) < 2e-4 && (n[0] = t);
59
50
  for (let e of [0, t]) Math.abs(n[1] - e) < 2e-4 && (n[1] = e);
@@ -91,5 +82,4 @@ function c(e, t, n) {
91
82
  count: a
92
83
  };
93
84
  }
94
- //#endregion
95
- export { n as cornerOptions, o as shapeClip, a as shapePath, s as shapePolygon, c as shapeSegments };
85
+ export { t as cornerOptions, a as shapeClip, i as shapePath, o as shapePolygon, s as shapeSegments };
@@ -1,21 +1,17 @@
1
- //#region src/core/spring.ts
1
+ // src/core/spring.ts
2
2
  var e = {
3
3
  press: {
4
- duration: .24,
5
- bounce: .2
4
+ duration: .16,
5
+ bounce: .25
6
6
  },
7
7
  release: {
8
- duration: .5,
9
- bounce: .42
8
+ duration: .26,
9
+ bounce: .25
10
10
  },
11
11
  glow: {
12
12
  duration: .42,
13
13
  bounce: 0
14
14
  },
15
- morph: {
16
- duration: .42,
17
- bounce: .18
18
- },
19
15
  layout: {
20
16
  duration: .4,
21
17
  bounce: .16
@@ -74,5 +70,4 @@ function r(e, t, n = .55) {
74
70
  let r = Math.abs(e);
75
71
  return Math.sign(e) * t * (1 - 1 / (r * n / t + 1));
76
72
  }
77
- //#endregion
78
73
  export { t as Spring, r as rubberBand, n as settleTime, e as springs };
package/dist/core.js CHANGED
@@ -1,6 +1,5 @@
1
- import { concentricOutline as e, contentInsets as t, cornerPlacement as n, insetShape as r, polygonClip as i } from "./core/concentric.js";
2
- import { Spring as a, rubberBand as o, settleTime as s, springs as c } from "./core/spring.js";
3
- import { roundRectDistance as l, smoothMin as u, smoothUnion as d } from "./core/union.js";
4
- import { materials as f } from "./core/materials.js";
5
- import { edgeDisplacement as p } from "./core/optics.js";
6
- export { a as Spring, e as concentricOutline, t as contentInsets, n as cornerPlacement, p as edgeDisplacement, r as insetShape, f as materials, i as polygonClip, l as roundRectDistance, o as rubberBand, s as settleTime, u as smoothMin, d as smoothUnion, c as springs };
1
+ import { edgeDisplacement as e } from "./core/optics.js";
2
+ import { glassRecipe as t, refraction as n } from "./core/materials.js";
3
+ import { concentricOutline as r, contentInsets as i, cornerPlacement as a, insetShape as o, polygonClip as s } from "./core/concentric.js";
4
+ import { Spring as c, rubberBand as l, settleTime as u, springs as d } from "./core/spring.js";
5
+ export { c as Spring, r as concentricOutline, i as contentInsets, a as cornerPlacement, e as edgeDisplacement, t as glassRecipe, o as insetShape, s as polygonClip, n as refraction, l as rubberBand, u as settleTime, d as springs };
@@ -0,0 +1,46 @@
1
+ import { aberrationFor as e, glassRecipe as t, outlineFor as n, shadowFor as r } from "../core/materials.js";
2
+ import { nineMapImage as i } from "./map-image.js";
3
+ import { backdropMarkup as a, fillMarkup as o, lightMarkup as s, outlineMarkup as c, overlayTintMarkup as l, refractMarkup as u, tintChannels as d, tintMarkup as f, toneMarkup as p } from "./material-graph.js";
4
+ // src/dom/backdrop-glass.ts
5
+ function m(r) {
6
+ let { maps: m, options: g, width: _, height: v, size: y, pixel: b } = r, x = [], S = [
7
+ -2 + b,
8
+ -2 + b,
9
+ _ + 4 - 2 * b,
10
+ v + 4 - 2 * b
11
+ ];
12
+ for (let e of [
13
+ "field",
14
+ "rim",
15
+ "light"
16
+ ]) x.push(i(m, e, `g${e}`, ...S, b));
17
+ let C = "SourceGraphic";
18
+ r.backed && (x.push(a("gbackdrop", {
19
+ x: 0,
20
+ y: 0,
21
+ width: _,
22
+ height: v
23
+ }), "<feMerge result=\"gfrosted\"><feMergeNode in=\"gbackdrop\"/><feMergeNode in=\"SourceGraphic\"/></feMerge>"), C = "gfrosted");
24
+ let w = t(g, y), T = h(g, y), E = w.fill <= T + .01 ? {
25
+ markup: "",
26
+ result: C
27
+ } : o("g", C, C, g, y, Math.sqrt(w.fill ** 2 - T ** 2) / w.fill);
28
+ x.push(E.markup, p("g", g, y, E.result));
29
+ let D = "gcolor", O = "glight", k = d(g);
30
+ if (k) {
31
+ let e = f("g", g, k);
32
+ x.push(e.markup), D = e.color, O = "gtintLight";
33
+ }
34
+ x.push(u("g", D, r.refraction, e(g, y)), ...k ? [l("glight", O, k)] : [], s("g", "grefracted", O, "gfield", g.material), c("g", C, "grim", 1, n(g, y)), "<feComposite in=\"grim\" in2=\"gfield\" operator=\"in\" result=\"gring\"/>", "<feMerge><feMergeNode in=\"goutline\"/><feMergeNode in=\"glitInside\"/><feMergeNode in=\"gring\"/></feMerge>");
35
+ let A = x.join("").replace(/<(fe(?:Flood|Composite|DisplacementMap|ColorMatrix|ComponentTransfer|GaussianBlur|Blend|Merge|Offset))\b([^>]*?)(\/?)>/g, (e, t, n, r) => /\sx="/.test(n) ? e : `<${t}${n} x="0" y="0" width="${_}" height="${v}"${r}>`);
36
+ return `<filter id="${r.id}" x="0" y="0" width="1" height="1" filterUnits="objectBoundingBox" primitiveUnits="userSpaceOnUse" color-interpolation-filters="sRGB">${A}</filter>`;
37
+ }
38
+ function h(e, n) {
39
+ let r = Math.round(t(e, n).blur * 100) / 100;
40
+ return r >= .05 ? r : 0;
41
+ }
42
+ function g(e, t, n) {
43
+ let i = n ? void 0 : r(e, t);
44
+ return !i || i.opacity < .004 ? "" : `0 ${i.dy}px ${2 * i.blur}px rgba(0, 0, 0, ${Math.round(i.opacity * 1e3) / 1e3})`;
45
+ }
46
+ export { m as backdropGlassFilter, h as backdropGlassFrost, g as backdropGlassShadow };
@@ -1,6 +1,7 @@
1
- import { unionSamplingBounds as e } from "./sampling-bounds.js";
2
- //#region src/dom/compose-layers.ts
3
- var t = (e, t) => e.x < t.x + t.width && t.x < e.x + e.width && e.y < t.y + t.height && t.y < e.y + e.height, n = (e) => `x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}"`, r = (e) => {
1
+ import { boundsMeet as e } from "./filter-bounds.js";
2
+ import { unionSamplingBounds as t } from "./sampling-bounds.js";
3
+ // src/dom/compose-layers.ts
4
+ var n = (e) => `x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}"`, r = (e) => {
4
5
  let t = Math.floor(e.x), n = Math.floor(e.y);
5
6
  return {
6
7
  x: t,
@@ -13,42 +14,52 @@ function a(a, o = "scene", s = "SourceGraphic") {
13
14
  if (!a.length) return i([s], o);
14
15
  let c = [];
15
16
  a.forEach((n, i) => {
16
- let a = {
17
- members: [i],
18
- bounds: r(n.bounds)
19
- };
20
- for (let n = 0; n < c.length;) {
21
- if (!t(a.bounds, c[n].bounds)) {
22
- n++;
23
- continue;
17
+ for (let a of n.parts ?? [n.bounds]) {
18
+ let n = {
19
+ members: [i],
20
+ bounds: r(a)
21
+ };
22
+ for (let i = 0; i < c.length;) {
23
+ if (!e(n.bounds, c[i].bounds)) {
24
+ i++;
25
+ continue;
26
+ }
27
+ let a = c.splice(i, 1)[0];
28
+ n = {
29
+ members: [.../* @__PURE__ */ new Set([...n.members, ...a.members])],
30
+ bounds: r(t([n.bounds, a.bounds]))
31
+ }, i = 0;
24
32
  }
25
- let i = c.splice(n, 1)[0];
26
- a = {
27
- members: [...a.members, ...i.members],
28
- bounds: r(e([a.bounds, i.bounds]))
29
- }, n = 0;
33
+ n.members.sort((e, t) => e - t), c.push(n);
30
34
  }
31
- a.members.sort((e, t) => e - t), c.push(a);
32
35
  });
33
- let l = [], u = [], d = [];
36
+ let l = /* @__PURE__ */ new Map();
37
+ for (let e of c) for (let t of e.members) l.set(t, (l.get(t) ?? 0) + 1);
38
+ let u = (e) => l.get(e) > 1 && c.some((t) => t.members.length > 1 && t.members.includes(e)), d = [], f = [], p = [], m = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set();
34
39
  c.forEach((e, t) => {
35
- if (e.members.length === 1) {
36
- let t = a[e.members[0]];
37
- u.push(t.mask), d.push(...t.layers);
40
+ let r = e.members.length === 1 ? e.members[0] : void 0;
41
+ if (r !== void 0 && !u(r)) {
42
+ let e = a[r];
43
+ m.has(r) || (m.add(r), f.push(e.mask)), h.has(r) || (h.add(r), p.push(...e.layers));
38
44
  return;
39
45
  }
40
- let r = `${o}-group${t}`, c = n(e.bounds), f = `${r}-area`;
41
- l.push(`<feFlood flood-color="white" ${c} result="${f}"/>`), u.push(f);
42
- let p = `${r}-source`;
43
- l.push(`<feComposite in="${s}" in2="${f}" operator="in" ${c} result="${p}"/>`);
46
+ let c = `${o}-group${t}`;
47
+ if (r !== void 0) {
48
+ let t = a[r];
49
+ m.has(r) || (m.add(r), f.push(t.mask)), d.push(i(t.layers, c, e.bounds)), p.push(c);
50
+ return;
51
+ }
52
+ let l = n(e.bounds), g = `${c}-area`;
53
+ d.push(`<feFlood flood-color="white" ${l} result="${g}"/>`), f.push(g);
54
+ let _ = `${c}-source`;
55
+ d.push(`<feComposite in="${s}" in2="${g}" operator="in" ${l} result="${_}"/>`);
44
56
  for (let t of e.members) {
45
- let n = a[t], r = `${o}-${n.id}-outside`, s = `${o}-${n.id}-output`;
46
- l.push(`<feComposite in="${p}" in2="${n.mask}" operator="out" ${c} result="${r}"/>`), l.push(i([r, ...n.layers], s, e.bounds)), p = s;
57
+ let n = a[t], r = `${c}-${n.id}-outside`, o = `${c}-${n.id}-output`;
58
+ d.push(`<feComposite in="${_}" in2="${n.mask}" operator="out" ${l} result="${r}"/>`), d.push(i([r, ...n.layers], o, e.bounds)), _ = o;
47
59
  }
48
- d.push(p);
60
+ p.push(_);
49
61
  });
50
- let f = u[0];
51
- return u.length > 1 && (l.push(i(u, `${o}-areas`, e(c.map((e) => e.bounds)))), f = `${o}-areas`), l.push(`<feComposite in="${s}" in2="${f}" operator="out" result="${o}-outside"/>`), l.push(i([`${o}-outside`, ...d], o)), l.join("");
62
+ let g = f[0];
63
+ return f.length > 1 && (d.push(i(f, `${o}-areas`, t(c.map((e) => e.bounds)))), g = `${o}-areas`), d.push(`<feComposite in="${s}" in2="${g}" operator="out" result="${o}-outside"/>`), d.push(i([`${o}-outside`, ...p], o)), d.join("");
52
64
  }
53
- //#endregion
54
65
  export { a as composeSparseLayers };