颜色的十六进制透明度 [英] Hex transparency in colors
问题描述
我正在为我的应用小部件实现小部件透明度选项,尽管我在正确获取十六进制颜色值时遇到了一些问题.我对十六进制颜色透明度完全陌生,尽管我找不到我的问题的具体答案,但我四处搜索了一下.
I'm working on implementing a widget transparency option for my app widget although I'm having some trouble getting the hex color values right. Being completely new to hex color transparency I searched around a bit although I couldn't find a specific answer to my question.
我想通过十六进制颜色设置透明度,所以假设我的十六进制颜色 ID 为#33b5e5",我希望它的透明度为 50%.然后我将使用#8033b5e5",因为 80 是 50%.
I want to set transparency by hex color so let's say my hex color id "#33b5e5" and I want it to be 50% transparent. Then I'll use "#8033b5e5" because 80 is 50%.
我在这里找到了一个有用的图表:http://www.dtp-aus.com/hexadeci.htm .有了这些数据,我设法想出了这个:
I found a useful chart here: http://www.dtp-aus.com/hexadeci.htm . With this data I managed to come up with this:
0% = #00
10% = #16
20% = #32
30% = #48
40% = #64
50% = #80
60% = #96
70% = #112
80% = #128
90% = #144
现在,当我的十六进制值高于 100 时,问题开始出现.十六进制颜色代码只能是 8 个符号长对吗?例如 #11233b5e5 (80%) 崩溃.
Now the issues start appearing when I get higher than 100 in hex. Hex color codes can only be 8 symbols long right? For example #11233b5e5 (80%) crashes.
我该怎么做才能使用更高的数字?
What can I do to enable me to use the higher numbers aswell?
推荐答案
这是一个正确的百分数到十六进制值的表格.例如.对于 50% 的白色,您可以使用 #80FFFFFF.
Here's a correct table of percentages to hex values. E.g. for 50% white you'd use #80FFFFFF.
- 100% — FF
- 95% — F2
- 90% — E6
- 85% — D9
- 80% — 抄送
- 75% — BF
- 70% — B3
- 65% — A6
- 60% — 99
- 55% — 8C
- 50% — 80
- 45% — 73
- 40% — 66
- 35% — 59
- 30% — 4D
- 25% — 40
- 20% — 33
- 15% — 26
- 10% — 1A
- 5% — 0D
- 0% — 00
(来源)
这篇关于颜色的十六进制透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!