Recommendations for Dithering in C

Context: I've ported my WebGL matrix effect to a Lua Playdate project, and am attempting a C project to see how their performance compares on-device. I'm developing on a Mac.

My Lua project imports a spritesheet of glyphs into an image table, and then creates a cache of opaque faded variants of each glyph on initialization via blendWithImage, to make a lookup table for drawing glyphs at different brightnesses in the update loop:

matrix_lua

I can think of several strategies for implementing this in C, but I don't know what's possible, or what's best:

  • Is it possible to invoke blendWithImage through the C API? I don't think so?
  • Could I invoke the Lua API's playdate.graphics.image.blendWithImage function from C somehow?
  • I could keep creating the images in Lua but maybe pass the images into the C somehow
  • I could implement my own dithering in C

What should I be doing here?

Can you create a dithered/faded/graduated black mask in a paint app and draw that over your columns of text?

That way you don't need to do any dithering or fading at all.

1 Like

This seems to work really well in the Lua version, and now I'm not depending on any API calls that are Lua-specific. Full speed ahead!

1 Like