refactor
This commit is contained in:
parent
4c24bd3933
commit
2547c8c117
7 changed files with 42 additions and 77 deletions
7
packages/frontend/src/scripts/color.ts
Normal file
7
packages/frontend/src/scripts/color.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export const alpha = (hex: string, a: number): string => {
|
||||
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)!;
|
||||
const r = parseInt(result[1], 16);
|
||||
const g = parseInt(result[2], 16);
|
||||
const b = parseInt(result[3], 16);
|
||||
return `rgba(${r}, ${g}, ${b}, ${a})`;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue