|
70 | 70 | <input type="radio" name="algorithm" value="elika">
|
71 | 71 | Elika’s Interpolation based on rounded/straight ratio
|
72 | 72 | </label>
|
| 73 | + <label> |
| 74 | + <input type="radio" name="algorithm" value="oriol"> |
| 75 | + Oriol's variant of current spec |
| 76 | + </label> |
73 | 77 | </form>
|
74 | 78 | <output id="output"></output>
|
75 | 79 | <script>
|
|
82 | 86 | {width: 200, height: 40, spread: 50, borderRadius: "20px / 4px"},
|
83 | 87 | {width: 500, height: 50, spread: 30, borderRadius: "15px"},
|
84 | 88 | {width: 500, height: 50, spread: 30, borderRadius: "25px"},
|
| 89 | + {width: 500, height: 60, spread: 30, borderRadius: "20px 20px 40px 40px"}, |
85 | 90 | {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"}, |
86 | 93 | {width: 500, height: 50, spread: 30, borderRadius: "50%"},
|
87 | 94 | {width: 500, height: 50, spread: 30, borderRadius: "50% 50% 1px 50%"},
|
| 95 | + {width: 200, height: 40, spread: 50, borderRadius: "0 100% 0 100%"}, |
88 | 96 | {width: 0, height: 0, spread: 30, borderRadius: "50px 0px 0px 0px"},
|
| 97 | + {width: 500, height: 500, spread: 30, borderRadius: "50px"}, |
89 | 98 | ];
|
90 | 99 |
|
91 | 100 | function show({incremental = false} = {}) {
|
|
278 | 287 |
|
279 | 288 | }
|
280 | 289 | }
|
| 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 | + } |
281 | 305 |
|
282 | 306 | 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`;
|
283 | 307 | }
|
|
0 commit comments