Emojis on Cosmic Unicorn

Love these new Galactic and Cosmic unicorns. Thank you for creating these Pimoroni team!

I have been working on an app to send pictures to one or multiple Cosmic unicorns. It can be used to send any picture to the unicorn but this first implementation is focused on sending emojis as a 32x32 picture.

Converting emoji to pixels by writing the 32x32 emoji font to html canvas, then to scrape the pixel information back off the html canvas. Then send the byte array over to the unicorn. This is a bit hacky. On tablet and mobile, sometimes it’s a couple pixels off, and will require some tweaks to get this fixed. If anyone has suggestion of a better way to do this, please let me know.

Used the cosmic_paint app as a starting point, and built a custom UI on top of cosmic_paint.py, sending pixels one by one over websocket. This was ending up being very slow to update, and the unicorn would crash from out of memory errors quite frequently.

Second version, updated cosmic_paint.py that instead of sending pixel by pixel, to allow sending the full byte array over websocket. This updated the unicorn much faster than pixel by pixel, but still crashed a lot.

Third version, removed websocket, and using basic POST to send the byte array. Added a GET method to pull the byte array off the unicorn, to be able to determine “what image is being displayed on this unicorn right now?”

Working on cleaning up the code to share.


User interface works on desktop, tablet, or mobile. Here is a preview of that.

1 Like

This looks ace, would love to see the code when you’re done :)

First release GitHub - chriscareycode/cosmic-paint-react: Paint emojis on your Pimoroni Cosmic Unicorn


Great fun, thanks for sharing! :)

I seem to be getting a bit of a offset on mine - I wonder if Windows and Android are sending differently sized emojis?

From Windows:

From Android:

1 Like

Thanks for reporting that Hel. I had not tested on Windows and Android yet, and did get repro of this issue on my Kindle Fire tablet. Was able to find a new technique that fixes this for all OS types. Also adding brightness control and the ability to paint Apple, Android, Facebook, and Twitter style emojis from any OS. Will let you know when that ships

1 Like

Updated version with more emojis, brightness controls, and should fix the issue where Android and Windows devices would write the emoji off-center on the Cosmic Unicorn Releases · chriscareycode/cosmic-paint-react · GitHub

Working beautifully now, thanks - having fun in the office with this :D

Am I OK to link to your project from our Github?

Awesome. Thanks for confirming the fix is working. I’m thinking to rename the project over to “cosmic-emoji” on github before you add link. Will shuffle things around this weekend. 🥰 🙏

1 Like

Moved the project over here to make room for subprojects underneath the main repo.
This project is moved into a subfolder cosmic-emoji-react in that repo.

Yes you can link this from your GitHub 😀

1 Like