What I Learned Today

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]
Posted by Tony Brix at 2:34 PM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Blog Archive

  • ▼  2018 (1)
    • ▼  January (1)
      • Calculate transparent foreground color
  • ►  2017 (1)
    • ►  February (1)
  • ►  2016 (1)
    • ►  May (1)
  • ►  2015 (17)
    • ►  October (1)
    • ►  June (4)
    • ►  May (1)
    • ►  April (1)
    • ►  March (3)
    • ►  February (6)
    • ►  January (1)
  • ►  2014 (15)
    • ►  December (2)
    • ►  November (2)
    • ►  September (1)
    • ►  August (2)
    • ►  July (1)
    • ►  June (2)
    • ►  May (5)
  • ►  2013 (8)
    • ►  May (2)
    • ►  April (2)
    • ►  March (1)
    • ►  February (1)
    • ►  January (2)

About Me

Tony Brix
View my complete profile
Simple theme. Powered by Blogger.