Add meme view & sharing

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2023-07-24 21:55:36 +03:00
parent 04661ca356
commit e479e3c0ad
33 changed files with 724 additions and 482 deletions

View File

@@ -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,
};