When using VertexColors, the docs state:
The interior of the polygon is colored by interpolating between the colors specified by
VertexColors.
It however doesn't say how this interpolation is carried out. I've seen at times that small quirks show up that I wouldn't expect, and I'm wondering if someone else has a clearer perspective on exactly why and when these show up.
aim = {Cos[2 π #], Sin[2 π #]} &;
angles[n_] := Range[0, 0.5, 0.5/(n - 1)];
colors[n_] := Join[ConstantArray[Purple, n], ConstantArray[Orange, n]];
draw[n_, a_] :=
Graphics[{
Polygon[Join[aim /@ angles[n], a aim@# & /@ Reverse[angles[n]]],
VertexColors -> colors[n]
]}]
Using this definition and n = 5, I don't see anything wrong when a = 0.415, but when a = 0.414, it looks like it's interpolating incorrectly, and when n is set larger, two such quirks appear which seem to always be present. This can be seen in the three calls:
GraphicsColumn[{draw[5, 0.415], draw[5, 0.414], draw[100, 0.415]}]
So the question is, why does this happen and is there a general way to avoid it, or test for when it's expected to happen?
I know that for this particular example I can avoid it simply by splitting my single polygon into many smaller 4 point polygons, I'm not asking for code that just draws a shaded arc. I'm interested in the underlying problem.

Comments
Post a Comment