Add meme view & sharing
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -32,6 +32,15 @@ const rgbToHex = (rgb: string) => {
|
||||
return `#${r.toString(16)}${g.toString(16)}${b.toString(16)}`;
|
||||
};
|
||||
|
||||
const rgbToRgba = (rgb: string, alpha: number) => {
|
||||
const [r, g, b] = rgb
|
||||
.replaceAll(/[^\d,]/g, '')
|
||||
.split(',')
|
||||
.map(value => Number.parseInt(value, 10));
|
||||
|
||||
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
||||
};
|
||||
|
||||
const generateRandomColor = () => {
|
||||
const r = Math.floor(Math.random() * 256)
|
||||
.toString(16)
|
||||
@@ -50,5 +59,6 @@ export {
|
||||
isHexColor,
|
||||
isRgbColor,
|
||||
rgbToHex,
|
||||
rgbToRgba,
|
||||
generateRandomColor,
|
||||
};
|
||||
|
Reference in New Issue
Block a user