Answer the question
In order to leave comments, you need to log in
How to fill a square with random colors?
How to fill a square with random colors? Just so that not the whole square is of the same solid color, as it turns out with this code
Graphics gr;
gr = this.CreateGraphics();
Random r = new Random();
SolidBrush mySolidBrush = new SolidBrush(Color.FromArgb(r.Next(255),r.Next(255),r.Next(255),r.Next(255)));
gr.FillRectangle(mySolidBrush, 50, 50, 450, 200);
Answer the question
In order to leave comments, you need to log in
something like this
foreach(int x=50; x < 450; x++)
foreach(int y=50; y < 200; y++)
{
SolidBrush mySolidBrush = new SolidBrush(Color.FromArgb(r.Next(255),r.Next(255),r.Next(255),r.Next(255)));
gr.FillRectangle(mySolidBrush, x, y, x+1, y+1);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question