@octane-xplat/smooth-corners 0.0.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/native/index.js +2 -0
- package/dist/native/node_modules/.pnpm/@lisse_core@0.7.2/node_modules/@lisse/core/dist/chunk-BL6ZAFLB.js +477 -0
- package/dist/native/octane-client-build.json +8 -0
- package/dist/native/packages/smooth-corners/src/SmoothCorners.tsrx.js +72 -0
- package/dist/native/packages/smooth-corners/src/apply.android.js +95 -0
- package/dist/native/packages/smooth-corners/src/apply.ios.js +92 -0
- package/dist/native/packages/smooth-corners/src/path.js +424 -0
- package/dist/web/index.js +2 -0
- package/dist/web/node_modules/.pnpm/@lisse_core@0.7.2/node_modules/@lisse/core/dist/chunk-BL6ZAFLB.js +477 -0
- package/dist/web/octane-client-build.json +8 -0
- package/dist/web/packages/smooth-corners/src/SmoothCorners.web.tsrx.js +62 -0
- package/dist/web/packages/smooth-corners/src/path.js +453 -0
- package/package.json +67 -4
- package/src/SmoothCorners.macos.tsrx +177 -0
- package/src/SmoothCorners.tsrx +67 -0
- package/src/SmoothCorners.web.tsrx +71 -0
- package/src/apply.android.ts +136 -0
- package/src/apply.ios.ts +136 -0
- package/src/index.macos.ts +10 -0
- package/src/index.ts +13 -0
- package/src/index.web.ts +10 -0
- package/src/path.ts +627 -0
- package/src/props.ts +66 -0
- package/types/index.d.ts +17 -0
- package/types/props.d.ts +59 -0
- package/README.md +0 -4
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@lisse+core@0.7.2/node_modules/@lisse/core/dist/chunk-BL6ZAFLB.js
|
|
2
|
+
function V(e, t, r, n, s, o, i) {
|
|
3
|
+
let p = e === 0 && t === 0 ? 0 : r >= 0 ? n - r : e / (e + t) * n, g = e === 0 && s === 0 ? 0 : o >= 0 ? i - o : e / (e + s) * i;
|
|
4
|
+
return Math.min(p, g);
|
|
5
|
+
}
|
|
6
|
+
function st({ topLeftCornerRadius: e, topRightCornerRadius: t, bottomRightCornerRadius: r, bottomLeftCornerRadius: n, width: s, height: o }) {
|
|
7
|
+
if (e === t && t === r && r === n && e > 0 && s > 0 && o > 0) {
|
|
8
|
+
let f = Math.min(s, o) / 2, M = {
|
|
9
|
+
radius: Math.min(e, f),
|
|
10
|
+
roundingAndSmoothingBudget: f
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
topLeft: M,
|
|
14
|
+
topRight: M,
|
|
15
|
+
bottomLeft: M,
|
|
16
|
+
bottomRight: M
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
let i = (t > e ? 1 : 0) + (n > e ? 1 : 0) + (r > e ? 1 : 0), p = (e >= t ? 1 : 0) + (n > t ? 1 : 0) + (r > t ? 1 : 0), g = (e >= n ? 1 : 0) + (t >= n ? 1 : 0) + (r > n ? 1 : 0), $ = e, x = t, u = n, c = r, a = -1, m = -1, l = -1, d = -1;
|
|
20
|
+
for (let f = 0; f < 4; f++) {
|
|
21
|
+
let S = i === f ? 0 : p === f ? 1 : g === f ? 2 : 3;
|
|
22
|
+
S === 0 ? (a = V(e, x, m, s, u, l, o), $ = Math.min(e, a)) : S === 1 ? (m = V(t, $, a, s, c, d, o), x = Math.min(t, m)) : S === 2 ? (l = V(n, c, d, s, $, a, o), u = Math.min(n, l)) : (d = V(r, u, l, s, x, m, o), c = Math.min(r, d));
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
topLeft: {
|
|
26
|
+
radius: $,
|
|
27
|
+
roundingAndSmoothingBudget: a
|
|
28
|
+
},
|
|
29
|
+
topRight: {
|
|
30
|
+
radius: x,
|
|
31
|
+
roundingAndSmoothingBudget: m
|
|
32
|
+
},
|
|
33
|
+
bottomLeft: {
|
|
34
|
+
radius: u,
|
|
35
|
+
roundingAndSmoothingBudget: l
|
|
36
|
+
},
|
|
37
|
+
bottomRight: {
|
|
38
|
+
radius: c,
|
|
39
|
+
roundingAndSmoothingBudget: d
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function G(e) {
|
|
44
|
+
return e * Math.PI / 180;
|
|
45
|
+
}
|
|
46
|
+
function y(e) {
|
|
47
|
+
let t = e * 1e4, r = Math.round(t), n = t - r;
|
|
48
|
+
if (n > .4999999 || n < -.4999999 || !Number.isSafeInteger(r)) return e.toFixed(4);
|
|
49
|
+
let s = e < 0, o = s ? -r : r, i = o % 1e4, p = (o - i) / 1e4, g = i < 10 ? "000" : i < 100 ? "00" : i < 1e3 ? "0" : "";
|
|
50
|
+
return (s ? "-" : "") + p + "." + g + i;
|
|
51
|
+
}
|
|
52
|
+
var q = {
|
|
53
|
+
p: 0,
|
|
54
|
+
pathSegment: () => ""
|
|
55
|
+
};
|
|
56
|
+
function L(e, t) {
|
|
57
|
+
return e === 0 || Number.isNaN(e) ? t : t.charCodeAt(0) === 45 ? t.slice(1) : "-" + t;
|
|
58
|
+
}
|
|
59
|
+
function k(e, t, r, n, s, o) {
|
|
60
|
+
let i = y(e), p = y(t), g = y(r), h = y(n), $ = y(s), x = y(o);
|
|
61
|
+
return {
|
|
62
|
+
x1: i,
|
|
63
|
+
x1n: L(e, i),
|
|
64
|
+
y1: p,
|
|
65
|
+
y1n: L(t, p),
|
|
66
|
+
x2: g,
|
|
67
|
+
x2n: L(r, g),
|
|
68
|
+
y2: h,
|
|
69
|
+
y2n: L(n, h),
|
|
70
|
+
x3: $,
|
|
71
|
+
x3n: L(s, $),
|
|
72
|
+
y3: x,
|
|
73
|
+
y3n: L(o, x)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function z(e, t) {
|
|
77
|
+
switch (t) {
|
|
78
|
+
case "TR": return `c ${e.x1} ${e.y1} ${e.x2} ${e.y2} ${e.x3} ${e.y3}`;
|
|
79
|
+
case "BR": return `c ${e.y1n} ${e.x1} ${e.y2n} ${e.x2} ${e.y3n} ${e.x3}`;
|
|
80
|
+
case "BL": return `c ${e.x1n} ${e.y1n} ${e.x2n} ${e.y2n} ${e.x3n} ${e.y3n}`;
|
|
81
|
+
case "TL": return `c ${e.y1} ${e.x1n} ${e.y2} ${e.x2n} ${e.y3} ${e.x3n}`;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function W(e, t) {
|
|
85
|
+
switch (t) {
|
|
86
|
+
case "TR": return `a ${e.radius} ${e.radius} 0 0 1 ${e.d} ${e.d}`;
|
|
87
|
+
case "BR": return `a ${e.radius} ${e.radius} 0 0 1 ${e.dn} ${e.d}`;
|
|
88
|
+
case "BL": return `a ${e.radius} ${e.radius} 0 0 1 ${e.dn} ${e.dn}`;
|
|
89
|
+
case "TL": return `a ${e.radius} ${e.radius} 0 0 1 ${e.d} ${e.dn}`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
var it = ({ cornerRadius: e, roundingAndSmoothingBudget: t }) => {
|
|
93
|
+
let r = Math.min(e, t);
|
|
94
|
+
if (r <= 0) return q;
|
|
95
|
+
let n = y(r), s = {
|
|
96
|
+
radius: n,
|
|
97
|
+
d: n,
|
|
98
|
+
dn: L(r, n)
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
p: r,
|
|
102
|
+
pathSegment: (o) => W(s, o)
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
function Y({ cornerRadius: e, cornerSmoothing: t, preserveSmoothing: r, roundingAndSmoothingBudget: n }) {
|
|
106
|
+
if (e <= 0) return {
|
|
107
|
+
a: 0,
|
|
108
|
+
b: 0,
|
|
109
|
+
c: 0,
|
|
110
|
+
d: 0,
|
|
111
|
+
p: 0,
|
|
112
|
+
arcSectionLength: 0,
|
|
113
|
+
cornerRadius: 0
|
|
114
|
+
};
|
|
115
|
+
let s = (1 + t) * e;
|
|
116
|
+
if (!r) {
|
|
117
|
+
let a = n / e - 1;
|
|
118
|
+
t = Math.min(t, a), s = Math.min(s, n);
|
|
119
|
+
}
|
|
120
|
+
let o = 90 * (1 - t), i = Math.sin(G(o / 2)) * e * Math.sqrt(2), p = (90 - o) / 2, g = e * Math.tan(G(p / 2)), h = 45 * t, $ = g * Math.cos(G(h)), x = $ * Math.tan(G(h)), u = (s - i - $ - x) / 3, c = 2 * u;
|
|
121
|
+
if (r && s > n) {
|
|
122
|
+
let a = n - x - i - $, l = a - a / 6;
|
|
123
|
+
u = Math.min(u, l), c = a - u, s = Math.min(s, n);
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
a: c,
|
|
127
|
+
b: u,
|
|
128
|
+
c: $,
|
|
129
|
+
d: x,
|
|
130
|
+
p: s,
|
|
131
|
+
arcSectionLength: i,
|
|
132
|
+
cornerRadius: e
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
var at = ({ cornerRadius: e, smoothing: t, preserveSmoothing: r, roundingAndSmoothingBudget: n }) => {
|
|
136
|
+
let s = Y({
|
|
137
|
+
cornerRadius: e,
|
|
138
|
+
cornerSmoothing: t,
|
|
139
|
+
preserveSmoothing: r,
|
|
140
|
+
roundingAndSmoothingBudget: n
|
|
141
|
+
});
|
|
142
|
+
if (s.cornerRadius <= 0) return q;
|
|
143
|
+
let o = _t(s);
|
|
144
|
+
return {
|
|
145
|
+
p: s.p,
|
|
146
|
+
pathSegment: (i) => {
|
|
147
|
+
switch (i) {
|
|
148
|
+
case "TR": return `c ${o.a} 0 ${o.ab} 0 ${o.abc} ${o.d} a ${o.r} ${o.r} 0 0 1 ${o.arc} ${o.arc} c ${o.d} ${o.c} ${o.d} ${o.bc} ${o.d} ${o.abc}`;
|
|
149
|
+
case "BR": return `c 0 ${o.a} 0 ${o.ab} ${o.dn} ${o.abc} a ${o.r} ${o.r} 0 0 1 ${o.arcn} ${o.arc} c ${o.cn} ${o.d} ${o.bcn} ${o.d} ${o.abcn} ${o.d}`;
|
|
150
|
+
case "BL": return `c ${o.an} 0 ${o.abn} 0 ${o.abcn} ${o.dn} a ${o.r} ${o.r} 0 0 1 ${o.arcn} ${o.arcn} c ${o.dn} ${o.cn} ${o.dn} ${o.bcn} ${o.dn} ${o.abcn}`;
|
|
151
|
+
case "TL": return `c 0 ${o.an} 0 ${o.abn} ${o.d} ${o.abcn} a ${o.r} ${o.r} 0 0 1 ${o.arc} ${o.arcn} c ${o.c} ${o.dn} ${o.bc} ${o.dn} ${o.abc} ${o.dn}`;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
function _t({ cornerRadius: e, a: t, b: r, c: n, d: s, arcSectionLength: o }) {
|
|
157
|
+
let i = t + r, p = i + n, g = r + n, h = y(t), $ = y(i), x = y(p), u = y(n), c = y(g), a = y(s), m = y(o);
|
|
158
|
+
return {
|
|
159
|
+
a: h,
|
|
160
|
+
an: L(t, h),
|
|
161
|
+
ab: $,
|
|
162
|
+
abn: L(i, $),
|
|
163
|
+
abc: x,
|
|
164
|
+
abcn: L(p, x),
|
|
165
|
+
c: u,
|
|
166
|
+
cn: L(n, u),
|
|
167
|
+
bc: c,
|
|
168
|
+
bcn: L(g, c),
|
|
169
|
+
d: a,
|
|
170
|
+
dn: L(s, a),
|
|
171
|
+
r: y(e),
|
|
172
|
+
arc: m,
|
|
173
|
+
arcn: "-" + m
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
var P = [
|
|
177
|
+
0,
|
|
178
|
+
Math.PI / 6,
|
|
179
|
+
Math.PI / 3,
|
|
180
|
+
Math.PI / 2
|
|
181
|
+
];
|
|
182
|
+
var tt = P.map((e) => Math.sin(e));
|
|
183
|
+
var et = P.map((e) => Math.cos(e));
|
|
184
|
+
var ut = [
|
|
185
|
+
(P[0] + P[1]) / 2,
|
|
186
|
+
(P[1] + P[2]) / 2,
|
|
187
|
+
(P[2] + P[3]) / 2
|
|
188
|
+
];
|
|
189
|
+
var Ft = ut.map((e) => Math.sin(e));
|
|
190
|
+
var Ot = ut.map((e) => Math.cos(e));
|
|
191
|
+
var ct = ({ cornerRadius: e, exponent: t, roundingAndSmoothingBudget: r }) => {
|
|
192
|
+
let n = Math.min(e, r);
|
|
193
|
+
if (n <= 0) return q;
|
|
194
|
+
let s = Number.isFinite(t) ? Math.max(2, t) : 4, o = 2 / s, i = s === 2 ? (u) => u : s === 4 ? Math.sqrt : s === 8 ? (u) => Math.sqrt(Math.sqrt(u)) : (u) => Math.pow(u, o), p = o - 1, g = s === 2 ? () => 1 : s === 4 ? (u) => 1 / Math.sqrt(u) : (u) => Math.pow(u, p), h = P.map((u, c) => c === 0 ? [0, 0] : c === P.length - 1 ? [n, n] : [n * i(tt[c]), n * (1 - i(et[c]))]), $ = P.map((u, c) => {
|
|
195
|
+
if (c === 0) return [1, 0];
|
|
196
|
+
if (c === P.length - 1) return [0, 1];
|
|
197
|
+
let a = o * g(tt[c]) * et[c] * n, m = o * g(et[c]) * tt[c] * n, l = Math.sqrt(a * a + m * m) || 1;
|
|
198
|
+
return [a / l, m / l];
|
|
199
|
+
}), x = [];
|
|
200
|
+
for (let u = 0; u < P.length - 1; u++) {
|
|
201
|
+
let [c, a] = h[u], [m, l] = h[u + 1], [d, f] = $[u], [S, M] = $[u + 1], v = n * i(Ft[u]), b = n * (1 - i(Ot[u])), N = 8 / 3 * (v - (c + m) / 2), B = 8 / 3 * (b - (a + l) / 2), F = S * f - M * d, D = F !== 0 ? (-M * N + S * B) / F : 0, O = F !== 0 ? (d * B - f * N) / F : 0, I = c + D * d, R = a + D * f, _ = m - O * S, H = l - O * M, w = I - c, j = R - a, At = _ - c, Et = H - a, Nt = m - c, It = l - a;
|
|
202
|
+
x.push(k(w, j, At, Et, Nt, It));
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
p: n,
|
|
206
|
+
pathSegment: (u) => {
|
|
207
|
+
let c = z(x[0], u);
|
|
208
|
+
for (let a = 1; a < x.length; a++) c += " " + z(x[a], u);
|
|
209
|
+
return c;
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
function nt(e, t, r, n) {
|
|
214
|
+
if (n <= 0) return {
|
|
215
|
+
x: 0,
|
|
216
|
+
y: 0,
|
|
217
|
+
theta: e
|
|
218
|
+
};
|
|
219
|
+
let o = n / 32, i = 0, p = 0;
|
|
220
|
+
for (let h = 1; h <= 32; h++) {
|
|
221
|
+
let $ = (h - 1) * o, x = $ + o, u = ($ + x) / 2, c = e + t * $ + r / 2 * $ * $, a = e + t * x + r / 2 * x * x, m = e + t * u + r / 2 * u * u;
|
|
222
|
+
i += o / 6 * (Math.cos(c) + 4 * Math.cos(m) + Math.cos(a)), p += o / 6 * (Math.sin(c) + 4 * Math.sin(m) + Math.sin(a));
|
|
223
|
+
}
|
|
224
|
+
let g = e + t * n + r / 2 * n * n;
|
|
225
|
+
return {
|
|
226
|
+
x: i,
|
|
227
|
+
y: p,
|
|
228
|
+
theta: g
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
var qt = 1e-6;
|
|
232
|
+
var pt = ({ cornerRadius: e, smoothing: t, roundingAndSmoothingBudget: r }) => {
|
|
233
|
+
if (e <= 0) return q;
|
|
234
|
+
let n = Math.max(0, Math.min(1, t)), s = e, o = Math.PI / 4 * n, i = Math.PI / 2 * s * n, p = i > 0 ? 1 / (s * i) : 0, { x: g, y: h } = i > 0 ? nt(0, 0, p, i) : {
|
|
235
|
+
x: 0,
|
|
236
|
+
y: 0
|
|
237
|
+
}, { x: $, y: x } = i > 0 ? nt(0, 0, p, i / 2) : {
|
|
238
|
+
x: 0,
|
|
239
|
+
y: 0
|
|
240
|
+
}, a = g - s * Math.sin(o) + (h + s * Math.cos(o)), m = a, l = s, d = g, f = h, S = $, M = x;
|
|
241
|
+
if (a > r && a > 0) {
|
|
242
|
+
let R = r / a;
|
|
243
|
+
m = r, l = s * R, d = g * R, f = h * R, S = $ * R, M = x * R;
|
|
244
|
+
}
|
|
245
|
+
if (m <= 0) return q;
|
|
246
|
+
let v = Math.cos(o), b = Math.sin(o), N = 0, B = 0;
|
|
247
|
+
i > 0 && (b > 1e-12 && (B = 8 / 3 * (f / 2 - M) / b), N = 8 / 3 * (S - d / 2) + B * v);
|
|
248
|
+
let F = Math.PI / 2 - 2 * o, D = Math.abs(F) > qt, O = i > 0 ? {
|
|
249
|
+
head: k(N, 0, d - B * v, f - B * b, d, f),
|
|
250
|
+
tail: k(B * b, B * v, f, d - N, f, d)
|
|
251
|
+
} : null, I = null;
|
|
252
|
+
if (D) {
|
|
253
|
+
let R = m - d - f, _ = y(R);
|
|
254
|
+
I = {
|
|
255
|
+
radius: y(l),
|
|
256
|
+
d: _,
|
|
257
|
+
dn: L(R, _)
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
p: m,
|
|
262
|
+
pathSegment: (R) => {
|
|
263
|
+
if (O === null) return I === null ? "" : W(I, R);
|
|
264
|
+
let _ = z(O.head, R), H = z(O.tail, R);
|
|
265
|
+
return I === null ? _ + " " + H : _ + " " + W(I, R) + " " + H;
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
var dt = {
|
|
270
|
+
arc: it,
|
|
271
|
+
squircle: at,
|
|
272
|
+
superellipse: ct,
|
|
273
|
+
clothoid: pt
|
|
274
|
+
};
|
|
275
|
+
Object.keys(dt);
|
|
276
|
+
function ft(e) {
|
|
277
|
+
return dt[e];
|
|
278
|
+
}
|
|
279
|
+
var U = /* @__PURE__ */ new Map();
|
|
280
|
+
var Z = null;
|
|
281
|
+
function Ht(e, t) {
|
|
282
|
+
return e + "|" + t.cornerRadius + "|" + t.smoothing + "|" + t.exponent + "|" + (t.preserveSmoothing ? 1 : 0) + "|" + t.roundingAndSmoothingBudget;
|
|
283
|
+
}
|
|
284
|
+
function Ut(e) {
|
|
285
|
+
return !Number.isFinite(e.cornerRadius) || !Number.isFinite(e.smoothing) || !Number.isFinite(e.exponent) || !Number.isFinite(e.roundingAndSmoothingBudget);
|
|
286
|
+
}
|
|
287
|
+
function Dt(e) {
|
|
288
|
+
let t = {};
|
|
289
|
+
return {
|
|
290
|
+
p: e.p,
|
|
291
|
+
pathSegment: (r) => {
|
|
292
|
+
let n = t[r];
|
|
293
|
+
if (n !== void 0) return n;
|
|
294
|
+
let s = e.pathSegment(r);
|
|
295
|
+
return t[r] = s, s;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function lt(e, t, r) {
|
|
300
|
+
if (Ut(r)) return t(r);
|
|
301
|
+
let n = Ht(e, r), s = U.get(n);
|
|
302
|
+
if (s) return n !== Z && (U.delete(n), U.set(n, s), Z = n), s;
|
|
303
|
+
let o = Dt(t(r));
|
|
304
|
+
return U.size >= 64 && U.delete(U.keys().next().value), U.set(n, o), Z = n, o;
|
|
305
|
+
}
|
|
306
|
+
function X(e, t, r, n) {
|
|
307
|
+
let o = Y({
|
|
308
|
+
cornerRadius: e,
|
|
309
|
+
cornerSmoothing: Math.min(t, n / e - 1),
|
|
310
|
+
preserveSmoothing: r,
|
|
311
|
+
roundingAndSmoothingBudget: n
|
|
312
|
+
}), i = o.a + o.b + o.c;
|
|
313
|
+
return {
|
|
314
|
+
p: o.p,
|
|
315
|
+
a: o.a,
|
|
316
|
+
b: o.b,
|
|
317
|
+
c: o.c,
|
|
318
|
+
d: o.d,
|
|
319
|
+
e: i,
|
|
320
|
+
ax: o.p - i,
|
|
321
|
+
ay: e - o.d,
|
|
322
|
+
R: e
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
function K({ a: e, b: t, c: r, d: n, e: s, ax: o, ay: i, R: p }) {
|
|
326
|
+
let g = e + t, h = t + r, $ = y(e), x = y(g), u = y(s), c = y(r), a = y(h), m = y(n), l = y(o), d = y(i);
|
|
327
|
+
return {
|
|
328
|
+
a: $,
|
|
329
|
+
an: L(e, $),
|
|
330
|
+
ab: x,
|
|
331
|
+
abn: L(g, x),
|
|
332
|
+
e: u,
|
|
333
|
+
en: L(s, u),
|
|
334
|
+
c,
|
|
335
|
+
cn: L(r, c),
|
|
336
|
+
bc: a,
|
|
337
|
+
bcn: L(h, a),
|
|
338
|
+
d: m,
|
|
339
|
+
dn: L(n, m),
|
|
340
|
+
r: y(p),
|
|
341
|
+
ax: l,
|
|
342
|
+
axn: L(o, l),
|
|
343
|
+
ay: d,
|
|
344
|
+
ayn: L(i, d)
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function bt(e) {
|
|
348
|
+
let t = K(e);
|
|
349
|
+
return `c ${t.a} 0 ${t.ab} 0 ${t.e} ${t.d} a ${t.r} ${t.r} 0 0 1 ${t.ax} ${t.ay} a ${t.r} ${t.r} 0 0 1 ${t.axn} ${t.ay} c ${t.cn} ${t.d} ${t.bcn} ${t.d} ${t.en} ${t.d}`;
|
|
350
|
+
}
|
|
351
|
+
function gt(e) {
|
|
352
|
+
let t = K(e);
|
|
353
|
+
return `c ${t.an} 0 ${t.abn} 0 ${t.en} ${t.dn} a ${t.r} ${t.r} 0 0 1 ${t.axn} ${t.ayn} a ${t.r} ${t.r} 0 0 1 ${t.ax} ${t.ayn} c ${t.c} ${t.dn} ${t.bc} ${t.dn} ${t.e} ${t.dn}`;
|
|
354
|
+
}
|
|
355
|
+
function ht(e) {
|
|
356
|
+
let t = K(e);
|
|
357
|
+
return `c 0 ${t.an} 0 ${t.abn} ${t.d} ${t.en} a ${t.r} ${t.r} 0 0 1 ${t.ay} ${t.axn} a ${t.r} ${t.r} 0 0 1 ${t.ay} ${t.ax} c ${t.d} ${t.c} ${t.d} ${t.bc} ${t.d} ${t.e}`;
|
|
358
|
+
}
|
|
359
|
+
function $t(e) {
|
|
360
|
+
let t = K(e);
|
|
361
|
+
return `c 0 ${t.a} 0 ${t.ab} ${t.dn} ${t.e} a ${t.r} ${t.r} 0 0 1 ${t.ayn} ${t.ax} a ${t.r} ${t.r} 0 0 1 ${t.ayn} ${t.axn} c ${t.dn} ${t.cn} ${t.dn} ${t.bcn} ${t.dn} ${t.en}`;
|
|
362
|
+
}
|
|
363
|
+
function xt(e, t, r, n) {
|
|
364
|
+
let s = Y({
|
|
365
|
+
cornerRadius: e,
|
|
366
|
+
cornerSmoothing: t,
|
|
367
|
+
preserveSmoothing: r,
|
|
368
|
+
roundingAndSmoothingBudget: n
|
|
369
|
+
}), o = G(45 * t);
|
|
370
|
+
return {
|
|
371
|
+
a: s.a,
|
|
372
|
+
b: s.b,
|
|
373
|
+
p: s.p,
|
|
374
|
+
sin: Math.sin(o),
|
|
375
|
+
cos: Math.cos(o)
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
var Ct = (e, t, r) => Math.max(0, Math.min(e / t - 1, r));
|
|
379
|
+
var T = (e) => y(Object.is(e, -0) ? 0 : e);
|
|
380
|
+
function yt(e, t, r, n, s) {
|
|
381
|
+
let o = xt(r, Ct(e / 2, r, n), s, e / 2), i = xt(r, Ct(t / 2, r, n), s, t / 2), p = (u, c, a, m, l, d) => {
|
|
382
|
+
let f = m === 0 ? o : i, S = d === 0 ? o : i, M = u + (a + l) * r, v = c + (m + d) * r, b = M - l * r * f.cos - a * r * f.sin, N = v - d * r * f.cos - m * r * f.sin, B = M - a * r * S.cos - l * r * S.sin, F = v - m * r * S.cos - d * r * S.sin, D = u + a * f.p, O = c + m * f.p, I = Math.hypot(B - b, F - N) > 1e-6, R = I ? B : b, _ = I ? F : N, H = u + l * S.p, w = c + d * S.p, j = `L ${T(D)} ${T(O)} `;
|
|
383
|
+
return j += `c ${T(-a * f.a)} ${T(-m * f.a)} ${T(-a * (f.a + f.b))} ${T(-m * (f.a + f.b))} ${T(b - D)} ${T(N - O)} `, I && (j += `a ${T(r)} ${T(r)} 0 0 1 ${T(B - b)} ${T(F - N)} `), j += `c ${T(H - l * (S.a + S.b) - R)} ${T(w - d * (S.a + S.b) - _)} ${T(H - l * S.a - R)} ${T(w - d * S.a - _)} ${T(H - R)} ${T(w - _)}`, j;
|
|
384
|
+
}, g = p(e, 0, -1, 0, 0, 1), h = p(e, t, 0, -1, -1, 0), $ = p(0, t, 1, 0, 0, -1), x = p(0, 0, 0, 1, 1, 0);
|
|
385
|
+
return `M ${T(o.p)} 0 ${g} ${h} ${$} ${x} Z`;
|
|
386
|
+
}
|
|
387
|
+
var Gt = .65;
|
|
388
|
+
var zt = "squircle";
|
|
389
|
+
var C = y;
|
|
390
|
+
function Lt(e) {
|
|
391
|
+
return {
|
|
392
|
+
radius: e.radius,
|
|
393
|
+
curve: e.curve ?? "squircle",
|
|
394
|
+
smoothing: e.smoothing ?? .65,
|
|
395
|
+
exponent: e.exponent ?? 4,
|
|
396
|
+
preserveSmoothing: e.preserveSmoothing ?? true
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
function J(e) {
|
|
400
|
+
return Lt(typeof e == "number" ? { radius: e } : e ?? { radius: 0 });
|
|
401
|
+
}
|
|
402
|
+
function Yt(e) {
|
|
403
|
+
if ("radius" in e) {
|
|
404
|
+
let t = Lt(e);
|
|
405
|
+
return {
|
|
406
|
+
topLeft: t,
|
|
407
|
+
topRight: t,
|
|
408
|
+
bottomRight: t,
|
|
409
|
+
bottomLeft: t
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
return {
|
|
413
|
+
topLeft: J(e.topLeft),
|
|
414
|
+
topRight: J(e.topRight),
|
|
415
|
+
bottomRight: J(e.bottomRight),
|
|
416
|
+
bottomLeft: J(e.bottomLeft)
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function A(e) {
|
|
420
|
+
return e.length > 0 ? " " + e : "";
|
|
421
|
+
}
|
|
422
|
+
function E(e, t) {
|
|
423
|
+
let r = ft(e.curve);
|
|
424
|
+
return lt(e.curve, r, {
|
|
425
|
+
cornerRadius: t.radius,
|
|
426
|
+
smoothing: e.smoothing,
|
|
427
|
+
exponent: e.exponent,
|
|
428
|
+
preserveSmoothing: e.preserveSmoothing,
|
|
429
|
+
roundingAndSmoothingBudget: t.roundingAndSmoothingBudget
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
var St = 1e-9;
|
|
433
|
+
function Q(e, t, r, n, s) {
|
|
434
|
+
return e.curve === "squircle" && t.curve === "squircle" && Math.abs(r.radius - s) < St && Math.abs(n.radius - s) < St && e.smoothing === t.smoothing && e.preserveSmoothing === t.preserveSmoothing;
|
|
435
|
+
}
|
|
436
|
+
function rt(e, t, r, n) {
|
|
437
|
+
return (e === r || e.curve === r.curve && e.smoothing === r.smoothing && e.exponent === r.exponent && e.preserveSmoothing === r.preserveSmoothing) && (t === n || t.radius === n.radius && t.roundingAndSmoothingBudget === n.roundingAndSmoothingBudget);
|
|
438
|
+
}
|
|
439
|
+
function ot(e, t, r) {
|
|
440
|
+
if (e <= 0 || t <= 0) return "M 0 0 H 0 V 0 H 0 Z";
|
|
441
|
+
let n = Yt(r);
|
|
442
|
+
if (n.topLeft.radius <= 0 && n.topRight.radius <= 0 && n.bottomRight.radius <= 0 && n.bottomLeft.radius <= 0) return `M 0 0 H ${e} V ${t} H 0 Z`;
|
|
443
|
+
let s = st({
|
|
444
|
+
topLeftCornerRadius: n.topLeft.radius,
|
|
445
|
+
topRightCornerRadius: n.topRight.radius,
|
|
446
|
+
bottomRightCornerRadius: n.bottomRight.radius,
|
|
447
|
+
bottomLeftCornerRadius: n.bottomLeft.radius,
|
|
448
|
+
width: e,
|
|
449
|
+
height: t
|
|
450
|
+
}), o = n.topLeft;
|
|
451
|
+
if (wt(n)) {
|
|
452
|
+
let c = Math.min(o.radius, e / 2, t / 2), a = Math.min(e, t) / 2, m = 1e-9;
|
|
453
|
+
if (c > 0 && a > c + m && a < (1 + o.smoothing) * c - m) return yt(e, t, c, o.smoothing, o.preserveSmoothing);
|
|
454
|
+
}
|
|
455
|
+
let i = e >= t, p = i ? t / 2 : e / 2;
|
|
456
|
+
if (i) {
|
|
457
|
+
let c = Q(n.topRight, n.bottomRight, s.topRight, s.bottomRight, p), a = Q(n.topLeft, n.bottomLeft, s.topLeft, s.bottomLeft, p);
|
|
458
|
+
if (c || a) {
|
|
459
|
+
let m = e / 2, l = c ? X(p, n.topRight.smoothing, n.topRight.preserveSmoothing, m) : null, d = a ? X(p, n.topLeft.smoothing, n.topLeft.preserveSmoothing, m) : null, f = d ? null : E(n.topLeft, s.topLeft), S = l ? null : E(n.topRight, s.topRight), M = l ? null : E(n.bottomRight, s.bottomRight), v = d ? null : E(n.bottomLeft, s.bottomLeft), b = "M " + C(d ? d.p : f.p) + " 0";
|
|
460
|
+
return b += " L " + C(e - (l ? l.p : S.p)) + " 0", l ? b += " " + bt(l) : (b += A(S.pathSegment("TR")), b += " L " + C(e) + " " + C(M.p), b += " L " + C(e) + " " + C(t - M.p), b += A(M.pathSegment("BR"))), d ? (b += " L " + C(d.p) + " " + C(t), b += " " + gt(d)) : (b += " L " + C(e - v.p) + " " + C(t), b += " L " + C(v.p) + " " + C(t), b += A(v.pathSegment("BL")), b += " L 0 " + C(t - f.p), b += " L 0 " + C(f.p), b += A(f.pathSegment("TL"))), b + " Z";
|
|
461
|
+
}
|
|
462
|
+
} else {
|
|
463
|
+
let c = Q(n.topLeft, n.topRight, s.topLeft, s.topRight, p), a = Q(n.bottomLeft, n.bottomRight, s.bottomLeft, s.bottomRight, p);
|
|
464
|
+
if (c || a) {
|
|
465
|
+
let m = t / 2, l = c ? X(p, n.topLeft.smoothing, n.topLeft.preserveSmoothing, m) : null, d = a ? X(p, n.bottomLeft.smoothing, n.bottomLeft.preserveSmoothing, m) : null, f = l ? null : E(n.topLeft, s.topLeft), S = l ? null : E(n.topRight, s.topRight), M = d ? null : E(n.bottomRight, s.bottomRight), v = d ? null : E(n.bottomLeft, s.bottomLeft), b;
|
|
466
|
+
return l ? b = "M 0 " + C(l.p) + " " + ht(l) : (b = "M " + C(f.p) + " 0", b += " L " + C(e - S.p) + " 0", b += A(S.pathSegment("TR"))), b += " L " + C(e) + " " + C(t - (d ? d.p : M.p)), d ? b += " " + $t(d) : (b += A(M.pathSegment("BR")), b += " L " + C(v.p) + " " + C(t), b += A(v.pathSegment("BL"))), l ? b += " L 0 " + C(l.p) : (b += " L 0 " + C(t - f.p), b += " L 0 " + C(f.p), b += A(f.pathSegment("TL"))), b + " Z";
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
let g = E(n.topLeft, s.topLeft), h = rt(n.topLeft, s.topLeft, n.topRight, s.topRight) && rt(n.topLeft, s.topLeft, n.bottomRight, s.bottomRight) && rt(n.topLeft, s.topLeft, n.bottomLeft, s.bottomLeft), $ = h ? g : E(n.topRight, s.topRight), x = h ? g : E(n.bottomRight, s.bottomRight), u = h ? g : E(n.bottomLeft, s.bottomLeft);
|
|
470
|
+
return "M " + C(g.p) + " 0 L " + C(e - $.p) + " 0" + A($.pathSegment("TR")) + " L " + C(e) + " " + C(x.p) + " L " + C(e) + " " + C(t - x.p) + A(x.pathSegment("BR")) + " L " + C(e - u.p) + " " + C(t) + " L " + C(u.p) + " " + C(t) + A(u.pathSegment("BL")) + " L 0 " + C(t - g.p) + " L 0 " + C(g.p) + A(g.pathSegment("TL")) + " Z";
|
|
471
|
+
}
|
|
472
|
+
function wt(e) {
|
|
473
|
+
let t = e.topLeft, r = e.topRight, n = e.bottomRight, s = e.bottomLeft;
|
|
474
|
+
return t.curve === "squircle" && r.curve === "squircle" && r.radius === t.radius && r.smoothing === t.smoothing && r.preserveSmoothing === t.preserveSmoothing && n.curve === "squircle" && n.radius === t.radius && n.smoothing === t.smoothing && n.preserveSmoothing === t.preserveSmoothing && s.curve === "squircle" && s.radius === t.radius && s.smoothing === t.smoothing && s.preserveSmoothing === t.preserveSmoothing;
|
|
475
|
+
}
|
|
476
|
+
//#endregion
|
|
477
|
+
export { st as a, it as b, Y as c, at as d, ct as e, pt as f, ft as i, Gt as m, zt as o, ot as p };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { smoothPathD } from "./path.js";
|
|
2
|
+
import { createElement, createScopedElement, createScopedValue, hookSlots, positionalChildren, useLayoutEffect, useRef, useState } from "octane";
|
|
3
|
+
//#region src/SmoothCorners.web.tsrx
|
|
4
|
+
var _hs$ = /* @__PURE__ */ hookSlots(3);
|
|
5
|
+
var SmoothCorners = function SmoothCorners(props, __s, __extra) {
|
|
6
|
+
const ref = useRef(null, _hs$ + 0);
|
|
7
|
+
const [size, setSize] = useState({
|
|
8
|
+
w: 0,
|
|
9
|
+
h: 0
|
|
10
|
+
}, _hs$ + 1);
|
|
11
|
+
useLayoutEffect(() => {
|
|
12
|
+
const el = ref.current;
|
|
13
|
+
if (!el) return;
|
|
14
|
+
const update = () => {
|
|
15
|
+
const r = el.getBoundingClientRect();
|
|
16
|
+
setSize((prev) => prev.w === r.width && prev.h === r.height ? prev : {
|
|
17
|
+
w: r.width,
|
|
18
|
+
h: r.height
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
update();
|
|
22
|
+
const ro = new ResizeObserver(update);
|
|
23
|
+
ro.observe(el);
|
|
24
|
+
return () => ro.disconnect();
|
|
25
|
+
}, [], _hs$ + 2);
|
|
26
|
+
const d = smoothPathD(size.w, size.h, props.corners);
|
|
27
|
+
const box = createScopedValue(() => createScopedElement("div", {
|
|
28
|
+
ref,
|
|
29
|
+
id: props.id,
|
|
30
|
+
className: props.className,
|
|
31
|
+
style: {
|
|
32
|
+
position: "relative",
|
|
33
|
+
...props.style,
|
|
34
|
+
clipPath: size.w > 0 ? `path("${d}")` : void 0
|
|
35
|
+
}
|
|
36
|
+
}, () => positionalChildren([props.children, props.border && size.w > 0 && createScopedValue(() => createScopedElement("svg", {
|
|
37
|
+
style: {
|
|
38
|
+
position: "absolute",
|
|
39
|
+
inset: 0,
|
|
40
|
+
width: "100%",
|
|
41
|
+
height: "100%",
|
|
42
|
+
pointerEvents: "none",
|
|
43
|
+
overflow: "visible"
|
|
44
|
+
},
|
|
45
|
+
viewBox: `0 0 ${size.w} ${size.h}`,
|
|
46
|
+
preserveAspectRatio: "none"
|
|
47
|
+
}, () => createScopedValue(() => createElement("path", {
|
|
48
|
+
d,
|
|
49
|
+
fill: "none",
|
|
50
|
+
stroke: props.border.color,
|
|
51
|
+
strokeWidth: props.border.width * 2
|
|
52
|
+
}))))])));
|
|
53
|
+
const shadow = props.shadow;
|
|
54
|
+
if (!shadow) return box ?? null;
|
|
55
|
+
const filter = `drop-shadow(${shadow.offsetX ?? 0}px ${shadow.offsetY ?? 0}px ${shadow.blur ?? 0}px ${shadow.color ?? "rgba(0,0,0,0.35)"})`;
|
|
56
|
+
return createScopedValue(() => createScopedElement("div", { style: {
|
|
57
|
+
display: "grid",
|
|
58
|
+
filter
|
|
59
|
+
} }, () => box));
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
export { SmoothCorners };
|