逆色计算算法 [英] Algorithm for calculating inverse color
本文介绍了逆色计算算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每个片段的RGB颜色都在0.0到1.0的范围内,我需要一种算法来获取颜色的反色,任何想法如何做到这一点?
I have a RGB color in the range of 0.0 to 1.0 for each fragment, I need an algorithm to get the inverse of the color, any ideas how can I do this?
推荐答案
newR = 1.0 - r
newG = 1.0 - g
newB = 1.0 - b
如果颜色具有预乘Alpha值,请使用alpha而不是1.0:
If the color has a premultiplied Alpha value use the alpha instead of 1.0:
newR = a - r
newG = a - g
newB = a - b
这篇关于逆色计算算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文