admin管理员组文章数量:1297125
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
.htm
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./resources/colours/500col.htm
Share Improve this question edited May 23, 2017 at 12:01 CommunityBot 11 silver badge asked Jun 27, 2012 at 11:20 A_userA_user 2,1576 gold badges26 silver badges33 bronze badges 1- 3 You should use HSL color (google for it) in order to be able to define easily light or dark colors. It's available in HTML5. – Denys Séguret Commented Jun 27, 2012 at 11:23
1 Answer
Reset to default 10You 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.
本文标签: How to generate light colour shades in javascriptStack Overflow
版权声明:本文标题:How to generate light colour shades in javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741647718a2390287.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论