Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
15 lines (13 sloc)
476 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import parseToRgba from './parseToRgba'; | |
import rgba from './rgba'; | |
/** | |
* Takes in a color and makes it more transparent by convert to `rgba` and | |
* decreasing the amount in the alpha channel. | |
* | |
* @param amount The amount to increase the transparency by, given as a decimal between 0 and 1 | |
*/ | |
function transparentize(color: string, amount: number): string { | |
const [r, g, b, a] = parseToRgba(color); | |
return rgba(r, g, b, a - amount); | |
} | |
export default transparentize; |