Skip to content

Instantly share code, notes, and snippets.

@zeraphie
Last active March 27, 2023 04:26
Show Gist options
  • Save zeraphie/83f565e837a55ba0ee6811e42a7f243c to your computer and use it in GitHub Desktop.
Save zeraphie/83f565e837a55ba0ee6811e42a7f243c to your computer and use it in GitHub Desktop.
Make a word with a different one ontop of it like Beͦsͧtͭ tͨoͪoͣlͬ eͫvͤeͩr

Dual Words

I was bored and made this small tool to merge words together, below is an example of it working in action

https://codepen.io/zephyr/full/GxPbZR

This was made using this

If you want to make a word with the allowed letters, this tool can help. The allowed letters are: "aeioucdhmrtvx"

export default class Alphabet {
static generate(lowercase = true){
let start = lowercase ? 97 : 65;
return new Array(26).fill(1).map((_, i) => String.fromCharCode(start + i));
}
static get lowercase(){
return this.generate(true);
}
static get uppercase(){
return this.generate(false);
}
static get combined(){
return this.lowercase.concat(this.uppercase);
}
static get combiningSmallLetters(){
return {
// Vowels
a: 'ͣ ',
e: 'ͤ ',
i: 'ͥ ',
o: 'ͦ ',
u: 'ͧ ',
// Consonants
c: 'ͨ ',
d: 'ͩ ',
h: 'ͪ ',
m: 'ͫ ',
r: 'ͬ ',
t: 'ͭ ',
v: 'ͮ ',
x: 'ͯ ',
};
}
}
export default function combineWords = (w1, w2) => {
w1 = w1.split('');
w2 = w2.split('');
let illegal = 0;
return w1.reduce((total, original, position) => {
let index = Alphabet.combined.findIndex(item => item === original);
if(index === -1){
illegal++;
return total += original;
}
let character = w2[position - illegal];
if(character){
let found = Alphabet.combiningSmallLetters[character.toLowerCase()];
if(found){
let combined = [
String.fromCodePoint(original.charCodeAt(0)),
String.fromCodePoint(found.charCodeAt(0)),
// Turns out you can put these characters ontop of each other!
// ... infinitely
// String.fromCodePoint(found.charCodeAt(0)),
].join('');
return total += combined.normalize('NFC');
}
}
return total += original;
}, '');
};
// This is an old way of doing it, I made a more dynamic version using the other two files, the codepen reflects the updated version
export const keymap = {
alphabet: ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'],
// Vowels
a: ['aͣ','bͣ','cͣ','dͣ','eͣ','fͣ','gͣ','hͣ','iͣ','jͣ','kͣ','lͣ','mͣ','nͣ','oͣ','pͣ','qͣ','rͣ','sͣ','tͣ','uͣ','vͣ','wͣ','xͣ','yͣ','zͣ'],
e: ['aͤ','bͤ','cͤ','dͤ','eͤ','fͤ','gͤ','hͤ','iͤ','jͤ','kͤ','lͤ','mͤ','nͤ','oͤ','pͤ','qͤ','rͤ','sͤ','tͤ','uͤ','vͤ','wͤ','xͤ','yͤ','zͤ'],
i: ['aͥ','bͥ','cͥ','dͥ','eͥ','fͥ','gͥ','hͥ','iͥ','jͥ','kͥ','lͥ','mͥ','nͥ','oͥ','pͥ','qͥ','rͥ','sͥ','tͥ','uͥ','vͥ','wͥ','xͥ','yͥ','zͥ'],
o: ['aͦ','bͦ','cͦ','dͦ','eͦ','fͦ','gͦ','hͦ','iͦ','jͦ','kͦ','lͦ','mͦ','nͦ','oͦ','pͦ','qͦ','rͦ','sͦ','tͦ','uͦ','vͦ','wͦ','xͦ','yͦ','zͦ'],
u: ['aͧ','bͧ','cͧ','dͧ','eͧ','fͧ','gͧ','hͧ','iͧ','jͧ','kͧ','lͧ','mͧ','nͧ','oͧ','pͧ','qͧ','rͧ','sͧ','tͧ','uͧ','vͧ','wͧ','xͧ','yͧ','zͧ'],
// Consonants
c: ['aͨ','bͨ','cͨ','dͨ','eͨ','fͨ','gͨ','hͨ','iͨ','jͨ','kͨ','lͨ','mͨ','nͨ','oͨ','pͨ','qͨ','rͨ','sͨ','tͨ','uͨ','vͨ','wͨ','xͨ','yͨ','zͨ'],
d: ['aͩ','bͩ','cͩ','dͩ','eͩ','fͩ','gͩ','hͩ','iͩ','jͩ','kͩ','lͩ','mͩ','nͩ','oͩ','pͩ','qͩ','rͩ','sͩ','tͩ','uͩ','vͩ','wͩ','xͩ','yͩ','zͩ'],
h: ['aͪ','bͪ','cͪ','dͪ','eͪ','fͪ','gͪ','hͪ','iͪ','jͪ','kͪ','lͪ','mͪ','nͪ','oͪ','pͪ','qͪ','rͪ','sͪ','tͪ','uͪ','vͪ','wͪ','xͪ','yͪ','zͪ'],
m: ['aͫ','bͫ','cͫ','dͫ','eͫ','fͫ','gͫ','hͫ','iͫ','jͫ','kͫ','lͫ','mͫ','nͫ','oͫ','pͫ','qͫ','rͫ','sͫ','tͫ','uͫ','vͫ','wͫ','xͫ','yͫ','zͫ'],
r: ['aͬ','bͬ','cͬ','dͬ','eͬ','fͬ','gͬ','hͬ','iͬ','jͬ','kͬ','lͬ','mͬ','nͬ','oͬ','pͬ','qͬ','rͬ','sͬ','tͬ','uͬ','vͬ','wͬ','xͬ','yͬ','zͬ'],
t: ['aͭ','bͭ','cͭ','dͭ','eͭ','fͭ','gͭ','hͭ','iͭ','jͭ','kͭ','lͭ','mͭ','nͭ','oͭ','pͭ','qͭ','rͭ','sͭ','tͭ','uͭ','vͭ','wͭ','xͭ','yͭ','zͭ'],
v: ['aͮ','bͮ','cͮ','dͮ','eͮ','fͮ','gͮ','hͮ','iͮ','jͮ','kͮ','lͮ','mͮ','nͮ','oͮ','pͮ','qͮ','rͮ','sͮ','tͮ','uͮ','vͮ','wͮ','xͮ','yͮ','zͮ'],
x: ['aͯ','bͯ','cͯ','dͯ','eͯ','fͯ','gͯ','hͯ','iͯ','jͯ','kͯ','lͯ','mͯ','nͯ','oͯ','pͯ','qͯ','rͯ','sͯ','tͯ','uͯ','vͯ','wͯ','xͯ','yͯ','zͯ'],
};
export default function findDualWord = (w1, w2) => {
w1 = w1.split('');
w2 = w2.split('');
let illegal = 0;
return w1.reduce((total, original, position) => {
let index = keymap.alphabet.findIndex(item => item === original.toLowerCase());
if(index === -1){
illegal++;
return total += original;
}
let character = w2[position - illegal];
if(character && keymap[character.toLowerCase()]){
return total += keymap[character.toLowerCase()][index];
}
return total += original;
}, '');
};
@tariqhussainkpk
Copy link

Hi

@Iinksafe
Copy link

ok

@leetyle2059u
Copy link

Its good
Udhdhdidhd
Hdhfjfjdnd
Jdhdidbdjd
Duhddbjdndjd
Idhdbdjfhfj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment