Reputation: 2157
Hello all I am working in JavaScript and want to generate colors for my graph.And I want a new color for every line and also the color should be light in shade.
I have read about question of color generation in java script
Random color generator in JavaScript
As I want new color for my line so random number generation will not work in my case Also the color should be light
I have read about the colors RGB values but I didn't find them following any pattern as how to choose light color
So any one can please guide me as is there a way to generate colors in sequence (avoid random) and choose only light color or any other function to make dark color lighter
Thanks
http://cloford.com/resources/colours/500col.htm
Upvotes: 2
Views: 6316
Reputation: 1200
You can try this way:
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 generate 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.
Upvotes: 10