Friday, January 19, 2018

Calculate transparent foreground color

https://stackoverflow.com/a/12228643/806777

function transparentColor(backgroundColor, finalColor, transparency){
  var color = [];
  for (var i = 0; i < 3; i++) {
    color[i] = (finalColor[i] - backgroundColor[i] + backgroundColor[i] * transparency) / transparency;
  }
  return color;
}

transparentColor([204, 222, 225], [102, 139, 197], .5) = [0, 56, 169]

No comments:

Post a Comment