Beispiel #1
0
        /// <summary>
        /// Рисование треугольника Серпинсого.
        /// </summary>
        /// <param name="target"> Где рисовать.</param>
        private void SerpTri(Graphics target)
        {
            SetupForElse();
            var start = new Point(pictureBox.Location.X + pictureBox.Size.Width / 2, 20 * delta);

            start.X += current.X;
            start.Y += current.Y;
            int          len = delta * Math.Min(pictureBox.Size.Height, pictureBox.Size.Width);
            SerpTriangle fractSerpTriangle = new SerpTriangle(new Point(start.X - len / 2, Convert.ToInt32(start.Y + len * Math.Sqrt(3) / 2)), new Point(start.X + len / 2, Convert.ToInt32(start.Y + len * Math.Sqrt(3) / 2)), start);

            fractSerpTriangle.Refresh(recur, target);
        }
Beispiel #2
0
 /// <summary>
 /// Функция для отрисовки прямой.
 /// </summary>
 /// <param name="depth"> Глубина рекурсии.</param>
 /// <param name="target"> Где рисовать.</param>
 public override void Refresh(int depth, Graphics target)
 {
     Draw(target, this);
     if (depth <= maxRecur)
     {
         if (depth > 0)
         {
             var first  = new SerpTriangle(a, new Point((b.X + a.X) / 2, (b.Y + a.Y) / 2), new Point((a.X + c.X) / 2, (a.Y + c.Y) / 2));
             var second = new SerpTriangle(b, new Point((c.X + b.X) / 2, (b.Y + c.Y) / 2), new Point((a.X + b.X) / 2, (a.Y + b.Y) / 2));
             var third  = new SerpTriangle(c, new Point((c.X + b.X) / 2, (b.Y + c.Y) / 2), new Point((a.X + c.X) / 2, (a.Y + c.Y) / 2));
             first.Refresh(depth - 1, target);
             second.Refresh(depth - 1, target);
             third.Refresh(depth - 1, target);
         }
     }
 }
Beispiel #3
0
 /// <summary>
 /// Рисование треугольника.
 /// </summary>
 /// <param name="target"> Где рисовать.</param>
 /// <param name="triangle"> Треугольник что нарисовать.</param>
 private void Draw(Graphics target, SerpTriangle triangle)
 {
     target.DrawPolygon(new Pen(Color.Blue, (float)2), new Point[3] {
         triangle.a, triangle.b, triangle.c
     });
 }