Exemple #1
0
        private void AddBranch(FractalLine parent, int Depth)
        {
            if (Depth > SplitDepth || Draw == false)
            {
                return;
            }

            double Angle1 = parent.m_Angle - AngleDelta;
            double Angle2 = parent.m_Angle + AngleDelta;

            FractalLine line  = new FractalLine(parent.m_End, (int)(parent.CalcLength() * ShrinkRate), Angle1, parent);
            FractalLine line2 = new FractalLine(parent.m_End, (int)(parent.CalcLength() * ShrinkRate), Angle2, parent);

            System.Threading.Thread.Sleep(Int32.Parse(txtAnimDelay.Text));

            //UI commands must be invoked on ui thread
            Action a = () => DrawCanvas.Refresh();

            InvokeUI(a);

            /*Take turns on which side goes first,
             * This prevents one side of the tree from completing first*/
            if (Depth % 2 == 0)
            {
                AddBranch(line, Depth + 1);
                AddBranch(line2, Depth + 1);
            }
            else
            {
                AddBranch(line2, Depth + 1);
                AddBranch(line, Depth + 1);
            }
        }
Exemple #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     history.Clear();
     canvas.Refresh();
 }