72
72
</ label >
73
73
< label >
74
74
< input type ="radio " name ="algorithm " value ="oriol ">
75
- Oriol's variant of current spec
75
+ Oriol's variant of current spec (adding a cubic factor)
76
+ </ label >
77
+ < label >
78
+ < input type ="radio " name ="algorithm " value ="oriol2 ">
79
+ Oriol's variant of current spec (adding a linear factor)
76
80
</ label >
77
81
</ form >
78
82
< output id ="output "> </ output >
93
97
{ width : 500 , height : 50 , spread : 30 , borderRadius : "50%" } ,
94
98
{ width : 500 , height : 50 , spread : 30 , borderRadius : "50% 50% 1px 50%" } ,
95
99
{ width : 200 , height : 40 , spread : 50 , borderRadius : "0 100% 0 100%" } ,
100
+ { width : 200 , height : 40 , spread : 50 , borderRadius : "10% 90% / 5%" } ,
101
+ { width : 200 , height : 40 , spread : 50 , borderRadius : "0 50% / 50%" } ,
96
102
{ width : 0 , height : 0 , spread : 30 , borderRadius : "50px 0px 0px 0px" } ,
97
103
{ width : 500 , height : 500 , spread : 30 , borderRadius : "50px" } ,
98
104
] ;
302
308
} ) ;
303
309
}
304
310
}
311
+ else if ( algorithm === "oriol2" ) {
312
+ for ( let corner in radii ) {
313
+ let coverage = Math . max (
314
+ 2 * radii [ corner ] [ 0 ] / testCase . width ,
315
+ 2 * radii [ corner ] [ 1 ] / testCase . height ,
316
+ ) || 0 ;
317
+ r [ corner ] = radii [ corner ] . map ( value => {
318
+ if ( value >= testCase . spread || coverage >= 1 ) {
319
+ return value + testCase . spread ;
320
+ }
321
+ let r = 1 - value / testCase . spread ;
322
+ return value + testCase . spread * ( 1 - r ** 3 * ( 1 - coverage ) ) ;
323
+ } ) ;
324
+ }
325
+ }
305
326
306
327
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` ;
307
328
}
312
333
</ script >
313
334
314
335
</ body >
315
- </ html >
336
+ </ html >
0 commit comments