private void buttonSun_Click(object sender, EventArgs e)
        {
            //for (int z = 0; z < 40; z++)
            //{


            //    for (int i = 0; i < 5; i++)
            //    {
            //        Turtle.Rotate(350);
            //        Turtle.Forward(i * 1);

            //        for (int k = 0; k < 6; k++)
            //        {
            //            Turtle.Rotate(350);
            //            Turtle.Forward(k * 1);
            //        }
            //    }
            //}
            Turtle.Delay = 100;
            for (int i = 0; i < 38; i++)
            {
                Turtle.Rotate(30);
                Turtle.Forward(200);
                Turtle.Rotate(5);
                Turtle.Backward(200);
                Turtle.Rotate(90);
                Turtle.Forward(200);
                Turtle.Rotate(5);
                Turtle.Backward(200);
                Turtle.Rotate(60);
            }
        }
Ejemplo n.º 2
0
        private void buttonDraw_Click(object sender, EventArgs e)
        {
            //Turtle.Rotate(30);
            //Turtle.Forward(200);
            //Turtle.Rotate(120);
            //Turtle.Forward(200);
            //Turtle.Rotate(120);
            //Turtle.Forward(200);

            Turtle.PenColor = Color.Blue;

            // Assign a delay to visualize the drawing process
            Turtle.Delay = 200;

            // Draw a equilateral triangle
            Turtle.Rotate(30);
            Turtle.Forward(200);
            Turtle.Rotate(120);
            Turtle.Forward(200);
            Turtle.Rotate(120);
            Turtle.Forward(200);

            // Draw a line in the triangle
            Turtle.Rotate(-30);
            Turtle.PenUp();
            Turtle.Backward(50);
            Turtle.PenDown();
            Turtle.Backward(100);
            Turtle.PenUp();
            Turtle.Forward(150);
            Turtle.PenDown();
            Turtle.Rotate(30);
        }
Ejemplo n.º 3
0
        private void buttonDraw_Click(object sender, EventArgs e)
        {
            Turtle.Delay = 300;

            for (int i = 0; i <= 3; i++)
            {
                // Draw a equilateral triangle
                Turtle.Rotate(30);
                Turtle.Forward(200);
                Turtle.Rotate(120);
                Turtle.Forward(200);
                Turtle.Rotate(120);
                Turtle.Forward(200);

                // Draw a line in the triangle
                Turtle.Rotate(-30);
                Turtle.PenUp();
                Turtle.Backward(50);
                Turtle.PenDown();
                Turtle.Backward(100);
                Turtle.PenUp();
                Turtle.Forward(150);
                Turtle.PenDown();
                Turtle.Rotate(30);
            }
        }
Ejemplo n.º 4
0
        private void DrawLevel(float parentSize, int numberOfLevels)
        {
            // Satellites
            var satelliteSize = parentSize / 2;

            Turtle.Forward(parentSize / 2);
            Turtle.Rotate(-60);
            DrawEquilateralTriangle(satelliteSize, numberOfLevels);
            Turtle.Rotate(60);

            --numberOfLevels;

            if (numberOfLevels > 0)
            {
                DrawLevel(satelliteSize, numberOfLevels);
                Turtle.Backward(parentSize - satelliteSize / 2);

                DrawLevel(satelliteSize, numberOfLevels);

                Turtle.Backward(satelliteSize / 2);
                Turtle.Rotate(-60);
                Turtle.Forward(parentSize / 2);
                Turtle.Rotate(60);

                DrawLevel(satelliteSize, numberOfLevels);

                // Now back to where we started...
                Turtle.Rotate(-60);
                Turtle.Forward(-parentSize / 2);
                Turtle.Rotate(60);
                Turtle.Backward(-satelliteSize / 2);
            }
        }
Ejemplo n.º 5
0
        public void TestBackward()
        {
            Turtle t = new Turtle();
            t.Backward(10f);

            Assert.AreEqual(-10f, t.X);
            Assert.AreEqual(0f, t.Y);
        }
Ejemplo n.º 6
0
 private void buttonDrawSun_Click(object sender, EventArgs e)
 {
     Turtle.Delay = 200;
     for (int i = 0; i < 18; i++)
     {
         Turtle.Forward(300);
         Turtle.Rotate(10);
         Turtle.Backward(300);
         Turtle.Rotate(10);
     }
 }
        public TurtleScriptValue Backward(List <TurtleScriptValue> parameters)
        {
            if (parameters.Count == 1)
            {
                double distance = parameters[0].NumericValue;

                Turtle.Backward(distance);
            }

            return(TurtleScriptValue.VOID);
        }
Ejemplo n.º 8
0
        private void buttonBackward_Click(object sender, EventArgs e)
        {
            string distanceText = InputPrompt.ShowDialog("Distance", "Enter Move Distance");

            int distance;

            if (int.TryParse(distanceText, out distance))
            {
                Turtle.Backward(distance);
                UpdateStatusBar();
            }
        }
Ejemplo n.º 9
0
 private void buttonDraw_Click(object sender, EventArgs e)
 {
     Turtle.Delay = 100;
     Turtle.Rotate(30);
     Turtle.Forward(200);
     Turtle.Rotate(120);
     Turtle.Forward(200);
     Turtle.Rotate(120);
     Turtle.Forward(200);
     Turtle.Rotate(-30);
     Turtle.PenUp();
     Turtle.Backward(30);
     Turtle.PenDown();
     Turtle.Backward(100);
     Turtle.PenUp();
     Turtle.Forward(130);
     Turtle.PenDown();
 }
Ejemplo n.º 10
0
 private void buttonDraw_Click(object sender, EventArgs e)
 {
     Turtle.Delay    = 200;
     Turtle.PenColor = Color.Blue;
     for (int i = 1; i <= 3; i++)
     {
         Turtle.Rotate(120);
         Turtle.Forward(200);
     }
     Turtle.PenUp();
     Turtle.Rotate(-30);
     Turtle.Backward(50);
     Turtle.PenDown();
     Turtle.Backward(100);
     Turtle.PenUp();
     Turtle.Forward(150);
     Turtle.Rotate(120);
     Turtle.PenDown();
 }
        /*
         *  Method: buttonDraw_Click(object sender, EventArgs e)
         *
         *  It draws the coded picture.
         */
        private void buttonDraw_Click(object sender, EventArgs e)
        {
            // Rotation is positive in the counterclockwise direction

            // 1. Draw a single equilateral triangle
            // Turtle.Rotate(30);
            // Turtle.Forward(200);
            // Turtle.Rotate(120);
            // Turtle.Forward(200);
            // Turtle.Rotate(120);
            // Turtle.Forward(200);

            // 2. Draw composite shapes
            int defaultDelay = Turtle.Delay;

            // Assign a delay to visualize the drawing process
            Turtle.Delay = 200;

            // Draw an equilateral triangle
            Turtle.Rotate(30);
            Turtle.Forward(200);
            Turtle.Rotate(120);
            Turtle.Forward(200);
            Turtle.Rotate(120);
            Turtle.Forward(200);

            // Draw a line in the triangle
            Turtle.Rotate(-30);
            Turtle.PenUp();
            Turtle.Backward(50);
            Turtle.PenDown();
            Turtle.Backward(100);
            Turtle.PenUp();
            Turtle.Forward(150);
            Turtle.PenDown();
            Turtle.Rotate(30);

            // reset delay
            Turtle.Delay = defaultDelay;
        }
        private void buttonDraw_Click(object sender, EventArgs e)
        {
            Enabled = false;
            try
            {
                // Assign a delay to visualize the drawing process
                Turtle.Delay = 150;

                // Draw a equilateral triangle
                Turtle.PenColor = Color.Green;
                Turtle.PenSize  = 5;
                Turtle.Rotate(30);
                Turtle.Forward(200);
                Turtle.Rotate(120);
                Turtle.Forward(200);
                Turtle.Rotate(120);
                Turtle.Forward(200);

                // Draw a line in the triangle
                Turtle.Rotate(-30);
                Turtle.PenUp();
                Turtle.Backward(50);
                Turtle.PenDown();
                Turtle.PenColor = Color.Red;
                Turtle.PenSize  = 5;
                Turtle.Backward(100);
                Turtle.PenColor = Turtle.DEFAULT_COLOR;
                Turtle.PenSize  = Turtle.DEFAULT_PEN_SIZE;
                Turtle.PenUp();
                Turtle.Forward(150);
                Turtle.PenDown();
                Turtle.Rotate(30);
            }
            finally
            {
                Enabled = true;
            }

            UpdateStatusBar();
        }
Ejemplo n.º 13
0
    public override void Paint(System.Drawing.Graphics g, double x, double y, double scale)
    {
        Vector pos         = new Vector(x, y);
        Vector orientation = this.Orientation.Copy();

        Turtle turtle = new Turtle(g, pos, orientation);

        turtle.SetColor(System.Drawing.Color.Red);
        turtle.Backward(this.Height / 2 * scale);
        turtle.SetColor(System.Drawing.Color.Black);

        turtle.Save();
        turtle.Left(NaturalConstants.Degree90);
        turtle.Forward(this.Width / 2 * scale);
        turtle.Right(a + NaturalConstants.Degree90);
        turtle.Forward(b * scale);

        turtle.Recall();
        turtle.Right(NaturalConstants.Degree90);
        turtle.Forward(this.Width / 2 * scale);
        turtle.Left(a + NaturalConstants.Degree90);
        turtle.Forward(b * scale);
    }