Quantcast
Viewing all articles
Browse latest Browse all 12583

Random Color

Hello everyone! I am just making a simple program for fun. And i need my program to select random color to draw a line. Here is part of my code:

rand1 = new Random().Next(-1000, 1000);
            rand2 = new Random().Next(-2150, 1000);
            rand3 = new Random().Next(-1200, -1000);
            rand4 = new Random().Next(-501, 1000);
            Random randonGen = new Random();
            Color randomColor = Color.FromArgb(randonGen.Next(255), randonGen.Next(255), randonGen.Next(255));

            
             Pen redPen = new Pen(Color.SkyBlue,10);
            
             
            g.DrawLine(redPen, new Point(rand3, rand1), new Point(rand4, rand2));

So, instead of "(Color.SkyBlue, 10)" i want it to choose a random color. I tried Color.randomColor and ofcorse it didn't work)) So i want instead of SkyBlue, a random color...


Viewing all articles
Browse latest Browse all 12583

Trending Articles