Skip to content

Commit

Permalink
improved emojis segmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
syxanash committed Dec 1, 2024
1 parent 73721d3 commit 7500b24
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions assets/js/bluerain.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ for (let i = 0; i < columns; i++) {
skeetsIndex[i] = 0;
}

const sanitizeForEmojis = (string) => [...new Intl.Segmenter().segment(string)].map(x => x.segment)

function loop() {
if (pauseAnimation) return;

Expand All @@ -56,7 +58,7 @@ function loop() {

for (let i = 0; i < drops.length; i++) {
if (i < skeets.length) {
const characters = Array.from(skeets[i]); // used to fix emoji encoding
const characters = sanitizeForEmojis(skeets[i]);
const text = characters[skeetsIndex[i]];
let oldText = '';

Expand Down Expand Up @@ -165,4 +167,4 @@ F - change rain font
`

console.log(helpText, "font-size: small")
console.log('%chttps://github.com/syxanash/bluerain', "font-size: medium");
console.log("%chttps://github.com/syxanash/bluerain", "font-size: medium");

0 comments on commit 7500b24

Please sign in to comment.