Skip to content

Instantly share code, notes, and snippets.

@piruin
Created October 14, 2017 04:41
Show Gist options
  • Save piruin/e9ece705de33e7af618a5ad3649d1668 to your computer and use it in GitHub Desktop.
Save piruin/e9ece705de33e7af618a5ad3649d1668 to your computer and use it in GitHub Desktop.

Hex Opacity Values

  • 100% — FF
  • 95% — F2
  • 90% — E6
  • 85% — D9
  • 80% — CC
  • 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
for (double i = 1; i >= 0; i -= 0.01) {
i = Math.round(i * 100) / 100.0d;
int alpha = (int) Math.round(i * 255);
String hex = Integer.toHexString(alpha).toUpperCase();
if (hex.length() == 1)
hex = "0" + hex;
int percent = (int) (i * 100);
System.out.println(String.format("%d%% — %s", percent, hex));
}
//https://stackoverflow.com/a/25170174
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment