Some dither types ignore alpha value in SDK 1.7.0

In the SDK release 1.7.0 the dither patterns

  • playdate.graphics.image.kDitherTypeFloydSteinberg
  • playdate.graphics.image.kDitherTypeBurkes
  • playdate.graphics.image.kDitherTypeAtkinson

produce the same results independent of the alpha value. The other dither types appear to be fine.

The following update function should produce a black screen but the result is striped.

function playdate.update()
	playdate.graphics.setDitherPattern(0, gfx.image.kDitherTypeFloydSteinberg)
	playdate.graphics.fillRect(0, 0, 400, 240)
end

image

1 Like

ohh, I see what happened. I refactored the code and didn't include the error-diffusing dithers in that function because I didn't think it made sense.For diagonal lines you can do gfx.setDitherPattern(0.5, gfx.image.kDitherTypeDiagonalLine) instead. (And alpha=0.25 or 0.75 give different weights of stripes.) With error-diffusing the results are very unpredictable.

My preference would be to leave the behavior like this, make a note in the docs, and maybe add a runtime warning if you call setDitherPattern with an error-diffusing dither type. But you can try and talk me out of it! :slight_smile:

Thanks for the heads up and yes, a runtime warning would be nice as it’ll make it easier to find the issue for people who have been using it.

My only argument to keep the feature would be that it’s nice for quick prototyping which is how I ended up using it. It’s no problem to replace it with pregenerated assets now that I know what I want but it was nice to get a quick start.