function - 如何在没有 ProcessingJS 的情况下制作 lerpColor() 函数
问题描述
我想创建自己的lerpColor(c1, c2, amount)
函数,其输出与 ProcessingJS
http://processingjs.org/reference/lerpColor_/
我正在寻找或类似的东西:
lerpColor = function (c1, c2, amount) {
// Do some math stuff here
return(newColor);
};
任何帮助将不胜感激。
解决方案
如果此颜色插值纯粹在 RGB 颜色空间中工作,则需要提取颜色分量并将下一个算法应用于每个分量
r1 = red(c1)
r2 = red(c2)
result_red = (1-amount) * r1 + amount * r2
or
result_red = r1 + amount * (r2 - r1)
...
return(color(result_red, result_green, result_blue));
推荐阅读
- node.js - 为什么 node.js 在服务器重启后不加载网站?
- python - 如何向其中添加多个项目?
- python - pysnmp snmp 打印 OID 实际值
- python - Discord.py:将欢迎消息移动到另一个模块后无法发送欢迎消息
- android - XAMARIN 错误:在 android-sdk 上部署失败
- javascript - Vue Input 传递一个数组
- reactjs - 为什么我的减速器在我的 action.payload 中找不到值来在我的数组中进行过滤?
- javascript - 反应“if”中唯一的第一条消息
- java - spring 项目(来自 IDE 上的 spring initialzr 插件)是 Unloadable
- github - 如何更改多个存储库的监视设置?