Error drawing lines with round caps when color set to XOR

xor-round-cap-line

As you can see, the circles drawn for the caps of the line are on full display when color is set to XOR. I wonder if rounded rects have the same issue…

xor-round-rect

Round rects draw fine, though the caps looks a bit different though the width is the same. Can’t seem to get full circle on top or bottom? Width of rect is an odd number (17px) so I can center against each vertical line.

1 XOR 1 == 0

Assuming that you’re drawing the 2 circles and the rectangle in XOR mode then I’d expect the part of the circles overlapping the rectangle to display like cut-outs on the rectangle exactly as you’re seeing.

If you drew the circles and rectangle in OR mode that wouldn’t happen; but I’m guessing you’re using XOR so that the dots show up in -ve as they intersect the vertical bar?

Seems like the rounded rect is your best bet - unless maybe you could draw the bar into a sprite with OR then draw that sprite to the screen with XOR.

I think Dustin is using playdate.graphics.setLineCapStyle() when drawing the line. So this is the SDK that internally draw the lines and circles in two steps which result in the issue.

2 Likes

ah. I get you. I’m still not sure that there’s any way to fix this issue for XOR without fundamentally changing the way that lines with rounded ends are drawn internally to that API function though :slight_smile:

Yeah, I wonder if they could switch to drawing the caps with arcs. Makes drawing lines with round caps perhaps more CPU intensive I suppose. Perhaps use slow path when color is set to XOR? I just wanted to note the bug. Clearly what is rendered is not expected. :slight_smile:

1 Like