博文地址

baiqiantaobaiqiantaobqt20094[email protected]

目录

透明度中百分比与十六进制的对应关系

计算代码

private static String getHexString(int i) {
float temp = 255 * i * 1.0f / 100f;
int round = Math.round(temp); //四舍五入
String hexString = Integer.toHexString(round);
if (hexString.length() < 2) {
hexString = "0" + hexString; //原博文此处是错的
}
return hexString.toUpperCase();
}

输出列表格式

private static void listFormat() {
System.out.println("-------透明度百分比对应的十六进制-------");
for (int i = 0; i <= 100; i++) {
System.out.println("百分比:" + i + "%" + "\t十六进制:" + getHexString(i));
}
}

输出markdown格式

private static void markdownFormat() {
System.out.println("-------透明度百分比对应的十六进制-------");
for (int i = 0; i <= 9; i++) {
StringBuilder transparency = new StringBuilder();
StringBuilder percent = new StringBuilder();
int value = 10 * i;
for (int j = 0; j <= 9; j++) {
transparency.append("|").append(" ").append(getHexString(value)).append(" ");
percent.append("|").append(" ").append(value++).append("%").append(" ");
}
percent.append("|").append("\n").append(transparency).append("|");
System.out.println(percent.toString());
}
}

对应关系表

0%1%2%3%4%5%6%7%8%9%
000305080A0D0F121417
10%11%12%13%14%15%16%17%18%19%
1A1C1F212426292B2E30
20%21%22%23%24%25%26%27%28%29%
3336383B3D404245474A
30%31%32%33%34%35%36%37%38%39%
4D4F525457595C5E6163
40%41%42%43%44%45%46%47%48%49%
66696B6E707375787A7D
50%51%52%53%54%55%56%57%58%59%
808285878A8C8F919496
60%61%62%63%64%65%66%67%68%69%
999C9EA1A3A6A8ABADB0
70%71%72%73%74%75%76%77%78%79%
B3B5B8BABDBFC2C4C7C9
80%81%82%83%84%85%86%87%88%89%
CCCFD1D4D6D9DBDEE0E3
90%91%92%93%94%95%96%97%98%99%
E6E8EBEDF0F2F5F7FAFC

2019-6-30

05-23 10:59