How to generate light shades of color in javascript

Hi everyone, I work in JavaScript and want to generate colors for my graphic. And I want a new color for each line, and also the color should be light.

I read the question about color generation in java script

JavaScript random color generator

How do I want a new color for my line, so a random number of generations will not work in my case Also the color should be light

I read about RGB color values, but I did not find them after any pattern, how to choose a light color

So, anyone can direct me as there is a way to generate colors in a sequence (avoid random ones) and choose only a light color or any other function to make dark color easier

thank

http://cloford.com/resources/colours/500col.htm

+2
source share
1 answer

You can try as follows:

var new_light_color = 'rgb(' + (Math.floor((256-229)*Math.random()) + 230) + ',' + 
                                    (Math.floor((256-229)*Math.random()) + 230) + ',' + 
                                    (Math.floor((256-229)*Math.random()) + 230) + ')';

This way you create colors that have red, green, and blue in the range 230 - 256, which is a light color. You can go lower by changing the numbers for darker colors.

+8
source

Source: https://habr.com/ru/post/1540171/


All Articles