Is it possible? Is it platform specific? Does it rely on the graphics hardware? Why does the antialiasing slider under Preferences > Appearance > Graphics do nothing? I remember seeing some post-plotting solutions years before in MathGroup, but could not find it.
Edit
System is: HP EliteBook 8440p, integrated Intel HD Graphics, running Windows 7, 64bit
Answer
This needs specific support from your graphics card. My own graphics card is very old, and does not support it, so the slider does nothing on my machine.
But the good news is that there are workarounds, and I even made an antialiasing palette (code at the end of the post -- evaluate it, pop out the palette, and if you prefer, save it using Palettes -> Install Palette...
).
This is the core antialiasing function I use:
antialias[g_, n_: 3] :=
ImageResize[Rasterize[g, "Image", ImageResolution -> n 72], Scaled[1/n]]
It simply renders a large image, and it downscales it. The results can be better than with a better graphics card's built-in antialiasing, so it's worth a look even if you have a good graphics card.
Problems with this method:
Fonts can be blurrier than what you'd like
With a high scaling factor, it may expose bugs in your graphics driver, and show some unusual results (I had problems with opacity in more complex graphics)
Tick marks don't scale properly (I think this is a bug), so they are barely visible on the antialiased version.
This is the palette code. Usage: select a 3D graphic and press the button. It'll insert an antialiased image below.
Begin["AA`"];
PaletteNotebook[DynamicModule[
{n = 3},
Column[{
SetterBar[
Dynamic[n], {2 -> "2\[Times]", 3 -> "3\[Times]",
4 -> "4\[Times]", 6 -> "6\[Times]"}, Appearance -> "Palette"],
Tooltip[
Button["Antialias", antialiasSelection[SelectedNotebook[], n],
Appearance -> "Palette"],
"Antialias selected graphics using the chosen scaling factor.\nA single 2D or 3D graphics box must be selected."]
}],
Initialization :> (
antialias[g_, n_Integer: 3] :=
ImageResize[Rasterize[g, "Image", ImageResolution -> n 72],
Scaled[1/n]];
antialiasSelection[doc_, n_] := Module[{selection, result},
selection = NotebookRead[doc];
If[MatchQ[selection, _GraphicsBox | _Graphics3DBox],
result =
ToBoxes@Image[antialias[ToExpression[selection], n],
Magnification -> 1];
SelectionMove[doc, After, Cell];
NotebookWrite[doc, result],
Beep[]
]
]
)
],
TooltipBoxOptions -> {TooltipDelay -> Automatic},
WindowTitle -> "Antialiasing"
]
End[];
Demonstration:
Comments
Post a Comment