获取随即颜色值

  //生成随即颜色值  颜色偏深
Response.Write("<font color=" + GetRandomColor() + ">" + GetRandomColor() + "</font>");

 

 

public string GetRandomColor()
    {
        Random d_First = new Random((int)DateTime.Now.Ticks);
        System.Threading.Thread.Sleep(d_First.Next(50));
        Random d_Second = new Random((int)DateTime.Now.Ticks);
        int int_Red = d_First.Next(256);
        int int_Green = d_Second.Next(256);
        int int_Blue = (int_Red + int_Green > 400) ? 0 : 400 - int_Red - int_Green;
        int_Blue = (int_Blue > 255) ? 255 : int_Blue;
        return Color.FromArgb(int_Red, int_Green, int_Blue).Name;
    }

posted @ 2012-03-13 13:40  吃西瓜最快  阅读(177)  评论(0编辑  收藏  举报