Skip to content

Commit c24914b

Browse files
committed
[css-backgrounds] Add additional variations and one additional testcase for w3c#7103.
1 parent e6979fb commit c24914b

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

css-backgrounds-3/radius-expansion-continuity.html

+35-11
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,27 @@
5959
</label>
6060
<label>
6161
<input type="radio" name="algorithm" value="linear-edge-portion">
62-
Rounded portion of edges (linear)
62+
Cap by rounded portion of edges (linear)
6363
</label>
6464
<label>
6565
<input type="radio" name="algorithm" value="cubic-edge-portion">
66-
Rounded portion of edges (cubic)
66+
Cap by rounded portion of edges (cubic)
6767
</label>
6868
<label>
69-
<input type="radio" name="algorithm" value="interpolate-straight-rounded">
70-
Interpolation based on straight/rounded (linear)
69+
<input type="radio" name="algorithm" value="linear-edge-ratio">
70+
Cap by rounded/straight ratio of edges (linear)
71+
</label>
72+
<label>
73+
<input type="radio" name="algorithm" value="cubic-edge-ratio">
74+
Cap by rounded/straight ratio of edges (cubic)
75+
</label>
76+
<label>
77+
<input type="radio" name="algorithm" value="interpolate-straight-rounded-portion">
78+
Interpolation based on rounded portion of edges
79+
</label>
80+
<label>
81+
<input type="radio" name="algorithm" value="interpolate-straight-rounded-ratio">
82+
Interpolation based on rounded/straight ratio
7183
</label>
7284
</form>
7385
<div id="output"></div>
@@ -81,6 +93,7 @@
8193
{width: 200, height: 40, spread: 50, borderRadius: "100px / 20px"},
8294
{width: 200, height: 40, spread: 50, borderRadius: "20px / 4px"},
8395
{width: 500, height: 50, spread: 30, borderRadius: "15px"},
96+
{width: 500, height: 50, spread: 30, borderRadius: "25px"},
8497
{width: 500, height: 50, spread: 30, borderRadius: "1px 1px 49px 49px"},
8598
{width: 500, height: 50, spread: 30, borderRadius: "50%"},
8699
{width: 500, height: 50, spread: 30, borderRadius: "50% 50% 1px 50%"},
@@ -264,30 +277,41 @@
264277
}
265278
case "linear-edge-portion":
266279
case "cubic-edge-portion":
267-
case "interpolate-straight-rounded": {
280+
case "linear-edge-ratio":
281+
case "cubic-edge-ratio":
282+
case "interpolate-straight-rounded-portion":
283+
case "interpolate-straight-rounded-ratio": {
268284
// The portion of each edge that is rounded
269285
const portion = {
270286
top: (radii.topLeft[0] + radii.topRight[0]) / testCase.width,
271287
right: (radii.topRight[1] + radii.bottomRight[1]) / testCase.height,
272288
bottom: (radii.bottomLeft[0] + radii.bottomRight[0]) / testCase.width,
273289
left: (radii.topLeft[1] + radii.bottomLeft[1]) / testCase.height,
274290
};
275-
const map = (value, cap, idx) => {
291+
const map = (value, ratio, idx) => {
276292
if (value >= testCase.spread) {
277293
return value + testCase.spread;
278294
}
279295
switch (algorithm.value) {
296+
case "linear-edge-ratio":
297+
ratio = Math.min(ratio / (1 - ratio), 1);
298+
// fallthrough
280299
case "linear-edge-portion": {
281300
let r = value / testCase.spread;
282-
return value + testCase.spread * Math.max(1 + (r - 1)**3, cap);
301+
return value + testCase.spread * Math.max(1 + (r - 1)**3, ratio);
283302
}
303+
case "cubic-edge-ratio":
304+
ratio = Math.min(ratio / (1 - ratio), 1);
305+
// fallthrough
284306
case "cubic-edge-portion": {
285-
let r = Math.max(value / testCase.spread, cap);
307+
let r = Math.max(value / testCase.spread, ratio);
286308
return value + testCase.spread * (1 + (r - 1)**3);
287309
}
288-
case "interpolate-straight-rounded": {
289-
const straight = 1 - cap;
290-
const ratio = Math.min(straight / cap, 1);
310+
case "interpolate-straight-rounded-ratio":
311+
ratio = 1 - Math.min((1 - ratio) / ratio, 1);
312+
// fallthrough
313+
case "interpolate-straight-rounded-portion": {
314+
ratio = 1 - ratio;
291315

292316
const r = value / testCase.spread;
293317
const cubic = value + testCase.spread * (1 + (r - 1)**3);

0 commit comments

Comments
 (0)