You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Congratulations!

    On Espruino the fonts are just stored as polygons, and are rendered with code like this: https://github.com/espruino/Espruino/blob/master/libs/graphics/graphics.c#L394

    Basically you'd want to modify graphicsFillPoly in that same file to antialias the edges. You should be able to google some polygon algorithms, but right now it:

    • 'sketches' out the polygon and finds its minimum and maximum X values for each line
    • fills each scan line in turn

    What you'd need to do is store the minimum and maximum values fractionally (maybe just by multiplying by 16), and then when you went to draw the scan line, you'd draw the points you needed to the beginning and end in the correct colour. In fact you might want to make sure the polygon fill algorithm take arguments of 16x size as well.

    The gotcha is that at the moment Espruino isn't aware of colour at all - it just takes a number and copies it into the next pixel so it doesn't know what R,G and B are. Since you only care about greyscale you could just treat the colour as a number though.

    Having said all that, your display is 72x172 pixels right? It might be easier to just use a 1 bit graphics buffer of twice that size in each direction, and to then scale it down by half - making each 2x2 square into single 2 bit pixel.

    You could do that with JS initially and see what it looks like. You could probably get it relatively quick using some hacky binary arithmetic to work on groups of pixels at once - or you could look at adding some convenience function in C that would take an ArrayBuffer and then squish it down in 2D.

About

Avatar for Gordon @Gordon started