Color generator

3

I want to develop a random color generator but it is clear, that is, it is possible to read a text with the black color on the color generated randomly. Random colors I can generate by means of the following code:
RGB(RandomRange(0,255), RandomRange(0,255), RandomRange(0,255));

The question is: How to generate only light colors ?

    
asked by anonymous 24.11.2016 / 19:05

1 answer

10

A very simple way is this:

RGB(RandomRange(150,255), RandomRange(150,255), RandomRange(150,255));

Basically you're making the minimum color 150, 150, 150.

The higher you start the value, the clearer the colors get. If you only wanted dark colors, it would be the opposite:

RGB(RandomRange(0,150), RandomRange(0,150), RandomRange(0,150));

In both cases, set the 150 to all entries according to your preference.

If you want bright colors, make up for using variables instead of 150, and create a formula that divides a number only between RG and B, maintaining the ratio but allowing you to "overload" one if the other is dark. >     

24.11.2016 / 19:08