2

我正在寻找一个公式来确定 RGB 颜色的红色度。我敢肯定有一些非常简单的公式,但我一直没能找到它。

基本上,它会是这样的:

function rednessAsPercent(r, g, b) {
  // Does some math to determine redness.
}

alert(rednessAsPercent(255, 0, 0)); // Alerts: 100
alert(rednessAsPercent(255, 255, 0)); // Alerts: 0.  This is pure yellow.
alert(rednessAsPercent(255, 122, 122)); // Alerts: ~50.  This is sort of pink.

有任何想法吗?

谢谢!

4

1 回答 1

0

您必须对“发红”的含义提出一个更好的定义-在什么范围内(大概是红-蓝-黄)

这可能有用: http ://en.wikipedia.org/wiki/HSL_color_space

于 2012-08-11T04:04:20.890 回答