Copy utils
This commit is contained in:
parent
d8a3ae7528
commit
a3f76f5c77
14 changed files with 141 additions and 3 deletions
16
src/utils/colors/hex.ts
Normal file
16
src/utils/colors/hex.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { rgb255 } from './rgb255';
|
||||
|
||||
import { vec3 } from 'gl-matrix';
|
||||
|
||||
export const hex = (hex: string): vec3 => {
|
||||
if (hex[0] === '#') {
|
||||
hex = hex.slice(1);
|
||||
}
|
||||
|
||||
const bigint = parseInt(hex, 16);
|
||||
const r = (bigint >> 16) & 255;
|
||||
const g = (bigint >> 8) & 255;
|
||||
const b = bigint & 255;
|
||||
|
||||
return rgb255(r, g, b);
|
||||
};
|
||||
Loading…
Reference in a new issue