tilemap-studio
tilemap-studio copied to clipboard
Improve or replace the palette generation algorithm
Given this input image:
(Or this equivalent one which I find easier to look at):
It could be done with just two palettes:
{ 001f, 03f0, 7fe0, 7c10, }
{ 02ff, 23e0, 7d00, 5c1f, }
But Tilemap Studio (and superfamiconv) do it in six:
84ff00 ffbd00 00ff42 ff0000
ffbd00 00ffff ff0000 0042ff
ffbd00 ff00bd ff0000 8400ff
84ff00 00ffff 00ff42 0042ff
84ff00 00ff42 ff00bd 8400ff
00ffff ff00bd 8400ff 0042ff
(Extending the input to one which could fit in 8 palettes but for which we fail to do so is left as an exercise for the reader.)
@ISSOtm found this example in https://github.com/gbdev/rgbds/issues/1451. We may want to use the Overload-and-Remove algorithm from rgbgfx.
(Extending the input to one which could fit in 8 palettes but for which we fail to do so is left as an exercise for the reader.)
Here you go chief:
Correct answer:
{ 03f0, 7fe0, 001f, 7c10, }
{ 02cb, 5ac0, 0016, 580b, }
{ 02ff, 23e0, 5c1f, 7d00, }
{ 0216, 16c0, 4016, 58a0, }
SuperFamiconv (requires -P 12 or higher):
[["#b50000","#ffbd00","#5ab500","#00ff42"],
["#ff0000","#b58400","#00b529","#00ffff"],
["#b50000","#ffbd00","#00b5b5","#0042ff"],
["#ff0000","#b58400","#0029b5","#8400ff"],
["#b50000","#ffbd00","#5a00b5","#ff00bd"],
["#ff0000","#b58400","#84ff00","#b50084"],
["#5ab500","#00ff42","#00b5b5","#0042ff"],
["#84ff00","#00b529","#0029b5","#8400ff"],
["#5ab500","#00ff42","#5a00b5","#ff00bd"],
["#00b529","#00ffff","#8400ff","#b50084"],
["#5a00b5","#00b5b5","#0042ff","#ff00bd"],
["#84ff00","#00ffff","#0029b5","#b50084"]]
Also refer to https://git.sr.ht/~issotm/pagination-rs/tree/master/item/src/lib.rs.