Created
October 20, 2017 04:12
-
-
Save isu3ru/153486f3dbc816b0dd2bea18341a8668 to your computer and use it in GitHub Desktop.
Java code to get each hexadecimal value from 100% to 0% alpha
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment