JavaScript中平均2种十六进制颜色的总和 [英] Average 2 hex colors together in javascript
本文介绍了JavaScript中平均2种十六进制颜色的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好吧,我想把这个扔出去,让人群考虑一下.
Alright thought I would throw this one out there for the crowd to think over.
给出一个函数 (用JavaScript编写),该函数期望两个字符串的格式类似十六进制颜色( ex#FF0000 )
Given a function (written in javascript) that expects two strings formated like a hex color (ex #FF0000)
返回十六进制颜色,该颜色是所传递的两种颜色的平均值.
return a hex color that is the average of both of the colors passed.
function averageColors(firstColor,secondColor)
{
...
return avgColor;
}
-编辑-
平均将定义为
如果通过的颜色是黄色,而第二个颜色是浅紫色,则返回的颜色将是中等橙色
推荐答案
我讨厌听起来很破的jQuery记录,但是 是 href ="http://www.xarg.org/project/jquery-color-plugin-xcolor/#meth_multiply" rel ="nofollow noreferrer">为此已经有jQuery插件.
I hate sounding like the oh-so-broken jQuery record, but there is a jQuery plugin for this already.
这篇关于JavaScript中平均2种十六进制颜色的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文