Anybody know of a way to per-pixel render marching ants that it looks okay on lines of any given angle?
Probably you need to be a bit more specific. For example, if I was doing this with Cairo, I would simply use
cairo_set_dash , then disable antialiasing and render the lines in question. I'd move the ants by cycling the offset parameter. If I needed proper two-color marching, I'd probably draw the line twice, the first with a solid color and the second dashed with the second color.
For the most general/lowlevel case, you should be able to just use bresenham's algorithm and a dash array (eg [0,0, 1, 1] for 2px-long dashes); each new pixel you visit, you take dasharray[curoffset] as the color to plot, then set offset = (offset + 1) modulus 4. The same method of 'walking' the ants as in my Cairo example applies. Pretty simple, the only thing to keep in mind is that you only count whole pixels for purposes of plotting dashes (ie. you treat a 1px 45-degree move as the same distance as a 1px 90-degree move)
This is the algorithm I am currently using (manually) when drawing icons.
Here's what it looks like applied to the mask icon I drew recently:

If displayed on a high resolution screen, longer dashes than this appear to be appropriate, for better visibility.. maybe as long as 8. Of course, on smaller contours, you need to use a smaller dash size to make it read well, so there is probably some compromise involved there -- 4 might work for most situations.
BTW, while I was making this animation I discovered that GIMP 2.9 has an improved Animation Playback plugin: notably, it allows you to zoom the animation 51% -> 300% size, override the layer application mode (combine vs replace), and refresh with any changes you've made in the meantime.
« Last Edit: April 06, 2015, 02:55:42 am by Ai »

Logged
If you insist on being pessimistic about your own abilities, consider also being pessimistic about the accuracy of that pessimistic judgement.