@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.
- package/CHANGELOG.md +124 -0
- package/README.md +66 -149
- package/dist/core/concentric.js +20 -3
- package/dist/core/corner-options.js +12 -0
- package/dist/core/corner-path.js +118 -0
- package/dist/core/materials.js +264 -32
- package/dist/core/optics.js +1 -2
- package/dist/core/progressive.js +1 -2
- package/dist/core/shape.js +18 -28
- package/dist/core/spring.js +5 -10
- package/dist/core.js +5 -6
- package/dist/dom/backdrop-glass.js +46 -0
- package/dist/dom/compose-layers.js +42 -31
- package/dist/dom/composited.js +136 -0
- package/dist/dom/control-motion.js +58 -47
- package/dist/dom/engine.js +1 -2
- package/dist/dom/escaped-layers.js +179 -0
- package/dist/dom/filter-bounds.js +42 -13
- package/dist/dom/filter-budget.js +1 -2
- package/dist/dom/filter-chain.js +40 -0
- package/dist/dom/filter-groups.js +33 -14
- package/dist/dom/filter-paint-root.js +8 -6
- package/dist/dom/filter-patch.js +94 -55
- package/dist/dom/filter-reach.js +32 -19
- package/dist/dom/filter-stages.js +1 -2
- package/dist/dom/fixed-shape.js +23 -16
- package/dist/dom/foreground.js +16 -17
- package/dist/dom/interaction.js +65 -92
- package/dist/dom/layout-rect.js +42 -0
- package/dist/dom/layout-size.js +28 -0
- package/dist/dom/lens-layers.js +250 -136
- package/dist/dom/map-encoder.js +16 -13
- package/dist/dom/map-encoder.worker.js +2 -3
- package/dist/dom/map-encoding.js +49 -12
- package/dist/dom/map-image.js +29 -7
- package/dist/dom/map-store.js +1 -2
- package/dist/dom/maps.js +133 -83
- package/dist/dom/material-graph.js +108 -29
- package/dist/dom/media-mirror.js +244 -0
- package/dist/dom/page-zoom.js +19 -18
- package/dist/dom/png.js +1 -2
- package/dist/dom/progressive.js +152 -147
- package/dist/dom/renderer.js +1 -2
- package/dist/dom/sampling-bounds.js +1 -2
- package/dist/dom/selection.js +133 -79
- package/dist/dom/shape-attributes.js +9 -0
- package/dist/dom/shape-effects.js +14 -0
- package/dist/dom/shape-geometry.js +3 -0
- package/dist/dom/shape-layout.js +115 -116
- package/dist/dom/shared-backdrop.js +33 -25
- package/dist/dom/specular.js +116 -0
- package/dist/dom/ticker.js +28 -19
- package/dist/dom/tint-color.js +24 -0
- package/dist/dom/warm.js +63 -59
- package/dist/dom.js +591 -505
- package/dist/gpu/geometry.js +2 -3
- package/dist/gpu/maps.js +1109 -7
- package/dist/gpu/planes.js +2 -3
- package/dist/gpu.js +66 -64
- package/dist/index.js +12 -10
- package/dist/react/button.js +12 -11
- package/dist/react/color-picker.js +199 -0
- package/dist/react/control-thumb.js +4 -5
- package/dist/react/menu.js +82 -111
- package/dist/react/merged-ref.js +1 -2
- package/dist/react/progressive.js +1 -2
- package/dist/react/scene.js +71 -55
- package/dist/react/shape.js +67 -47
- package/dist/react/slider.js +81 -0
- package/dist/react/surface.js +90 -56
- package/dist/react/switch.js +101 -0
- package/dist/react/tabs.js +85 -63
- package/dist/react/toolbar.js +38 -123
- package/dist/react/value-control-motion.js +1 -2
- package/dist/styles.css +517 -111
- package/dist/types/core/concentric.d.ts +8 -0
- package/dist/types/core/corner-options.d.ts +4 -0
- package/dist/types/core/corner-path.d.ts +8 -0
- package/dist/types/core/index.d.ts +3 -5
- package/dist/types/core/materials.d.ts +100 -28
- package/dist/types/core/shape.d.ts +4 -6
- package/dist/types/core/spring.d.ts +8 -12
- package/dist/types/dom/backdrop-glass.d.ts +38 -0
- package/dist/types/dom/compose-layers.d.ts +4 -0
- package/dist/types/dom/composited.d.ts +61 -0
- package/dist/types/dom/escaped-layers.d.ts +32 -0
- package/dist/types/dom/filter-bounds.d.ts +4 -0
- package/dist/types/dom/filter-chain.d.ts +6 -0
- package/dist/types/dom/filter-groups.d.ts +1 -1
- package/dist/types/dom/filter-paint-root.d.ts +3 -0
- package/dist/types/dom/filter-patch.d.ts +5 -0
- package/dist/types/dom/filter-reach.d.ts +9 -9
- package/dist/types/dom/foreground.d.ts +2 -1
- package/dist/types/dom/index.d.ts +8 -19
- package/dist/types/dom/interaction.d.ts +8 -8
- package/dist/types/dom/layout-rect.d.ts +17 -0
- package/dist/types/dom/layout-size.d.ts +11 -0
- package/dist/types/dom/lens-layers.d.ts +18 -10
- package/dist/types/dom/map-encoder.d.ts +5 -2
- package/dist/types/dom/map-encoding.d.ts +12 -3
- package/dist/types/dom/map-image.d.ts +7 -1
- package/dist/types/dom/maps.d.ts +25 -7
- package/dist/types/dom/material-graph.d.ts +73 -10
- package/dist/types/dom/media-mirror.d.ts +49 -0
- package/dist/types/dom/progressive.d.ts +2 -5
- package/dist/types/dom/sampling-bounds.d.ts +1 -3
- package/dist/types/dom/selection.d.ts +29 -4
- package/dist/types/dom/shape-attributes.d.ts +6 -0
- package/dist/types/dom/shape-effects.d.ts +10 -0
- package/dist/types/dom/shape-geometry.d.ts +6 -0
- package/dist/types/dom/shape-layout.d.ts +2 -4
- package/dist/types/dom/shared-backdrop.d.ts +7 -3
- package/dist/types/dom/specular.d.ts +50 -0
- package/dist/types/dom/ticker.d.ts +4 -1
- package/dist/types/dom/tint-color.d.ts +11 -0
- package/dist/types/dom/warm.d.ts +8 -2
- package/dist/types/gpu/geometry.d.ts +2 -0
- package/dist/types/gpu/planes.d.ts +3 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/react/button.d.ts +1 -1
- package/dist/types/react/color-picker.d.ts +26 -0
- package/dist/types/react/index.d.ts +14 -10
- package/dist/types/react/menu.d.ts +4 -5
- package/dist/types/react/progressive.d.ts +1 -1
- package/dist/types/react/scene.d.ts +4 -2
- package/dist/types/react/shape.d.ts +11 -1
- package/dist/types/react/slider.d.ts +14 -0
- package/dist/types/react/surface.d.ts +11 -22
- package/dist/types/react/switch.d.ts +9 -0
- package/dist/types/react/tabs.d.ts +3 -3
- package/dist/types/react/toolbar.d.ts +1 -1
- package/package.json +46 -40
- package/dist/core/morph-path.js +0 -206
- package/dist/core/union.js +0 -117
- package/dist/dom/compound-field.js +0 -23
- package/dist/dom/exit-handoff.js +0 -14
- package/dist/dom/map-blend.js +0 -8
- package/dist/dom/morph.js +0 -296
- package/dist/react/value-controls.js +0 -176
- package/dist/types/core/morph-path.d.ts +0 -110
- package/dist/types/core/union.d.ts +0 -20
- package/dist/types/dom/compound-field.d.ts +0 -35
- package/dist/types/dom/exit-handoff.d.ts +0 -7
- package/dist/types/dom/map-blend.d.ts +0 -22
- package/dist/types/dom/morph.d.ts +0 -78
- package/dist/types/react/value-controls.d.ts +0 -20
package/dist/core/materials.js
CHANGED
|
@@ -1,41 +1,273 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
.
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
1.1031
|
|
111
|
+
.125,
|
|
112
|
+
.4,
|
|
113
|
+
.455
|
|
26
114
|
]
|
|
27
115
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
.
|
|
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
|
-
|
|
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
|
-
|
|
41
|
-
|
|
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 };
|
package/dist/core/optics.js
CHANGED
package/dist/core/progressive.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
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 };
|
package/dist/core/shape.js
CHANGED
|
@@ -1,29 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
|
19
|
-
return
|
|
9
|
+
function i(n, i, a) {
|
|
10
|
+
return r(`p|${n}|${i}|${a}`, () => e(n, i, t(a)));
|
|
20
11
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
12
|
+
function a(n, i, a) {
|
|
13
|
+
return r(`c|${n}|${i}|${a}`, () => `path("${e(n, i, t(a))}")`);
|
|
23
14
|
}
|
|
24
|
-
function
|
|
25
|
-
let r =
|
|
26
|
-
|
|
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
|
|
44
|
+
return a;
|
|
54
45
|
}
|
|
55
|
-
function
|
|
56
|
-
let r =
|
|
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
|
-
|
|
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 };
|
package/dist/core/spring.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
// src/core/spring.ts
|
|
2
2
|
var e = {
|
|
3
3
|
press: {
|
|
4
|
-
duration: .
|
|
5
|
-
bounce: .
|
|
4
|
+
duration: .16,
|
|
5
|
+
bounce: .25
|
|
6
6
|
},
|
|
7
7
|
release: {
|
|
8
|
-
duration: .
|
|
9
|
-
bounce: .
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
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 {
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
n
|
|
23
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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 = `${
|
|
46
|
-
|
|
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
|
-
|
|
60
|
+
p.push(_);
|
|
49
61
|
});
|
|
50
|
-
let
|
|
51
|
-
return
|
|
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 };
|