UNPKG

433 BJavaScriptView Raw
1// Inspired by https://github.com/material-components/material-components-ios/blob/bca36107405594d5b7b16265a5b0ed698f85a5ee/components/Elevation/src/UIColor%2BMaterialElevation.m#L61
2export default function getOverlayAlpha(elevation) {
3 let alphaValue;
4 if (elevation < 1) {
5 alphaValue = 5.11916 * elevation ** 2;
6 } else {
7 alphaValue = 4.5 * Math.log(elevation + 1) + 2;
8 }
9 return Math.round(alphaValue * 10) / 1000;
10}
\No newline at end of file