Endcord Labs · Design

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.

Sitting
Run, frame 1
Run, frame 2
Asleep
Four of the five frames, each 16 by 16 pixels, shown here at 6×.

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:

................ ...kkk....kkk... ...kooooooook... ...owwwwwwwwo... ..owwkkwwkkwwo.. ..owkekwwkekwo.. ..owkkwoowkkwo.. ...owwwwwwwwo... ...okkwwwwkko... ..okkkwwwwkkko.. ..okkwwwwwwkko.. ..owswwwwwwswo.. ..okkkwwwwkkko.. ..okkkooookkko.. ...ooo....ooo... ................

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

  • o outline, #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.
  • k black fur, #262b38: lighter than the outline, so the ears and legs still have an edge against it.
  • w white fur, #f3f6fb: the brand's Paper colour, a white with a hint of blue.
  • s white fur in shade, #c3ccdb: two or three pixels of it give the body some roundness.
  • e the shine in the eyes, so the sitting panda looks at you instead of through you.
  • z the 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.

More from Endcord LabsTalk about it on Discord