Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery颜色变化_Javascript_Jquery_Colors - Fatal编程技术网

Javascript jquery颜色变化

Javascript jquery颜色变化,javascript,jquery,colors,Javascript,Jquery,Colors,我需要生成给定颜色的所有255/256颜色变体,是否有一些建议可以开始,或者使用jQuery库 提前感谢。我想你说的是对特定颜色值的单个红色、绿色和蓝色通道(我想这就是你所说的“颜色”)执行某种数学运算。我只能猜测您想要的输入和输出值,但这里有一个示例开始,操作RGB空间*中的值。假设您的输入是十六进制数: var color = 0xFFD700, // "gold" // separate the channels using bitmasks redValue = col

我需要生成给定颜色的所有255/256颜色变体,是否有一些建议可以开始,或者使用jQuery库


提前感谢。

我想你说的是对特定颜色值的单个红色、绿色和蓝色通道(我想这就是你所说的“颜色”)执行某种数学运算。我只能猜测您想要的输入和输出值,但这里有一个示例开始,操作RGB空间*中的值。假设您的输入是十六进制数:

var color = 0xFFD700, // "gold"

    // separate the channels using bitmasks
    redValue = color & 0xFF0000, // redValue is 0xFF0000
    greenValue = color & 0x00FF00, // greenValue is 0x00D700
    blueValue = color & 0x0000FF; // blueValue is 0x000000

// now we can manipulate each color channel independently
var lessRed = redValue - 0x010000,
    moreBlue = blueValue + 0x000001,
    newColor = lessRed + greenValue + moreBlue; // newColor is 0xFED701
因此,一种通过改变红色通道,保持绿色和蓝色恒定,来产生所有颜色的数组的方法:

var colors = [],
    startColor = 0x00D700,
    endColor = 0xFFD700,
    incr = 0x010000;

while (startColor <= endColor)
{
    colors.push(startColor);
    startColor = startColor + incr;
}

// print the hex values
var i, len = colors.length, out = [];
for (var i=0; i<len; i++)
{
    out.push('0x' + colors[i].toString(16))
}
console.log(out.join('\n'))
哦,不需要jQuery


*
根据,RGB空间可能不是最好的颜色空间,但根据您的问题,我认为它是。

谢谢

我发现了两个有趣的概念:

我将对以下概念进行一些介绍:

$.xcolor.Lightning和$.xcolor.darken

另一个有趣的阅读:

但最后一个不适用于红色、绿色和蓝色: FF0000 00FF00 0000FF


也许只需要一点修正就可以接受3个“真实”的红、绿和蓝十六进制值,但我丢失了。

你所说的“变化”到底是什么意思?这很接近吗?实际上只有一种颜色。它只有1600万种变体。@recursive,那颜色当然是octarine。@josoroma你还没有定义“变体”是什么意思。色调的变化?亮度红色/绿色/蓝色组件?
var input = 'FFD700',
    hexValue = parseInt(input, 16);
console.log(hexValue.toString(10)); // prints: 16766720
console.log(hexValue.toString(16)); // prints: FFD700