当应用大约一半透明度的alpha时,我将使用什么代码来获取颜色的十六进制值? [英] What code would I use to get the hex value of a color when an alpha at about half transparency is applied?

查看:790
本文介绍了当应用大约一半透明度的alpha时,我将使用什么代码来获取颜色的十六进制值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个视觉元素(可以是文字或div与颜色填充,无关紧要),颜色设置为黑色, 0x000000 ,它的alpha设置为 .4 .5 ,背景为白色 0xFFFFFF ,结果将为灰色。我们可以在Photoshop中测试。

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

或者类似JavaScript,ActionScript或VBScript:

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.

推荐答案

您可以使用此 Alpha混合算法:


这篇关于当应用大约一半透明度的alpha时,我将使用什么代码来获取颜色的十六进制值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆