UNPKG

533 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = getOverlayAlpha;
7// Inspired by https://github.com/material-components/material-components-ios/blob/bca36107405594d5b7b16265a5b0ed698f85a5ee/components/Elevation/src/UIColor%2BMaterialElevation.m#L61
8function getOverlayAlpha(elevation) {
9 let alphaValue;
10 if (elevation < 1) {
11 alphaValue = 5.11916 * elevation ** 2;
12 } else {
13 alphaValue = 4.5 * Math.log(elevation + 1) + 2;
14 }
15 return Math.round(alphaValue * 10) / 1000;
16}
\No newline at end of file