问题
If I have a visual element (could be text or div with color fill, doesn't matter) and the color is set to black, 0x000000, and it's alpha is set to .4 or .5 and the background is solid white, 0xFFFFFF, the result would be a gray color. We can test this in Photoshop.
What I would like to know is what code would I use to get to that result?
I'm looking for something such as an equation:
newColor = foregroundColor * alpha * backgroundColor
Or something like in JavaScript, ActionScript or VBScript:
var color:uint = (0x888888 * .5) * 0x000000;
Part of the difficulty is solving this issue is the lack of fully understanding enough about hexadecimal and how it relates to color to solve it on my own.
回答1:
You can use this Alpha Blending algorithm from wikipedia:
来源:https://stackoverflow.com/questions/14127060/what-code-would-i-use-to-get-the-hex-value-of-a-color-when-an-alpha-at-about-hal