Add constructor with int-alpha (0-255)

This commit is contained in:
Lukas Rieger (Blue) 2022-10-10 18:00:59 +02:00
parent 3bbf92965d
commit 49b51f400d
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2

View File

@ -77,6 +77,15 @@ public Color(int i, float alpha) {
this((i >> 16) & 0xFF, (i >> 8) & 0xFF, i & 0xFF, alpha);
}
/**
* Creates a new color from the given integer in the format 0xRRGGBB.
* @param i the integer to create the color from
* @param alpha the alpha value in range 0-255
*/
public Color(int i, int alpha) {
this((i >> 16) & 0xFF, (i >> 8) & 0xFF, i & 0xFF, (float) alpha / 255f);
}
/**
* The value can be an integer in String-Format (see {@link #Color(int)}) or a string in hexadecimal format
* prefixed with # <i>(css-style: e.g. <code>#f16</code> becomes <code>#ff1166</code>)</i>.