]>
Commit | Line | Data |
---|---|---|
66dc4cae BB |
1 | const internals = { |
2 | kSplitterRegex: /.{1,8}/g, | |
3 | kGlyphs: [ | |
41247723 BB |
4 | '☽', |
5 | '☆', | |
6 | '♢', | |
7 | '♡', | |
8 | '╱', | |
9 | '╲', | |
10 | '╳', | |
11 | '〰', | |
12 | '▷', | |
13 | '⏊', | |
14 | '〒', | |
15 | '▢', | |
16 | '◯', | |
17 | '⏃', | |
18 | '⏀', | |
19 | '⏆' | |
66dc4cae BB |
20 | ] |
21 | }; | |
22 | ||
23 | // Return a glyph with color based on a 4 byte fragment of a UUIDv4 | |
24 | const getGlyphHashFragment = function (uuidFragment) { | |
25 | ||
26 | const glyphIndex = parseInt(uuidFragment.substring(0,2), 16) % 16; | |
27 | return { | |
28 | glyph: internals.kGlyphs[glyphIndex], | |
29 | color: `#${uuidFragment.substring(2,8)}` | |
00a6e8aa | 30 | }; |
66dc4cae BB |
31 | }; |
32 | ||
33 | // Return an array of glyphs based on a UUIDv4 | |
34 | export const getGlyphHash = function (uuid) { | |
35 | ||
c64352ff | 36 | const hashFragments = uuid.replace(/[-]/g,'').match(internals.kSplitterRegex); |
66dc4cae BB |
37 | return hashFragments.map(getGlyphHashFragment); |
38 | }; |