• C# 随机颜色的方法


     1          public string GetRandomColor()
     3         {
     4 
     5             Random RandomNum_First = new Random((int)DateTime.Now.Ticks);
     6 
     7             //  对于C#的随机数,没什么好说的
     8 
     9             System.Threading.Thread.Sleep(RandomNum_First.Next(50));
    10 
    11             Random RandomNum_Sencond = new Random((int)DateTime.Now.Ticks);
    12 
    13  
    14 
    15             //  为了在白色背景上显示,尽量生成深色
    16 
    17             int int_Red = RandomNum_First.Next(256);
    18 
    19             int int_Green = RandomNum_Sencond.Next(256);
    20 
    21             int int_Blue = (int_Red + int_Green > 400) ? 0 : 400 - int_Red - int_Green;
    22 
    23             int_Blue = (int_Blue > 255) ? 255 : int_Blue;
    24             Color color = Color.FromArgb(int_Red, int_Green, int_Blue);
    25             string strColor = "#" + Convert.ToString(color.ToArgb(), 16).PadLeft(8, '0').Substring(2, 6);
    26             return strColor;
    27 
    28         } 
    29 
    30 
    31   
  • 相关阅读:
    记录输出时间
    ***灵感或者没想到的思想
    Managing Difficulties
    4.20
    单调队列
    背包
    线性DP
    可持久化数据结构
    平衡树
    点分治
  • 原文地址:https://www.cnblogs.com/youchim/p/5311343.html
Copyright © 2020-2023  润新知