I’m trying to build a very simple animation application, using Electron. I think it will be a nice exercise in software planning/organization, and it’s really just an excuse to build with languages I’m learning.

Eventually, there is an animation which is going to be stored and that calls for a format. In animation, large chunks of a frame are going to remain unchanged: and can simply be reproduced from the previous frame when decoding.

Region quadtrees are a very simple way to help with this.

The idea I have right now is to process things like diff, in that I would be looking at pixels which flip between consecutive frames. I am thinking of using a region quadtree to compress these diffs.

The idea here is a divide-and-conquer approach. First, check whether all the pixels in the region can be approximated by their mean. If so, our work is done. Otherwise, divide the image into subregions (I used four quadrants) and continue recursively.

Tiger walking from the pool — Humphrey Muleba

Approximate regions with a single color

Finer block size:

Here’s the code: Link

Thanks for reading!

**UPDATE: ** Drawing things with a trackpad is not fun, will probably get back to this soon (tm).