Last active
January 2, 2023 12:15
-
-
Save cookieukw/c6dc34a4ec0aa2b19b11caac66aab5ec to your computer and use it in GitHub Desktop.
emojiFy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* All codes in this gist profile bearing the name of | |
a written license are licensed | |
under that same license, while | |
codes without one are unlicensed | |
and may be used without attribution. | |
MIT LICENSE | |
*/ | |
const model = [ | |
{ | |
a: [1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0], | |
}, | |
{ | |
b: [0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1], | |
}, | |
{ | |
c: [0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0], | |
}, | |
{ | |
d: [0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1], | |
}, | |
{ | |
e: [0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0], | |
}, | |
{ | |
f: [0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1], | |
}, | |
{ | |
g: [0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0], | |
}, | |
{ | |
h: [0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0], | |
}, | |
{ | |
i: [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1], | |
}, | |
{ | |
j: [1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], | |
}, | |
{ | |
k: [0, 1, 1, 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| |
y: [0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1], | |
}, | |
{ | |
z: [0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0], | |
}, | |
]; | |
const { log } = console; | |
const fs = require("fs"); | |
const letterToEmote = (letter) => { | |
if (letter.length > 1) return null; | |
letter = letter.trim().toLowerCase(); | |
let res = model.find((res) => { | |
if (Object.keys(res)[0] == letter) return true; | |
return false; | |
}); | |
res = res[letter].map((item, i) => { | |
if (item == 0) return `:1px:${(i + 1) % 4 == 0 ? `\n` : ""}`; | |
return `:0px:${(i + 1) % 4 == 0 ? `\n` : ""}`; | |
}); | |
return res.join(""); | |
}; | |
const emojiFy = (text) => { | |
let splited = text.split(""); | |
splited = splited | |
.map((letter, i) => { | |
return letterToEmote(letter) + `${i == splited.length - 1 ? "" : "\n\n"}`; | |
}) | |
.join(""); | |
return splited; | |
}; | |
fs.writeFileSync("../emojiFy.txt", emojiFy("kie")); |
disadvantages: the code gives an error if you put letters other than the common alphabet (abcde...), that is, you cannot put accents, emojis, characteristics, etc.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A code mapped to the letters of the alphabet. he makes a text with letters forming a kind of drawing. In this case they are discord emojis, where :0px: is a transparent emoji and :1px: is a full red emoji