开发者

How can I get a list of visually distinct colors?

I need to assign colours to distinguish between different items. Simple case: order rows of different color according to customer.

I don't want to have the user choose a colour for every customer, I want to do this at runtime.

If there is a single customer I will use "red", if there are two "red" and "white", ...

Of course I can create my GimmeRandomColour(i: index) own function t开发者_运维技巧hat uses i and the RGB function to create good random colours (but in this case creating nice colours can be tricky). Or I can say if i is 0 give me clRed, ... (in this way creating many colours can be a problem).

How can I get a "good list of colours" with a acceptable levels of contrast?


No in-built function in Delphi. See this question for ways to generate pleasing colour schemes.

Algorithm to randomly generate an aesthetically-pleasing color palette


A common approach is to use the values $00, $33, $66, $99, $CC and $FF (Random(6) * $33) for each RGB color component.

That will result in 216 different colors that are safe to use.

See examples on wikipedia.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜