docs-desktop icon indicating copy to clipboard operation
docs-desktop copied to clipboard

Correction to BuildRegularPolygon

Open DrTomF opened this issue 3 years ago • 1 comments

Thanks for giving the BuildRegularPolygon code but to work correctly you should change the using block as follows:

 using (StreamGeometryContext ctx = geometry.Open())
        {

            double step = 2 * Math.PI / Math.Max(numSides, 3);
            Point cur = c;

            double a = Math.PI * offsetDegree / 180.0;
            for (int i = 0; i < numSides; i++, a += step)
            {
                cur.X = c.X + r * Math.Cos(a);
                cur.Y = c.Y + r * Math.Sin(a);
                if (i == 0)
                {
                    ctx.BeginFigure(cur, true /* is filled */, true /* is closed */);
                }
                else
                {
                    ctx.LineTo(cur, true /* is stroked */, false /* is smooth join */);
                }
            }
        }

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

DrTomF avatar Apr 19 '22 02:04 DrTomF

Thank you for opening this issue. I'll add it to the backlog. If you would like to contribute, you can submit a fix by editing the original article. Click on the Content Source link at the bottom of your original comment. To learn how to edit, see the Editing files in a repository article from GitHub.

Thanks again!

adegeo avatar Apr 24 '22 18:04 adegeo