Created
November 20, 2020 03:17
-
-
Save callmetwan/61e1690feccd9a6448d139158733f127 to your computer and use it in GitHub Desktop.
JS adjustable RGBA opacity
This file contains hidden or 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
function adjustRgbaOpacity(color: string, opacity: number) { | |
color.replace(/[^,]+(?=\))/, opacity); | |
} | |
const rgba = 'rgba(255, 255, 255, 1)'; | |
const rgbargba = adjustRgbaOpacity(color, .5); | |
https://stackoverflow.com/a/8179549/2124039 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment