Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            var topLeftToBottomRight = new FoxDraw(canvas);

            var bottomLeftToTopRight = new FoxDraw(canvas);

            double toolBarHeight = 40; //These are the offsets on my system
            double sideOffSet    = 20; //These are the offsets on my system

            // Draw the canvas' diagonals.
            // If it starts from the upper-left corner it should be green, otherwise it should be red.

            var topLeft  = new Point(0, 0);
            var topRight = new Point(Width - sideOffSet, 0);

            var bottomLeft  = new Point(0, Height - toolBarHeight);
            var bottomRight = new Point(Width - sideOffSet, Height - toolBarHeight);

            topLeftToBottomRight.StrokeColor(Colors.Green);
            bottomLeftToTopRight.StrokeColor(Colors.Red);

            topLeftToBottomRight.DrawLine(topLeft, bottomRight);
            bottomLeftToTopRight.DrawLine(bottomLeft, topRight);
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);
            // Reproduce this:
            // [https://github.com/greenfox-academy/teaching-materials/blob/master/workshop/drawing/purple-steps/r3.png]

            var startLocation = new Point(50, 50);

            purpleStepGenerator(6, 10, startLocation);

            void purpleStepGenerator(double repetitions, double size, Point start)
            {
                double x = start.X;
                double y = start.Y;

                foxDraw.StrokeColor(Colors.Black);
                foxDraw.FillColor(Colors.Purple);

                for (int i = 0; i < repetitions; i++)
                {
                    foxDraw.DrawRectangle(x, y, size, size);

                    x += size;
                    y += size;

                    size *= 1.5;
                }
            }
        }
Exemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();

            // Draw a box that has different colored lines on each edge.

            FoxDraw topLine    = new FoxDraw(myCanvas);
            FoxDraw bottomLine = new FoxDraw(myCanvas);

            FoxDraw leftLine  = new FoxDraw(myCanvas);
            FoxDraw rightLine = new FoxDraw(myCanvas);

            double margin = 100;

            Point topLeft     = new Point(margin, margin);
            Point topRight    = new Point(Width - margin, margin);
            Point bottomLeft  = new Point(margin, Height - margin);
            Point bottomRight = new Point(Width - margin, Height - margin);

            //top
            topLine.StrokeColor(Colors.Red);
            topLine.DrawLine(topLeft, topRight);

            //bottom
            bottomLine.StrokeColor(Colors.Green);
            bottomLine.DrawLine(bottomLeft, bottomRight);

            //left
            leftLine.StrokeColor(Colors.Blue);
            leftLine.DrawLine(topLeft, bottomLeft);

            //right
            rightLine.StrokeColor(Colors.Yellow);
            rightLine.DrawLine(topRight, bottomRight);
        }
Exemplo n.º 4
0
 public static void DrawHorizontalLineFrom(double x, double y, double length, FoxDraw foxDraw)
 {
     foxDraw.StrokeColor(Colors.Red);
     for (int i = 0; i < 3; i++)
     {
         foxDraw.DrawLine(new Point(x, y + (i * 100)), new Point(x + length, y + (i * 100)));
     }
 }
Exemplo n.º 5
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            // Fill the canvas with a checkerboard pattern.

            DrawCheckerBoard(8);

            void DrawCheckerBoard(int amountOfSquares)
            {
                double squareSize = canvas.Width / amountOfSquares;


                //Set mainwindow and canvas width and height to 800
                double x = 0 + 10;
                double y = 0 + 30;

                foxDraw.FillColor(Colors.Black);
                foxDraw.StrokeColor(Colors.Black);

                foxDraw.DrawRectangle(x, y, squareSize, squareSize);

                for (int i = 0; i < amountOfSquares; i++)
                {
                    for (int j = 0; j < amountOfSquares; j++)
                    {
                        if (i % 2 == 0)
                        {
                            if (j % 2 == 0)
                            {
                                foxDraw.FillColor(Colors.White);
                            }
                            else
                            {
                                foxDraw.FillColor(Colors.Black);
                            }

                            foxDraw.DrawRectangle(x + (j * squareSize), y, squareSize, squareSize);
                        }
                        else
                        {
                            if (j % 2 == 0)
                            {
                                foxDraw.FillColor(Colors.Black);
                            }
                            else
                            {
                                foxDraw.FillColor(Colors.White);
                            }

                            foxDraw.DrawRectangle(x + (j * squareSize), y, squareSize, squareSize);
                        }
                    }
                    y += squareSize;
                }
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);
            // Create a function that takes 1 parameter:
            // A list of (x, y) points
            // and connects them with green lines.
            // connect these to get a box: {new Point(10, 10), new Point(290, 10), new Point(290, 290), new Point(10, 290)}
            // Connect these: {new Point(50, 100), new Point(70, 70), new Point(80, 90), new Point(90, 90), new Point(100, 70),
            // new Point(120, 100), new Point(85, 130), new Point(50, 100)}

            var greenFox = new List <Point>();

            greenFox.Add(new Point(50, 100));
            greenFox.Add(new Point(70, 70));
            greenFox.Add(new Point(80, 90));
            greenFox.Add(new Point(90, 90));
            greenFox.Add(new Point(100, 70));
            greenFox.Add(new Point(120, 100));
            greenFox.Add(new Point(85, 130));
            greenFox.Add(new Point(50, 100));

            foxDraw.StrokeColor(Colors.White);
            foxDraw.BackgroundColor(Colors.Black);
            foxDraw.FillColor(Colors.Green);

            ConnectTheDots(greenFox);

            var box = new List <Point>();

            //Box
            box.Add(new Point(10, 10));
            box.Add(new Point(290, 10));
            box.Add(new Point(290, 290));
            box.Add(new Point(10, 290));
            foxDraw.FillColor(Color.FromArgb(0, 0, 0, 0));

            ConnectTheDots(box);



            void ConnectTheDots(List <Point> inputPoints)
            {
                var from = inputPoints[0];
                var to   = new Point(0, 0);

                foreach (var point in inputPoints)
                {
                    to = point;
                    foxDraw.DrawPolygon(inputPoints);
                    from = point;
                }
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);
            // Create a function that takes 1 parameter:
            // A list of (x, y) points
            // and connects them with green lines.
            // connect these to get a box: {new Point(10, 10), new Point(290, 10), new Point(290, 290), new Point(10, 290)}
            // Connect these: {new Point(50, 100), new Point(70, 70), new Point(80, 90), new Point(90, 90), new Point(100, 70),
            // new Point(120, 100), new Point(85, 130), new Point(50, 100)}

            Random rng = new Random();

            var points = new List <Point>();

            foxDraw.StrokeColor(Colors.White);
            foxDraw.BackgroundColor(Colors.Black);
            foxDraw.FillColor(Colors.Gray);

            for (int i = 0; i < 30; i++)
            {
                points.Add(new Point(rng.Next(700), rng.Next(700)));
            }


            ConnectTheDots(points);

            void ConnectTheDots(List <Point> inputPoints)
            {
                var from = inputPoints[0];
                var to   = new Point(0, 0);

                foreach (var point in inputPoints)
                {
                    to = point;
                    foxDraw.DrawLine(from, to);
                    from = point;
                }
            }
        }
Exemplo n.º 8
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            var points = new List <Point>();

            int stepDistance = 10;
            int canvasHeight = Convert.ToInt32(canvas.Height);
            int canvasWidth  = Convert.ToInt32(canvas.Width);

            foxDraw.StrokeColor(Color.FromRgb(0, 0, 0));

            Point bottomSide = new Point(0, canvasHeight);

            points.Add(bottomSide);

            Point leftSide = new Point(0, 0);

            points.Add(leftSide);

            foxDraw.DrawLine(bottomSide, leftSide);

            Random rng = new Random();

            for (int i = 1; i < canvas.Width; i += stepDistance)
            {
                //Add X
                bottomSide.X += stepDistance;
                points.Add(new Point(bottomSide.X, canvasHeight));

                //Add Y
                leftSide.Y += stepDistance;
                points.Add(new Point(leftSide.X, leftSide.Y));

                foxDraw.DrawLine(bottomSide, leftSide);
            }
        }
Exemplo n.º 9
0
        public MainWindow()
        {
            InitializeComponent();
            var foxDraw = new FoxDraw(canvas);

            // Draw the night sky:
            //  - The background should be black
            //  - The stars can be small squares
            //  - The stars should have random positions on the canvas
            //  - The stars should have random color (some shade of grey)

            double sizeOfStar    = 3;
            int    amountOfStars = 200;

            foxDraw.BackgroundColor(Colors.Black);

            DrawStars(sizeOfStar, amountOfStars);

            void DrawStars(double size, int amount)
            {
                Random rng = new Random();

                int margin = 10;

                int width  = Convert.ToInt32(canvas.Width) - margin;
                int height = Convert.ToInt32(canvas.Height) - margin;

                for (int i = 0; i < amount; i++)
                {
                    byte randomColor = Convert.ToByte(rng.Next(0, 255));
                    foxDraw.FillColor(Color.FromRgb(randomColor, randomColor, randomColor));
                    foxDraw.StrokeColor(Color.FromRgb(randomColor, randomColor, randomColor));
                    foxDraw.DrawEllipse(rng.Next(0, width), rng.Next(0, height), sizeOfStar, sizeOfStar);
                }
            }
        }
Exemplo n.º 10
0
 public static void DrawToCenterFrom(double x, double y, Point centre, FoxDraw foxDraw)
 {
     foxDraw.StrokeColor(Colors.Green);
     foxDraw.DrawLine(new Point(x, y), centre);
 }