Exemplo n.º 1
0
        static void DrawTriangle(FoxDraw foxDraw, double startx, double starty, double endx, double endy, int count)
        {
            foxDraw.StrokeColor(Colors.Black);
            foxDraw.FillColor(Colors.White);
            foxDraw.BackgroundColor(Colors.Gray);

            //var points = new List<Point>();
            //points.Add(new Point(startx, starty));
            //points.Add(new Point(endx, starty));
            //points.Add(new Point(startx + (endx - startx) / 2, endy));
            //foxDraw.DrawPolygon(points);

            //var points2 = new List<Point>();
            //points2.Add(new Point(startx + (endx - startx) / 2, starty));
            //points2.Add(new Point(startx + (endx - startx) / 4, starty + (endy - starty) / 2));
            //points2.Add(new Point(startx + (endx - startx) * 3 / 4, starty + (endy - starty) / 2));
            foxDraw.DrawPolygon(points);

            count--;
            if (count > 0)
            {
                DrawTriangle(foxDraw, startx + (endx - startx) / 2, starty, endx, starty + (endy - starty) / 2, count);
                DrawTriangle(foxDraw, startx, starty, startx + (endx - startx) / 2, starty + (endy - starty) / 2, count);
                DrawTriangle(foxDraw, startx + (endx - startx) / 4, starty + (endy - starty) / 2, startx + (endx - startx) * 3 / 4, endy, count);
            }
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            foxDraw.BackgroundColor(Colors.Gold);
            int    level  = 5;
            int    size   = 600;
            Random random = new Random();

            DrawTriangles(foxDraw, size, 0, 0, level, RandomColor(random), random);
            //  DrawTriangles.DrawLine(foxDraw, size, 0, size / 2, size);
            //  DrawTriangles.DrawLine(foxDraw, size / 2, size, 0, 0);
        }