コード例 #1
0
        private void DrawTriangels(FoxDraw foxDraw, int widthOfTriangles)
        {
            double startingPointX  = 0 - widthOfTriangles;
            double startingPointY  = canvas.Height;
            double heightOfTriagle = widthOfTriangles * Math.Sqrt(3) / 2;

            foxDraw.FillColor(Colors.White);
            foxDraw.BackgroundColor(Colors.White);
            int counter = (int)canvas.Width / widthOfTriangles;

            for (int j = 0; j < (int)canvas.Width / widthOfTriangles; j++)
            {
                for (int i = 0; i < counter; i++)
                {
                    var points = new List <Point>();
                    points.Add(new Point(startingPointX += widthOfTriangles, startingPointY));
                    points.Add(new Point(startingPointX + widthOfTriangles, startingPointY));
                    points.Add(new Point(startingPointX + widthOfTriangles / 2, startingPointY - heightOfTriagle));
                    foxDraw.StrokeColor(Colors.Black);
                    foxDraw.DrawPolygon(points);
                }
                counter--;
                startingPointX  = j * widthOfTriangles / 2 - widthOfTriangles / 2;
                startingPointY -= heightOfTriagle;
            }
        }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            Random r = new Random();

            foxDraw.BackgroundColor(Colors.GhostWhite);
            int edge            = 50;
            int numOfRectangles = 4;

            for (int i = 0; i < numOfRectangles; i++)
            {
                int x_coordinates = r.Next(edge, (int)canvas.Width - edge);
                int y_coordinates = r.Next(edge, (int)canvas.Height - edge);
                int recWidth      = r.Next(20, 50);
                int recHeight     = r.Next(20, 50);

                Color randomColor = Color.FromRgb((byte)r.Next(255), (byte)r.Next(255), (byte)r.Next(255));
                foxDraw.FillColor(randomColor);
                foxDraw.DrawRectangle(x_coordinates, y_coordinates, recWidth, recHeight);
            }


            // draw four different size and color rectangles.
            // avoid code duplication.
        }
コード例 #3
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            foxDraw.BackgroundColor(Colors.White);
            int squareSize = 20;

            DrawCheckBoard(foxDraw, squareSize);
        }
コード例 #4
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            foxDraw.BackgroundColor(Colors.White);
            int xStartingPoint = 0;
            int yStartingPoint = 0;

            DrawLinesToTheCenter(foxDraw, xStartingPoint, yStartingPoint);
        }
コード例 #5
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            foxDraw.BackgroundColor(Colors.White);
            int gridLength = 20;

            DrawTheGreenLines(foxDraw, gridLength);
            DrawThePurpleLines(foxDraw, gridLength);
        }
コード例 #6
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            foxDraw.BackgroundColor(Colors.White);

            int gridLength = 20;

            DrawTheEnvelopeStar(foxDraw, gridLength);
        }
コード例 #7
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            foxDraw.BackgroundColor(Colors.White);
            int squareSize = 300;

            for (int i = 0; i < 3; i++)
            {
                squareSize -= 50;
                DrawSquares(foxDraw, squareSize);
            }
        }
コード例 #8
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            foxDraw.FillColor(Colors.Yellow);
            foxDraw.BackgroundColor(Colors.Yellow);
            foxDraw.StrokeColor(Colors.Black);
            double x        = 0;
            double y        = 0;
            double baseSide = canvas.Width;

            DrawSquare(foxDraw, x, y, baseSide);
        }
コード例 #9
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            foxDraw.BackgroundColor(Colors.GhostWhite);

            int x = 10;
            int y = 10;

            foxDraw.DrawRectangle(canvas.Width / 2 - x / 2, canvas.Height / 2 - y / 2, x, y);


            // Draw a green 10x10 square to the canvas' center.
        }
コード例 #10
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            foxDraw.BackgroundColor(Colors.Beige);

            foxDraw.StrokeColor(Colors.Red);
            foxDraw.DrawLine(0, 100, canvas.Width / 2, 100);

            foxDraw.StrokeColor(Colors.Green);
            foxDraw.DrawLine(100, 0, 100, canvas.Height / 2);

            // draw a red horizontal line to the canvas' middle.
            // draw a green vertical line to the canvas' middle.
        }
コード例 #11
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            foxDraw.BackgroundColor(Colors.GhostWhite);

            int x = 100;
            int y = 100;

            Drawing(foxDraw, x, y);

            // Create a line drawing function that takes 2 parameters:
            // The x and y coordinates of the line's starting point
            // and draws a 50 long horizontal line from that point.
            // Draw 3 lines with that function. Use loop for that.
        }
コード例 #12
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            foxDraw.BackgroundColor(Colors.GhostWhite);

            foxDraw.StrokeColor(Colors.Green);
            foxDraw.DrawLine(0, 0, canvas.Width, canvas.Height);

            foxDraw.StrokeColor(Colors.Red);
            foxDraw.DrawLine(0, canvas.Height, canvas.Width, 0);


            // Draw the canvas' diagonals.
            // If it starts from the upper-left corner it should be green, otherwise it should be red.
        }
コード例 #13
0
        public void DrawStars(FoxDraw foxDraw, int numberOfStars)
        {
            Random r = new Random();

            foxDraw.BackgroundColor(Colors.Black);

            int edge = 1;

            for (int i = 0; i < numberOfStars; i++)
            {
                int  randomSize = r.Next(1, 10);
                byte grayColor  = (byte)r.Next(255);

                Color randomColor = Color.FromRgb(grayColor, grayColor, grayColor);
                foxDraw.FillColor(randomColor);
                foxDraw.StrokeColor(randomColor);
                foxDraw.DrawEllipse(r.Next(edge, (int)canvas.Width - edge), r.Next(edge, (int)canvas.Height - edge), randomSize, randomSize);
            }
        }
コード例 #14
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            foxDraw.BackgroundColor(Colors.GhostWhite);
            foxDraw.StrokeColor(Colors.Red);
            foxDraw.DrawLine(100, 100, 200, 100);

            foxDraw.StrokeColor(Colors.Green);
            foxDraw.DrawLine(200, 100, 200, 200);

            foxDraw.StrokeColor(Colors.Yellow);
            foxDraw.DrawLine(200, 200, 100, 200);

            foxDraw.StrokeColor(Colors.Blue);
            foxDraw.DrawLine(100, 200, 100, 100);

            // Draw a box that has different colored lines on each edge.
        }
コード例 #15
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            foxDraw.BackgroundColor(Colors.GhostWhite);

            int x = 0;
            int y = 100;

            for (int i = 0; i < 3; i++)
            {
                Drawing(foxDraw, x, y);
                x *= 2;
                y *= 2;
            }


            // Create a line drawing function that takes 2 parameters:
            // The x and y coordinates of the line's starting point
            // and draws a line from that point to the center of the canvas.
            // Draw 3 lines with that function. Use loop for that.
        }