Clear a Graphics

image_pdfimage_print
   
 

using System;
using System.Drawing;
using System.Windows.Forms;
   
class RandomClear: Form 
{
     public static void Main()
     {
          Application.Run(new RandomClear());
     }
     public RandomClear()      
     {
          Text = "Random Clear";
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          Graphics graphics = pea.Graphics;
          Random   rand = new Random();
   
          graphics.Clear(Color.FromArgb(rand.Next(256),
                                    rand.Next(256),
                                    rand.Next(256)));
     }
}

    


This entry was posted in 2D Graphics. Bookmark the permalink.