本文介绍了更改的RGB颜色的色调在javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过这个话题,这显示了一种方法来增加/减小RGB颜色的亮度,我是需要一种方法来改变的RGB /十六进制颜色的色调在Javascript。

Inspired by this topic, which shows a way to increase / decrease a RGB colors brightness, I was in need for a way to change the Hue of an RGB / Hex Color in Javascript.

changeHue(#FF0000,40)将返回#ffaa00

推荐答案

如果你不害怕图书馆和几KB不会破坏你的项目,你可以尝试的,而不是重新实现轮...

If you're not afraid of libraries and a few kb won't ruin your project, you could try sc-color rather than reimplementing the wheel...

下面是一个 的jsfiddle 使用SC-颜色。的code的症结就在这里:

Here's a jsfiddle using sc-color. The crux of the code is here:

var c = sc_color("#FF0000").hue(40).hex6();
$("#test").css("background-color", c);

披露:我是SC-色笔者

这篇关于更改的RGB颜色的色调在javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-21 03:56