Drawing checkered lnes

I assume the answer to this is a very simple 'no' but thought I'd ask just in case I'm missing something:

Is there anyway to get a checkered pattern when calling a draw function like playdate.graphics.drawLine()?

I know you can use setColor() to make the line white or black or clear, but am hoping to get a checkered line, but ideally without having to figure out sprite rotation, which seems complex and janky.

Thanks for any tips! But again fully expecting the answer to just be 'no'.

I was trying to do something similar - for just vertical or horizontal lines, if you can make do with an 8x8 pattern, graphics.setPattern() can be used to pretty good effect, albeit limited in the length of the 'on' sections due to the pattern size. Also note that the pattern is 'fixed' in screen space, so it's as if you are just 'revealing' a portion of the tiled 8x8 pattern in the region you are drawing your line; the pattern doesn't "start" with wherever your draw call is.

For diagonals, I'll be curious to see if others have answers.

Here's how you can do marching ants. Matt's Prototypes - #3 by matt

There’s also the GFXP library, where you could set a checkerboard pattern with gfxp.set(“gray”)

Depending what you mean by "checkered" on a line, how thick the lines are, and what directions they go, a pattern of diagonal stripes can work well: it looks the same on both H and V lines. Diagonals will vary wildly though.

playdate.graphics.setDitherPattern has that ready to go: just try .5 alpha with kDitherTypeDiagonalLine.

1 Like

I'm wondering if you can change the draw offset to move the start position of the pattern?

Thanks so much everyone! All of this was super useful! Wish I could set every response as 'Solution'!

I ended up using that amazing GFXP tool to get a patter and then used setDitherPattern() right before drawLine() and it worked a treat.

Thanks again!

3 Likes