How to generate random color names in C#

后端 未结 15 1807
清酒与你
清酒与你 2020-11-29 21:57

I need to generate random color names e.g. \"Red\", \"White\" etc. How can I do it? I am able to generate random color like this:

Random randonGen = new Ran         


        
15条回答
  •  Happy的楠姐
    2020-11-29 22:44

    I would build a lookup table. Especially since some colors are up to personal interpretation.

    Go through each color value in the Color struct ( http://msdn.microsoft.com/en-us/library/system.drawing.color.aspx ) and map it to the RGB values. Then to convert back, lookup the RGB value to see if it has a named color.

提交回复
热议问题