- Code: Select all
PointF[] points = new PointF[5];
for (int i = 0; i < points.Length; i++)
{
float x = (float)Math.Cos(i * 2 * Math.PI / 5);
float y = (float)Math.Sin(i * 2 * Math.PI / 5);
points[i] = new PointF(x, y);
}
PdfPath path = new PdfPath();
path.AddLine(points[2], points[0]);
path.AddLine(points[0], points[3]);
path.AddLine(points[3], points[1]);
path.AddLine(points[1], points[4]);
path.AddLine(points[4], points[2]);
which generates this star nicely:
However if I modify the code so that the lines are not drawn in sequence:
- Code: Select all
PointF[] points = new PointF[5];
for (int i = 0; i < points.Length; i++)
{
float x = (float)Math.Cos(i * 2 * Math.PI / 5);
float y = (float)Math.Sin(i * 2 * Math.PI / 5);
points[i] = new PointF(x, y);
}
PdfPath path = new PdfPath();
path.AddLine(points[2], points[0]);
path.AddLine(points[4], points[2]);
path.AddLine(points[0], points[3]);
path.AddLine(points[3], points[1]);
path.AddLine(points[1], points[4]);
I get the following result:
It is as if PDFPath requires the lines to be added in order, and that it draws without picking up the pen. Is this a correct understanding? Is there a way to avoid this so that I can add the lines in any order/not have to sort them? Thanks in advance.