Пример #1
0
        public override void MoveTurtle(string instructions, float distanceUnit)
        {
            ExpressiveRangeLogger.RecordPosition();
            for (int i = 0; i < instructions.Length; i++)
            {
                switch (instructions[i])
                {
                case '0':
                    Turtle.Forward(distanceUnit / 2);
                    break;

                case '1':
                    Turtle.Forward(distanceUnit);
                    break;

                case '[':
                    PushTurtle();
                    Turtle.Rotate(-45);
                    break;

                case ']':
                    PopTurtle();
                    Turtle.Rotate(45);
                    break;
                }
                ExpressiveRangeLogger.RecordPosition();
                ProgressBar.Value = i;
            }
            base.MoveTurtle(instructions, distanceUnit);
        }
Пример #2
0
        private void BtnExecute_Click(object sender, EventArgs e)
        {
            EnableButtons(false);

            if (checkReset.Checked)
            {
                ResetTurtle();
            }

            string instructions = LbxInstructions.SelectedItem.ToString();

            progressBar.Maximum = instructions.Length - 1;
            Turtle.PenSize      = brushThickness;
            Turtle.ShowTurtle   = checkTurtleVisible.Checked;

            if (checkDelay.Checked)
            {
                Turtle.Delay = 1000 / instructions.Length;
            }
            else
            {
                Turtle.Delay = 0;
            }

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            generator.MoveTurtle(instructions, distanceUnit);
            stopwatch.Stop();
            ExpressiveRangeLogger.LogExpressiveRange(instructions.Length, stopwatch.ElapsedMilliseconds);

            EnableButtons(true);
            progressBar.Value = 0;
        }
Пример #3
0
        public override void MoveTurtle(string instructions, float distanceUnit)
        {
            ExpressiveRangeLogger.RecordPosition();
            for (int i = 0; i < instructions.Length; i++)
            {
                switch (instructions[i])
                {
                case 'F':
                case 'G':
                    Turtle.Forward(distanceUnit);
                    break;

                case '-':
                    Turtle.Rotate(120);
                    break;

                case '+':
                    Turtle.Rotate(-120);
                    break;
                }
                ExpressiveRangeLogger.RecordPosition();
                ProgressBar.Value = i;
            }
            base.MoveTurtle(instructions, distanceUnit);
        }
Пример #4
0
        public override void MoveTurtle(string instructions, float distanceUnit)
        {
            ExpressiveRangeLogger.RecordPosition();
            for (int i = 0; i < instructions.Length; i++)
            {
                switch (instructions[i])
                {
                case 'A':
                    Turtle.Forward(distanceUnit);
                    break;

                case 'B':
                    Turtle.PenVisible = false;
                    Turtle.Forward(distanceUnit);
                    Turtle.PenVisible = true;
                    break;
                }
                ExpressiveRangeLogger.RecordPosition();
                ProgressBar.Value = i;
            }
            base.MoveTurtle(instructions, distanceUnit);
        }
Пример #5
0
        private void BtnInit_Click(object sender, EventArgs e)
        {
            ExpressiveRangeLogger.Initialize();
            switch (CbxGenerator.SelectedItem.ToString())
            {
            case "Cantor set":
                generator = new CantorSetGenerator();
                break;

            case "Koch curve":
                generator = new KochCurveGenerator();
                break;

            case "Fractal (binary) tree":
                generator = new FractalTreeGenerator();
                break;

            case "Sierpinski triangle":
                generator = new SierpinskiTriangleGenerator();
                break;

            case "Fractal plant":
                generator = new FractalPlantGenerator();
                break;

            default:
                throw new Exception("Unknown selection");
            }
            Turtle.ShowTurtle     = checkTurtleVisible.Checked;
            Generator.ProgressBar = progressBar;
            UpdateListBox();
            BtnInit.Text = "Re-Initialize";
            EnableButtons(true);
            TbxThickness.Text = "2";
            TbxDistance.Text  = "20";
        }