算法的加色混合的RGB值 [英] Algorithm for Additive Color Mixing for RGB Values
本文介绍了算法的加色混合的RGB值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在寻找一种算法做加色混合RGB值。
是不是简单地添加的RGB值加在一起为256 A最大?
(R1,G1,B1)+(R2,G2,B2)=
(分钟(R1 + R2,256),分钟(G1 + G2,256),分钟(B1 + B2,256))
解决方案
这取决于你想要什么,它可以帮助,看看有什么结果的不同方法。
如果你想
红+黑=红 红+绿=黄 红+绿+蓝=白 红+白=白 黑+白=白
然后用夹子作品加入(如分(R1 + R2,255)
)这更像是你提到的光照模型。
如果你想
红+黑=暗红色 红+绿=深黄色 红+绿+蓝=深灰色 红+白=粉红色 黑+白=灰
,那么你就需要平均的值(例如(R1 + R2)/ 2
)本工程为更好地减轻/变暗的颜色和创建渐变。
I'm looking for an algorithm to do additive color mixing for RGB values.
Is it as simple as adding the RGB values together to a max of 256?
(r1, g1, b1) + (r2, g2, b2) =
(min(r1+r2, 256), min(g1+g2, 256), min(b1+b2, 256))
解决方案
It depends on what you want, and it can help to see what the results are of different methods.
If you want
Red + Black = Red Red + Green = Yellow Red + Green + Blue = White Red + White = White Black + White = White
then adding with a clamp works (e.g. min(r1 + r2, 255)
) This is more like the light model you've referred to.
If you want
Red + Black = Dark Red Red + Green = Dark Yellow Red + Green + Blue = Dark Gray Red + White = Pink Black + White = Gray
then you'll need to average the values (e.g. (r1 + r2) / 2
) This works better for lightening/darkening colors and creating gradients.
这篇关于算法的加色混合的RGB值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文