You are browsing as a guest. Sign up (or log in) to start making projects!

9h 20m 12s logged

⭐ Day 18 of building Starforge, a pixel art & animation studio that lives in your browser.

That heart is only half real. I drew the left side and the editor drew the right side under my pencil, live. Mirror mode landed today, and I spent an embarrassing amount of time just watching the other half appear.

Two more things came with it. The Export dialog now plays your actual GIF before you download it, next to its true size, same bytes as the download, so the dialog can’t lie to you. My greeting star comes out at 2.4 KB, using 125 of 256 colors. And the encoder learned to lose colors gracefully, which is my favorite thing I’ve built this week:

How it works

A GIF holds at most 256 colors. Until today, art with more colors hit a wall, an error message asking you to reduce your palette. I hated that message, so now the encoder runs median cut instead.

Median cut, in human terms: pour every color in your drawing into one box. Find the box’s longest side, red, green or blue, whichever stretches widest, sort the colors along that side, and cut the box in half at the median. Repeat, always cutting the widest box you have left. After 255 cuts you hold 256 boxes, and each box’s average becomes one crayon in the final palette. Colors that sat close together end up sharing a crayon, which is exactly the kind of loss your eye forgives.

The sneaky part is that the same drawing must produce the identical file every single time, so every sort breaks ties by the color’s own value and every average rounds the same way. There’s a test that encodes the same art twice and demands the bytes back, identical.

Receipts

  • 563 green tests
  • ~10,000 colors in, 256 out, in about 23ms
  • ffmpeg decodes the quantized file, and re-encoding what it hands back produces the identical bytes

Last post I asked you to export a GIF and drop it in the comments. Nobody did :C, fair enough, the star was doing all the work.

So today I made it personal: open starforge.lacorte.city, turn on mirror mode, and draw half a thing. The editor does the other half. Post what you get, I’ll feature my favorite in the next devlog :D.

And a real question I can’t decide alone: diagonal axes or kaleidoscope. which should mirror mode learn first? Both are on the backlog. You can decide the order.

(If you want to catch the next post, follow the project, that button actually notifies you. :boykisser: )

0
12

Comments 0

No comments yet. Be the first!