3 ms·
I wrote an html5/canvas chalkboard the weekend before that lets you replay your drawings and get a link to send them to other people. I don't want to link it he
by yoav 15y ago
I wrote an html5/canvas chalkboard the weekend before that lets you replay your drawings and get a link to send them to other people. I don't want to link it here because it'll crash my server if a (hacker news) of people start saving drawings.. anyway it stores the path data as JSON on the server as a text blob to optimize database queries... otherwise it would have to fetch thousands of rows just to get a single drawing. I wanted to reduce storage, but also bandwidth; specifically for uploads which can take a while(a short drawing produced around 1MB of JSON), I also thought it would be cool to add the drawing data directly in the url or send it to someone in an email —hence using a modifiable alphabet for the hashes, or allow unrestricted drawing and save it to html5 localstorage.
I figured I might as well put the ideas I had into code and on github so others could help refine it, and if it turned out not to work that well was planning on attempting to implement gzip in javascript.
Incidentally in my unreliable data specific benchmarks using my algorithm + gzip resulted in smaller files than just gzip, but I'm not going to make that claim without more benchmarks. Hard to say if you can exploit http gzip compression and store the gzipped data on the server, whether the extra time using my algorithm as a pre-compressor would be worth any byte reduction achieved for that use case.
Also the current implementation is focused on compressing ascii characters into fewer ascii characters, it should be possible to implement a version that compresses bits into smaller bits and achieves better compression for use cases where you can compress to binary and ascii isn't a requirement.