Exemple #1
0
        public static void test_chamfer()
        {
            //Polygon2d poly = Polygon2d.MakeRectangle(Vector2d.Zero, 200, 200);
            //if (poly.IsClockwise)
            //    poly.Reverse();

            Polygon2d poly       = Polygon2d.MakeCircle(100, 64);
            double    max_offset = 50;

            for (int k = 0; k < poly.VertexCount; k++)
            {
                double t      = (double)k / (double)poly.VertexCount;
                double offset = (k % 2 == 0) ? -t * max_offset : t * max_offset;
                poly[k] = poly[k] + offset * poly[k].Normalized;
            }

            poly.Chamfer(60, 30, 30);

            SVGWriter writer = new SVGWriter();

            writer.AddPolygon(poly, SVGWriter.Style.Filled("lime", "black", 0.25f));

            writer.Write(TestUtil.GetTestOutputPath("test.svg"));
        }