3.2.2 antialias option

I was just trying out the new antialiased primitive drawing in the 3.2.2 SDK (thanks to Garmin for adding this!) - but noticing there are a few limitations Slight smile

The main problem being that pixel positions seem to have to be integers still - please correct me if I've missed something ...

This means that if you try to draw a horizontal/vertical line with pen width set to an even number then the anti aliasing always fills half a pixel on each side (top, bottom, left & right) - a workaround for this particular case is to draw a polygon instead.

But if you try and draw a thin diagonal line using the polygon method, then you get imprecision in the corner positions, so it's not possible to guarantee a regular width to the line as it varies with the angle you draw the diagonal at. This case works better using the line drawing Slight smile

If there's any chance of getting any amount of floating point precision for the pixel positions it would be very useful! (Even half a pixel would fix the line drawing offset ...)

Here's an example image from one of my tests in the simulator to see if I could draw some second markers around the edge of a watchface. Maybe it works differently on real devices though? The outer lines are drawn using line drawing, and the inner lines are drawn using polygons - and they are trying to be 2 pixels wide and 10 pixels long.

  • The sim can be a bit deceptive here, as the pixels are much larger than on a real device.  It's probably best to look at this on an actual device.  When I first tried this, what I did was each time onUpdate() was called, I toggled setAntiAlias() between true and false, and the difference became very obvious. 

  • Unfortunately I don't have a device which supports 3.2.2 ... so I can't see what it actually looks like. I know the real displays do look a bit different, but if the simulator displays the pxels being assigned in the same way, then it doesn't seem as useful as I was hoping (but is still better than no anti aliasing - but not as good as anti aliased fonts).

  • You get an idea of what it's doing in the sim, where you just toggle setAntiAlias() each time onUpdate() is called so in high power, it changes every second. It looks better on a real device as the pixels are much smaller.

    Here's something I threw together with circle, arcs, squares, polygons and in the sim,

    AA=false

    AA=true

    Not sure how well it can be seen here, but it's really clear in the sim itself.

  • Yep big difference between those 2 Slight smile The rings, circles and triangles are hugely improved. The 1 pixel wide lines are slightly better. And the ellipse still looks the same. So for a lot of scenarios it works really well - any thick lines you won't notice errors in width so much.

    But you don't have any 2 pixel wide lines there Slight smile So for fine detail it's more of a problem.

    I did think of one idea for even pixel wide lines - to try drawing 2 x odd width lines side by side, e.g. two 1 pixel wide lines instead of a 2 pixel wide one. Kind of shows some promise as it removes the extra 1/2 pixel on the end of each line, but the integer precision for the line ends can cause a mismatch along the middle:

    I was wondering how well it can work for procedurally drawing text (like truetype etc) - but will have to continue the tests ...