internal void RasterizePolygon(CGContext context, PointF center, PointF[] pathPoints,
Color[] surroundColors, Color centerColor)
{
var last = pathPoints[0];
Color start = Color.Empty;
Color end = Color.Empty;
var count = pathPoints.Length - 1;
var colorCount = surroundColors.Length;
var startIndex = 0;
var endIndex = 1;
// // Create new stopwatch
// var stopwatch = new System.Diagnostics.Stopwatch ();
//
// // Begin timing
// stopwatch.Start();
for (int p = 1; p <= count; p++)
{
var next = pathPoints[p];
if (startIndex >= colorCount)
{
start = surroundColors[colorCount - 1];
end = surroundColors[colorCount - 1];
}
else
{
start = surroundColors[startIndex++];
if (startIndex == colorCount)
{
end = surroundColors[0];
}
else
{
if (endIndex >= colorCount)
{
end = surroundColors[colorCount - 1];
}
else
{
end = surroundColors[endIndex++];
}
}
}
//Console.WriteLine("triangle {0} P1 {1} P2 {2} P3 {3} color {4}", p, last, next, center, start);
if (polygonWinding == FillMode.Winding)
RasterizeTriangle(context, center, last, next, centerColor, start, end);
else
RasterizeTriangle(context, last, center, next, start, centerColor, end);
last = next;
}
// // Stop timing
// stopwatch.Stop();
//
// // Write result
// Console.WriteLine("Time elapsed: {0}",
// stopwatch.Elapsed);
}