diff options
| author | Ben Beltran <ben@nsovocal.com> | 2020-01-26 16:33:43 +0100 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2020-01-26 16:33:43 +0100 |
| commit | 66dc4cae4cd37e82d773dc30be046d82d380ec4d (patch) | |
| tree | 89723b2fa1505907a3998f8cbe81fd5448614ef6 /app/utils | |
| parent | 32ec81f6370328833fd0ba3dfe1c2974ac775973 (diff) | |
Add skeleton for topic
Tested with VoiceOver
Diffstat (limited to 'app/utils')
| -rw-r--r-- | app/utils/glyph_hash.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/app/utils/glyph_hash.js b/app/utils/glyph_hash.js new file mode 100644 index 0000000..c074376 --- /dev/null +++ b/app/utils/glyph_hash.js @@ -0,0 +1,38 @@ +const internals = { + kSplitterRegex: /.{1,8}/g, + kGlyphs: [ + "☽", + "☆", + "♢", + "♡", + "╱", + "╲", + "╳", + "〰", + "▷", + "⏊", + "〒", + "▢", + "◯", + "⏃", + "⏀", + "⏆" + ] +}; + +// Return a glyph with color based on a 4 byte fragment of a UUIDv4 +const getGlyphHashFragment = function (uuidFragment) { + + const glyphIndex = parseInt(uuidFragment.substring(0,2), 16) % 16; + return { + glyph: internals.kGlyphs[glyphIndex], + color: `#${uuidFragment.substring(2,8)}` + } +}; + +// Return an array of glyphs based on a UUIDv4 +export const getGlyphHash = function (uuid) { + + const hashFragments = uuid.match(internals.kSplitterRegex); + return hashFragments.map(getGlyphHashFragment); +}; |