Skip to content

Commit fd50f90

Browse files
committed
[css-backgrounds-3] Add Oriol's variant and testcases to radius-expansion.html
1 parent b76c566 commit fd50f90

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

css-backgrounds-3/radius-expansion.html

+24
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
<input type="radio" name="algorithm" value="elika">
7171
Elika’s Interpolation based on rounded/straight ratio
7272
</label>
73+
<label>
74+
<input type="radio" name="algorithm" value="oriol">
75+
Oriol's variant of current spec
76+
</label>
7377
</form>
7478
<output id="output"></output>
7579
<script>
@@ -82,10 +86,15 @@
8286
{width: 200, height: 40, spread: 50, borderRadius: "20px / 4px"},
8387
{width: 500, height: 50, spread: 30, borderRadius: "15px"},
8488
{width: 500, height: 50, spread: 30, borderRadius: "25px"},
89+
{width: 500, height: 60, spread: 30, borderRadius: "20px 20px 40px 40px"},
8590
{width: 500, height: 50, spread: 30, borderRadius: "1px 1px 49px 49px"},
91+
{width: 500, height: 60, spread: 30, borderRadius: "0px 0px 30px 30px"},
92+
{width: 250, height: 35, spread: 50, borderRadius: "0px 0px 25px 25px"},
8693
{width: 500, height: 50, spread: 30, borderRadius: "50%"},
8794
{width: 500, height: 50, spread: 30, borderRadius: "50% 50% 1px 50%"},
95+
{width: 200, height: 40, spread: 50, borderRadius: "0 100% 0 100%"},
8896
{width: 0, height: 0, spread: 30, borderRadius: "50px 0px 0px 0px"},
97+
{width: 500, height: 500, spread: 30, borderRadius: "50px"},
8998
];
9099

91100
function show({incremental = false} = {}) {
@@ -278,6 +287,21 @@
278287

279288
}
280289
}
290+
else if (algorithm === "oriol") {
291+
for (let corner in radii) {
292+
let coverage = Math.max(
293+
2 * radii[corner][0] / testCase.width,
294+
2 * radii[corner][1] / testCase.height,
295+
) || 0;
296+
r[corner] = radii[corner].map(value => {
297+
if (value >= testCase.spread || coverage >= 1) {
298+
return value + testCase.spread;
299+
}
300+
let r = (1 - value / testCase.spread) * (1 - coverage);
301+
return value + testCase.spread * (1 - r**3);
302+
});
303+
}
304+
}
281305

282306
return `${r.topLeft[0]}px ${r.topRight[0]}px ${r.bottomRight[0]}px ${r.bottomLeft[0]}px / ${r.topLeft[1]}px ${r.topRight[1]}px ${r.bottomRight[1]}px ${r.bottomLeft[1]}px`;
283307
}

0 commit comments

Comments
 (0)