mmulet / font-game-engine

Make your own game in a font!
GNU General Public License v3.0
149 stars 3 forks source link

Anti-aliased images are hard to convert #2

Open FreddieRa opened 3 years ago

FreddieRa commented 3 years ago

Anti Aliasing

When exporting pngs of text Pixlr, it anti-alias the edges:

image

This is nice, but when I try and convert it in the online editor, I have 130+ colors to manually reassign:

image

To address this, I have implemented a "Guess" function which will take a threshold (how close two RBG colours should be in LAB space to be considered the same) and then will automatically assign all of the relevant colours:

image

I'm currently working on this in my own fork which is yet to be published, but any insight or suggested features before I open a PR would be appreciated.

Additional notes:

FreddieRa commented 3 years ago

Current changes can be seen here: https://github.com/mmulet/font-game-engine/compare/main...FreddieRa:main

mmulet commented 3 years ago

When I built fontemon, I used blender’s https://docs.blender.org/manual/en/latest/compositing/types/converter/color_ramp.html color ramp node in the composition to preprocess images with many colors.

Screenshot 2021-04-02 170336

FreddieRa commented 3 years ago

Ah okay, that of course works, this just makes the converter more of a one-stop-shop. I am however getting the issue of Unrecognized color 117,117,117,255 despite the fact that no colours show up in the input sidebar.

mmulet commented 3 years ago

Hard to say, but most likely, the currentColors array hasn't been updated correctly. Try running

   this.currentColors = getAllColorsFromAnImage(
      this.image.data,
      true
    ).inputColors;

after making your change

FreddieRa commented 3 years ago

Interesting, thank you, that fixed it. Now however I now get NetworkError when attempting to fetch resource. I'll open a separate issue.