我的颜色值为rgb(92,174,224),并且当不透明度为0.5(或我选择的任何值,它可能为0.4)并且背景为白色rgb(255)时,我想找到rgba等效值,255,255)。
我希望答案是一个等式的形式,如:
div (d) = rgb(92, 174, 224) ---- (The colour to match)
background (b) = rgb(255, 255, 255) ---- (The colour behind the transparent colour)
x = (d - (b*0.5)) / 0.5
r = (d - (b*0.5)) / 0.5
g = (d - (b*0.5)) / 0.5
b = (d - (b*0.5)) / 0.5
答案 0 :(得分:0)
如果我能正确理解你的问题,那么这里有适合你的东西。
color = rgb(92, 174, 224);
// we will use color[0] to access first value
bg = rbg(255,255,255);
// we will use bg[0] to access first value
alpha = 0.6;
base = alpha/10;
现在计算如下。
ResultColor[0] = round( bg[0] - ( (bg[0] - color[0])/alpha ) - 1 )
ResultColor[1] = round( bg[1] - ( (bg[1] - color[1])/alpha ) - 1 )
ResultColor[2] = round( bg[2] - ( (bg[2] - color[2])/alpha ) - 1 )
因此产生的颜色将是
ResultColor = rgb(173,214,239)