I\'ve been searching for just over a week now on how to create something like this.
I have the code and for loops to create each Panel by X, and Y coords a
With this answer you'll get the possibility to use the HSB representation of a color (maybe take also a look here).
By using this you can for the first row use a random hue, a zero saturation and a brightness going from 1.0 to 0.0 in the amount of needed steps. For the other rows you have to take 1.0 for the saturation and increase the hue from 0 to 360 in the same amount of steps and also increase the saturation from 0.0 to 1.0 per row.
I just put an example together:
private void OnResize(object sender, EventArgs e)
{
Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
UpdateImage(e.Graphics);
}
private void UpdateImage(Graphics graphics)
{
var columns = 10;
var rows = 8;
var hueSteps = 360 / columns;
var columnSteps = 1.0F / columns;
var width = Width / columns;
var height = Height / (rows + 1);
for (int i = 0; i < columns; i++)
{
var gray = ColorExtensions.FromAhsb(255, 0, 0, columnSteps * i);
using (var brush = new SolidBrush(gray))
{
graphics.FillRectangle(brush, width * i, 0, width, height);
}
}
for (int i = 0; i < columns; i++)
{
for (int j = 1; j <= rows; j++)
{
var color = ColorExtensions.FromAhsb(255, hueSteps * i, 1, columnSteps * j);
using (var brush = new SolidBrush(color))
{
graphics.FillRectangle(brush, width * i, height * j, width, height);
}
}
}
}
The result is not exact the same, but that would be just a matter of re-arrange the loops: