Drawing the panda on a 16-pixel grid
The Endcord panda now follows your mouse in the oneko plugin. It's drawn in plain text, six colours and five frames.
The oneko plugin has always had a cat that chases your mouse, and lately a puppy that follows the cat. Now the Endcord panda tags along at the back, and falls asleep sooner than either of them. Here's how it's made.
A drawing you can read in a code review
There's no image file. Each frame is sixteen lines of sixteen letters, and each letter is a colour. This is the sitting panda as it appears in the source:
Drawing in text sounds awkward, but it has real advantages. A change to one pixel shows up as a one-letter change in a pull request. Nothing has to be exported from a drawing app, and there's no binary file to get out of sync with the code.
Six colours, and no black
ooutline,#0e1220: a navy so dark it reads as black, but it sits in the same family as Endcord's night-blue background instead of fighting it.kblack fur,#262b38: lighter than the outline, so the ears and legs still have an edge against it.wwhite fur,#f3f6fb: the brand's Paper colour, a white with a hint of blue.swhite fur in shade,#c3ccdb: two or three pixels of it give the body some roundness.ethe shine in the eyes, so the sitting panda looks at you instead of through you.zthe sleeping z,#9ccbff: the same ice blue as the letters on the logo, where the panda is also asleep.
From letters to a sharp picture
When the plugin starts, each frame is turned into a tiny SVG: every letter becomes a one-pixel square, and all squares of the same colour join into a single path. The result is a few hundred bytes, drawn with shape-rendering="crispEdges" so the edges stay hard at any size. The plugin shows it at 32 pixels, exactly 2×, so every panda pixel is a clean 2×2 block on screen.
The panda follows whoever is ahead of it: the puppy, or the cat if the puppy is off, or your mouse if both are. It keeps to the side its leader came from, so it trails behind instead of sitting on top of anyone. When it catches up it sits down, and after five quiet seconds it's asleep. Pandas sleep a lot.
The frames are also in the brand kit as SVGs, if you want the panda in your own video or theme.
