本文介绍了如何在C#中生成随机的暗色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过这种方式生成一个随机颜色:
I generate a random color this way:
var random = new Random();
var color = String.Format("#{0:X6}", random.Next(0x1000000));
如何排除比某个值更亮的颜色?
How can I exclude colors brighter than a certain value?
推荐答案
清除brightes颜色的上半部分的一个很简单的方法是通过
An quite simple way to get rid of the "upper half" of brightes colors is to mask the result via
random.Next(0x1000000) & 0x7F7F7F
这篇关于如何在C#中生成随机的暗色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!