如何在javascript中生成浅色调 [英] How to generate light colour shades in javascript

查看:92
本文介绍了如何在javascript中生成浅色调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我在JavaScript工作,想为我的图形生成颜色。我希望每一行都有一个新颜色,颜色应该是浅色。



我已阅读有关java脚本中颜色生成的问题



JavaScript中的随机颜色生成器



因为我想为我的行添加新颜色所以随机数生成在我的情况下不起作用
此外颜色应该很浅



我已经阅读了有关RGB值的颜色,但我没有找到任何关于如何选择浅色的图案



所以任何人都可以指导我,因为有一种方法可以按顺序生成颜色(避免随机),只选择浅色或任何其他功能,使深色更浅



谢谢



http://cloford.c om / resources / colors / 500col.htm

解决方案

你可以这样试试:

  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)+')';

通过这种方式,您可以生成红色,绿色和蓝色的颜色,范围为230 - 256,这是浅色。您可以通过更改数字来降低颜色。


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

解决方案

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.

这篇关于如何在javascript中生成浅色调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆