コード例 #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);
            }
        }
コード例 #2
0
        public static void DrawTriangle(FoxDraw foxDraw, double origox, double origoy, double size, double count)
        {
            if (size > 0)
            {
                if (count < 10)
                {
                    foxDraw.StrokeColor(Colors.Black);
                    foxDraw.FillColor(Colors.White);

                    var points = new List <Point>();
                    points.Add(new Point(origox, origoy));
                    points.Add(new Point(origox + size, origoy));
                    points.Add(new Point(origox + (size / 2), origoy + (Math.Sqrt(3) / 2 * size)));

                    foxDraw.DrawPolygon(points);
                    count++;

                    DrawTriangle(foxDraw, origox, origoy, (size / 2), count);
                    DrawTriangle(foxDraw, origox + (size / 2), origoy, (size / 2), count);
                    DrawTriangle(foxDraw, origox + (size / 4), (origoy + (Math.Sqrt(3) / 2 * size) / 2), (size / 2), count);
                }
                else
                {
                    return;
                }
            }
            else
            {
                return;
            }
        }
コード例 #3
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            foxDraw.FillColor(Colors.Transparent);

            Triangles(foxDraw, 0, 0, canvas.Width, 7);
        }
コード例 #4
0
        static void DrawTriangles(FoxDraw foxDraw, int sideLength, int baseLineY, int resolution)
        {
            Point a = new Point(50, baseLineY);
            Point b = new Point(50 + sideLength, baseLineY);
            Point c = new Point(50 + sideLength / 2, baseLineY - sideLength * 0.866);

            var points = new List <Point>()
            {
                a, b, c
            };

            foxDraw.FillColor(Colors.White);
            foxDraw.DrawPolygon(points);
            double x1 = a.X;
            double y1 = a.Y;
            double x2 = a.X;
            double y2 = a.Y;

            for (int i = 1; i < resolution; i++)
            {
                x1 = (i * a.X + (resolution - i) * c.X) / resolution;
                y1 = (i * a.Y + (resolution - i) * c.Y) / resolution;
                x2 = (i * a.X + (resolution - i) * b.X) / resolution;
                y2 = (i * a.Y + (resolution - i) * b.Y) / resolution;
                foxDraw.DrawLine(x1, y1, x2, y2);
            }

            x1 = c.X;
            y1 = c.Y;
            x2 = c.X;
            y2 = c.Y;

            for (int i = 1; i < resolution; i++)
            {
                x1 = (i * c.X + (resolution - i) * a.X) / resolution;
                y1 = (i * c.Y + (resolution - i) * a.Y) / resolution;
                x2 = (i * c.X + (resolution - i) * b.X) / resolution;
                y2 = (i * c.Y + (resolution - i) * b.Y) / resolution;
                foxDraw.DrawLine(x1, y1, x2, y2);
            }

            x1 = b.X;
            y1 = b.Y;
            x2 = b.X;
            y2 = b.Y;

            for (int i = 1; i < resolution; i++)
            {
                x1 = (i * b.X + (resolution - i) * a.X) / resolution;
                y1 = (i * b.Y + (resolution - i) * a.Y) / resolution;
                x2 = (i * b.X + (resolution - i) * c.X) / resolution;
                y2 = (i * b.Y + (resolution - i) * c.Y) / resolution;
                foxDraw.DrawLine(x1, y1, x2, y2);
            }
        }
コード例 #5
0
        public static void DrawGreenPolygon2(FoxDraw foxDraw, double x, double y, double triangleSide, double triangleheight)
        {
            var points = new List <Point>();

            points.Add(new Point(x, y));
            points.Add(new Point(x + triangleSide / 2, y + triangleheight));
            points.Add(new Point(x - triangleSide, y));


            foxDraw.FillColor(Colors.Gray);
            foxDraw.DrawPolygon(points);
        }
コード例 #6
0
        public static void DrawGreenPolygon(FoxDraw foxDraw, double z, double a, double triangleSide, double triangleheight)
        {
            var points = new List <Point>();

            points.Add(new Point(z, a));
            points.Add(new Point(z + triangleSide, a));
            points.Add(new Point(z - triangleSide / 2, a + triangleheight));


            foxDraw.FillColor(Colors.Gray);
            foxDraw.DrawPolygon(points);
        }
コード例 #7
0
        private void DrawOneTrianle(Point startPoint, double sizeOfTriangle)
        {
            double halfOfSide       = sizeOfTriangle / 2;
            double heightOfTriangle = Math.Sqrt(Math.Pow(sizeOfTriangle, 2) - Math.Pow(halfOfSide, 2));
            var    points           = new List <Point>();

            points.Add(new Point(startPoint.X, startPoint.Y));
            points.Add(new Point(startPoint.X + halfOfSide, startPoint.Y + heightOfTriangle));
            points.Add(new Point(startPoint.X - halfOfSide, startPoint.Y + heightOfTriangle));
            foxDraw.StrokeColor(Colors.Red);
            foxDraw.FillColor(Colors.Transparent);
            foxDraw.DrawPolygon(points);
        }
コード例 #8
0
        public MainWindow()
        {
            InitializeComponent();
            FoxDraw foxDraw = new FoxDraw(canvas);

            foxDraw.StrokeColor(Colors.Black);
            foxDraw.FillColor(Colors.White);
            float level       = 7;
            float inputWidth  = (float)canvas.Width;
            float inputHeight = (float)canvas.Height;
            float xStart      = 0;
            float xEnd        = 0;

            var pointsOfTriangle = new List <Point>();

            TriangleDrawer(foxDraw, level, inputWidth, inputHeight, xStart, xEnd);
            Console.ReadLine();
        }
コード例 #9
0
 public void DrawRectangle(FoxDraw foxDraw)
 {
     foxDraw.StrokeColor(Colors.Black);
     foxDraw.FillColor(Colors.Transparent);
     foxDraw.DrawRectangle(0.25 * foxDraw.Canvas.Width, 0.25 * foxDraw.Canvas.Height, 0.25 * foxDraw.Canvas.Width, 0.25 * foxDraw.Canvas.Height, 15);
 }