Ejemplo n.º 1
0
        private void SetButtons()
        {
            ShowPic1.Image = new Bitmap(40, 40);
            ShowPic2.Image = new Bitmap(40, 38);
            ShowPic3.Image = new Bitmap(52, 52);

            //Draw Fractal TreeFractal icon
            treeFractal = new TreeFractal(40, 40, startColor, endColor, 10, 0.7, Math.PI / 4, Math.PI / 4);
            treeFractal.Draw();
            lines    = treeFractal.GetLines;
            graphics = Graphics.FromImage(ShowPic1.Image);
            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            pen = new Pen(Color.Black);

            foreach (Fractal.Line Line in lines)
            {
                pen.Color = Line.Color;
                graphics.DrawLine(pen, Line.OldX, Line.OldY, Line.X, Line.Y);
            }
            ShowPic1.Update();

            //Draw Cantor icon
            cantor = new Cantor(40, 50, startColor, endColor, 10, 10);
            cantor.Draw();
            rectangles = cantor.GetRectangles;
            graphics   = Graphics.FromImage(ShowPic2.Image);
            solidBrush = new SolidBrush(startColor);

            foreach (Fractal.Rectangle rect in rectangles)
            {
                pen.Color        = rect.Color;
                solidBrush.Color = rect.Color;

                graphics.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Heigth);
                graphics.FillRectangle(solidBrush, rect.X, rect.Y, rect.Width, rect.Heigth);
            }
            ShowPic1.Update();

            //Draw Levi icon
            levi = new Levi(52, 50, startColor, endColor, 10);
            levi.Draw();
            lines    = levi.GetLines;
            graphics = Graphics.FromImage(ShowPic3.Image);

            foreach (Fractal.Line Line in lines)
            {
                pen.Color = Line.Color;
                graphics.DrawLine(pen, Line.OldX, Line.OldY, Line.X, Line.Y);
            }
            ShowPic3.Update();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Main Draw func
        /// </summary>
        public void Draw()
        {
            MainPic.Height = PicLayout.Height * scale;
            MainPic.Width  = PicLayout.Width * scale;

            bitmap        = new Bitmap(MainPic.Width, MainPic.Height);
            MainPic.Image = bitmap;
            graphics      = Graphics.FromImage(MainPic.Image);

            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            switch (fractalNumber)
            {
            case 1:
                treeFractal = new TreeFractal(MainPic.Width, MainPic.Height,
                                              startColor, endColor, depth, coef, CornerL, CornerR);
                treeFractal.Draw();
                lines = treeFractal.GetLines;

                foreach (Fractal.Line Line in lines)
                {
                    pen.Color = Line.Color;
                    graphics.DrawLine(pen, Line.OldX, Line.OldY, Line.X, Line.Y);
                }

                break;

            case 2:
                cantor = new Cantor(MainPic.Width, MainPic.Height,
                                    startColor, endColor, depth, distance);
                cantor.Draw();
                rectangles = cantor.GetRectangles;

                foreach (Fractal.Rectangle rect in rectangles)
                {
                    pen.Color        = rect.Color;
                    solidBrush.Color = rect.Color;

                    graphics.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Heigth);
                    graphics.FillRectangle(solidBrush, rect.X, rect.Y, rect.Width, rect.Heigth);
                }

                break;

            case 3:
                levi = new Levi(MainPic.Width, MainPic.Height,
                                startColor, endColor, depth);
                levi.Draw();
                lines = levi.GetLines;

                foreach (Fractal.Line Line in lines)
                {
                    pen.Color = Line.Color;
                    graphics.DrawLine(pen, Line.OldX, Line.OldY, Line.X, Line.Y);
                }
                break;

            default:
                break;
            }

            MainPic.Image = bitmap;

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }