‹— back


I woke up with this fantastic thought, that it would be so cool if you could press a 'Share' button on cketch, the thing uploaded yesterday, and instantly tweet out a drawing you've made. Unfortunately previous Twitter card experience made it known that probably isn't possible without hosting the images somewhere and posting a link. But download button was still a fantastic idea. And it has to be a GIF of course! Because, y'know, pixels go blink and stuff.

Converting to GIF locally was quite easy, running before the afternoon had really kicked in (thanks to charlietangora's gif-h, a single file header for pixel arrays to animated GIFs). Getting the web side working was ... a pain. Soooo many failed attempts, mostly revolving around trying to output a base64 string to open a browser window containing the GIF. It didn't go well, but eventually an answer came, and so did the 'create gif' button!

The missing piece was hidden away in Emscripten's virtual filesystem support (-s EXTRA_EXPORTED_RUNTIME_METHODS=FS). This gave the JavaScript access to the virtual FS, which allowed saving the GIF as normal, and then having a function bound to the button on page which calls FS.readFile.

I didn't work much on what I was supposed to work on today (some pathfinding working though: will post tomorrow!), but this was a nice thing to have, and to have stashed away for the future.