Example #1
0
 public static void DrawFigures(this Bitmap Image, int Number, BitmapFigureType Type)
 {
     for (int i = 0; i < Number; i++)
     {
         Image.DrawFigure(Type);
     }
 }
Example #2
0
        public static void DrawFigure(this Bitmap Image, BitmapFigureType Type)
        {
            Random random = new Random();

            Brush[] brushes = new Brush[]
            {
                new HatchBrush((HatchStyle)
                               Enum.Parse(typeof(HatchStyle),
                                          Enum.GetNames(typeof(HatchStyle))[
                                              random.Next(
                                                  Enum.GetNames(typeof(HatchStyle)).Length)]),
                               Color.FromArgb(255,
                                              random.Next(255),
                                              random.Next(255),
                                              random.Next(255)),
                               Color.FromArgb(255,
                                              random.Next(255),
                                              random.Next(255),
                                              random.Next(255))),
                new SolidBrush(Color.FromArgb(255,
                                              random.Next(255),
                                              random.Next(255),
                                              random.Next(255)))
            };

            Image.DrawFigure(brushes[random.Next(brushes.Length)],
                             (BitmapFigureType)
                             Enum.Parse(typeof(BitmapFigureType),
                                        Enum.GetNames(typeof(BitmapFigureType))[random.Next(Enum.GetNames(typeof(BitmapFigureType)).Length)]));
        }
Example #3
0
        public static void DrawFigure(this Bitmap Image, Brush Brush, BitmapFigureType Type)
        {
            Random random = new Random();

            using (Graphics g = Graphics.FromImage(Image))
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;

                switch (Type)
                {
                case BitmapFigureType.Circle:
                {
                    int radius = random.Next(Image.Width / 10);
                    g.DrawEllipse(new Pen(Brush), random.Next(Image.Width), random.Next(Image.Height), radius, radius);
                    break;
                }

                case BitmapFigureType.Ellipse:
                {
                    g.DrawEllipse(new Pen(Brush), random.Next(Image.Width), random.Next(Image.Height), random.Next(Image.Width / 10), random.Next(Image.Height / 10));
                    break;
                }

                case BitmapFigureType.Triangle:
                {
                    break;
                }

                case BitmapFigureType.Square:
                {
                    int radius = random.Next(Image.Width / 10);
                    g.DrawRectangle(new Pen(Brush), random.Next(Image.Width), random.Next(Image.Height), radius, radius);
                    break;
                }

                case BitmapFigureType.Paralellogram:
                {
                    g.DrawRectangle(new Pen(Brush), random.Next(Image.Width), random.Next(Image.Height), random.Next(Image.Width / 10), random.Next(Image.Height / 10));
                    break;
                }

                case BitmapFigureType.Pentagon:
                {
                    break;
                }

                case BitmapFigureType.Hexagon:
                {
                    break;
                }
                }
            }
        }
Example #4
0
 public static void DrawFigure(this Bitmap Image, Color Color, BitmapFigureType Type)
 {
     Image.DrawFigure(new SolidBrush(Color), Type);
 }
Example #5
0
 public static void DrawFigures(this Bitmap Image, int Number, Color Color, BitmapFigureType Type)
 {
     Image.DrawFigures(Number, new SolidBrush(Color), Type);
 }