Class ColorUtils
java.lang.Object
com.blackrook.gui.struct.ColorUtils
Some utility methods for mixing ARGB colors.
- Author:
- Matthew Tropiano
-
Method Summary
Modifier and TypeMethodDescriptionstatic intargbAddScaledIncomingAlpha(int argbSource, int argbIncoming) Adds two colors, with the addition scaled by the incoming color's alpha component.static intargbAlpha(int argbSource, int argbIncoming) Mixes two colors scaled by the incoming color's alpha component.static intargbColor(float red, float green, float blue, float alpha) Converts a componentized color to an ARGB integer.static intargbHSLA(float hue, float saturation, float luminance, float alpha) Converts a hue-saturation-lightness-alpha color to an ARGB integer.static intargbMix(int argbSource, int argbIncoming, int scalar) Mixes two ARGB values linearly.static intargbMultiplyScaledIncomingAlpha(int argbSource, int argbIncoming) Multiply-blends two colors together, with the multiplication scaled by the incoming color's alpha component.static intargbSubtractScaledIncomingAlpha(int argbSource, int argbIncoming) Subtracts the incoming color from the source, with the subtraction scaled by the incoming color's alpha component.
-
Method Details
-
argbColor
public static int argbColor(float red, float green, float blue, float alpha) Converts a componentized color to an ARGB integer.- Parameters:
red- the red channel scalar (0 to 1).green- the green channel scalar (0 to 1).blue- the blue channel scalar (0 to 1).alpha- the alpha scalar (0 to 1).- Returns:
- the resultant integer.
-
argbHSLA
public static int argbHSLA(float hue, float saturation, float luminance, float alpha) Converts a hue-saturation-lightness-alpha color to an ARGB integer.- Parameters:
hue- the color hue (in radians).saturation- the saturation scalar (0 to 1).luminance- the luminance scalar (0 to 1).alpha- the alpha scalar (0 to 1).- Returns:
- the resultant ARGB integer.
-
argbMix
public static int argbMix(int argbSource, int argbIncoming, int scalar) Mixes two ARGB values linearly.- Parameters:
argbSource- the source ARGB color.argbIncoming- the destination ARGB color.scalar- transition scalar: 0 to 255. 128 is 50/50.- Returns:
- the resultant ARGB color.
-
argbAlpha
public static int argbAlpha(int argbSource, int argbIncoming) Mixes two colors scaled by the incoming color's alpha component.- Parameters:
argbSource- the source ARGB color.argbIncoming- the destination ARGB color.- Returns:
- the resultant ARGB color.
-
argbAddScaledIncomingAlpha
public static int argbAddScaledIncomingAlpha(int argbSource, int argbIncoming) Adds two colors, with the addition scaled by the incoming color's alpha component.- Parameters:
argbSource- the source ARGB color.argbIncoming- the destination ARGB color.- Returns:
- the resultant ARGB color.
-
argbSubtractScaledIncomingAlpha
public static int argbSubtractScaledIncomingAlpha(int argbSource, int argbIncoming) Subtracts the incoming color from the source, with the subtraction scaled by the incoming color's alpha component.- Parameters:
argbSource- the source ARGB color.argbIncoming- the destination ARGB color.- Returns:
- the resultant ARGB color.
-
argbMultiplyScaledIncomingAlpha
public static int argbMultiplyScaledIncomingAlpha(int argbSource, int argbIncoming) Multiply-blends two colors together, with the multiplication scaled by the incoming color's alpha component.- Parameters:
argbSource- the source ARGB color.argbIncoming- the destination ARGB color.- Returns:
- the resultant ARGB color.
-