返回“n”的JavaScript函数给定颜色的阴影(从暗到亮) [英] JavaScript function to return "n" shades of a given color from (dark to light)

查看:220
本文介绍了返回“n”的JavaScript函数给定颜色的阴影(从暗到亮)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得用于生成标签云的特定颜色的颜色范围。



假设用户使用 RGB / HHHHHH 值输入了一些颜色,那么我想写一个函数<$不同颜色的深浅不同颜色的no返回 RGB / HHHHHH 颜色。这些颜色将有助于显示具有相同阴影的不同颜色的不同标签。但我想避免黑白色调。



以下是 F({R:0,G:0,B:255},7)返回 7 蓝色阴影。





<对于任何RGB组合,例如(25,150,150)也不会是真的。



使用JavaScript可以使用此函数,还是有可以实现这一点的RGB的任何公式?

解决方案

你想在 jsbin ?这是我使用jQuery构建的演示。



让我知道如果你有任何疑问。


I would like to get the color range of the specific color for generating tag cloud.

Say that user has entered some color with RGB/HHHHHH values then I would like to write a function f(color, no) which returns RGB/HHHHHH for "no" of different shades from dark to light colors for specified "color". These colors then will be useful to display the different tags with different color of same shade. But I would like to avoid black and white shades in it.

Following is example of F({R:0, G:0, B:255}, 7) which returns 7 shades of blue.

I would not like it to be true for any RGB combination say for example (25, 150,150) also.

Is this function possible using JavaScript or is there any formula for RGB with which this can be achieved?

解决方案

Do you want something like this on jsbin? This is a demo that I have built using jQuery.

Let me know if you have any doubts.

这篇关于返回“n”的JavaScript函数给定颜色的阴影(从暗到亮)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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