Смена цвета карандаша после каждой итерации на рандомный - C#
Формулировка задачи:
Как изменить после каждой итерации цвет карандаша на рандомный?
for (int i = 0; i < 50; i++)
{
x1 = x1 + (x2 - x1) * p;
y1 = y1 + (y2 - y1) * p;
x2 = x2 + (x3 - x2) * p;
y2 = y2 + (y3 - y2) * p;
x3 = x3 + (x4 - x3) * p;
y3 = y3 + (y4 - y3) * p;
x4 = x4 + (x1 - x4) * p;
y4 = y4 + (y1 - y4) * p;
// задаем массиву точек новые координаты
points[0] = new Point((int)x1, (int)y1);
points[1] = new Point((int)x2, (int)y2);
points[2] = new Point((int)x3, (int)y3);
points[3] = new Point((int)x4, (int)y4);
////можно выводить так или через полигон
//g.DrawLine(new Pen(Color.DarkBlue), points[0], points[1]);
//g.DrawLine(new Pen(Color.DarkBlue), points[1], points[2]);
//g.DrawLine(new Pen(Color.DarkBlue), points[2], points[3]);
g.DrawPolygon(new Pen(Color.DarkBlue), points);
Thread.Sleep(80);
}
}Решение задачи: «Смена цвета карандаша после каждой итерации на рандомный»
textual
Листинг программы
Random r = new Random(); Pen br = new Pen(Color.FromArgb(r.Next(255), r.Next(255), r.Next(255), r.Next(255)));