# Anti-aliasing with the multiple-object form of Polygon?

Observe:

rand = RandomReal[1, {4, 3, 2}];

Graphics @ Polygon @ rand


Graphics[Polygon /@ rand]


I am losing anti-aliasing when I use the multiple-polygon syntax form of Polygon. Yet it is possible for Mathematica to apply AA as can be shown with:

Style[
Graphics @ Polygon @ rand,
Antialiasing -> True
]


(Incidentally this Style-applied AA does not copy with Szabolcs's Image Uploader but the in-Notebook appearance is identical to the second output above.)

• Why am I losing anti-aliasing here?

• Is there a system option to turn it on, and with what caveat?

-
It seems with antialiasing on, you get seams between adjacent polygons. It's in the end of possible issues in the Polygon docs. So probably it assumes that by default, with the multiple-polygon syntax form it's more important to avoid seams for adjacent polygons and with the several distinct polygons antialiasing is more important. Just an idea –  Rojo Jun 24 '12 at 19:51
Also, setting the Antialiasing->True globally instead of Automatic, fixes this, but I have no idea what other sideeffects it has –  Rojo Jun 24 '12 at 20:09
Maybe one could add the "undocumented" tag. –  Jens Jun 24 '12 at 20:39
@Rojo Antialiased polygons don't join properly and will create artefacts in e.g. a ListDensityPlot, try ListDensityPlot[RandomReal[1, {20,3}]]. –  Szabolcs Jun 24 '12 at 20:41
@Rojo why don't you post that as an answer. I'd like to get an answer up relating to that, and it would be better if you were the one to post it. –  Mr.Wizard Jun 24 '12 at 20:51

It seems with antialiasing on, you get seams between adjacent polygons. It's at the end of the possible issues section in the Polygon documentation page.

So probably it assumes that by default, with the all-in-one-polygon syntax form (one Polygon head for multiple polygon representations) it's more important to avoid seams for adjacent polygons, and with the multiple-Polygon-syntax, antialiasing is more important.

Functions such as ContourPlot or ListDensityPlot, that use Polygon to render it's results, use this all-in-one syntax to save space, and require the polygons to join well, so by default antialiasing is off. See Antialiasing option behaves weird (polygon edges visible in ContourPlot) for an example of what can happen with anti-aliasing. You could always set the option Antialiasing to True instead of Automatic, either at global or notebook or cell level, but you will suffer the consequences when using one of these functions.

-

Antialiasing can be used as a directive inside Graphics:

Table[Graphics[{Antialiasing -> aa, Polygon[rand]}], {aa, {True, False}}]


-
That's a very unusual syntax! –  Szabolcs Jun 24 '12 at 20:26
I didn't know this (+1) but it still requires an additional step, and it still doesn't explain what I'm seeing. Any further comment? –  Mr.Wizard Jun 24 '12 at 20:30
It's good to know (+1), but @Mr.Wizard's Style syntax allows the same thing and seems more consistent. –  Jens Jun 24 '12 at 20:37
Only that globally forcing Antialiasing -> True would have negative consequences for some scenarios (possibly depending on platform.) –  Brett Champion Jun 24 '12 at 20:37
The difference is due to the behavior of Antialiasing->Automatic (see the documentation for Antialiasing). The behavior of Automatic is not defined (and could change). The current behavior is effectively True for a single polygon and False for a multi-polygon (even it if only has one item). –  ragfield Jun 24 '12 at 22:26