Package com.prineside.tdi2.utils
Class PackColor
java.lang.Object
com.badlogic.gdx.graphics.Color
com.prineside.tdi2.utils.PackColor
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class com.badlogic.gdx.graphics.Color
a, b, BLACK, BLUE, BROWN, CHARTREUSE, CLEAR, CLEAR_WHITE, CORAL, CYAN, DARK_GRAY, FIREBRICK, FOREST, g, GOLD, GOLDENROD, GRAY, GREEN, LIGHT_GRAY, LIME, MAGENTA, MAROON, NAVY, OLIVE, ORANGE, PINK, PURPLE, r, RED, ROYAL, SALMON, SCARLET, SKY, SLATE, TAN, TEAL, VIOLET, WHITE, WHITE_FLOAT_BITS, YELLOW
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PackColor
fromColors
(Color... colors) getColorAtIndex
(int idx) boolean
isArray()
static boolean
isLooksLikeColorValue
(String value) static PackColor
parseColorConfig
(String colorCfg, ObjectMap<String, PackColor> colorVars) Parse color configuration with optional color modifiers.static PackColor
parseColorConfigArray
(String[] colorCfg, ObjectMap<String, PackColor> colorVars) Parse array of PackColors from array of stringsstatic Color
parseColorValue
(String colorCfg, ObjectMap<String, PackColor> colorVars) Parse single color value without modifiers.toString()
Returns the color encoded as hex string with the format RRGGBBAA.Methods inherited from class com.badlogic.gdx.graphics.Color
abgr8888ToColor, abgr8888ToColor, add, add, alpha, argb8888, argb8888, argb8888ToColor, clamp, cpy, equals, fromHsv, fromHsv, hashCode, lerp, lerp, luminanceAlpha, mul, mul, mul, premultiplyAlpha, rgb565, rgb565, rgb565ToColor, rgb888, rgb888, rgb888ToColor, rgba4444, rgba4444, rgba4444ToColor, rgba8888, rgba8888, rgba8888ToColor, set, set, set, set, sub, sub, toFloatBits, toFloatBits, toFloatBits, toHsv, toIntBits, toIntBits, valueOf, valueOf
-
Constructor Details
-
PackColor
public PackColor() -
PackColor
-
PackColor
public PackColor(int from)
-
-
Method Details
-
isArray
public boolean isArray() -
getColorArray
-
getColorAtIndex
-
from
-
toString
Description copied from class:com.badlogic.gdx.graphics.Color
Returns the color encoded as hex string with the format RRGGBBAA. -
parseColorConfigArray
public static PackColor parseColorConfigArray(String[] colorCfg, ObjectMap<String, PackColor> colorVars) throws PackColor.ColorConfigFormatExceptionParse array of PackColors from array of strings- Parameters:
colorCfg
- array of string, similar to those you'd pass to the method with a single stringcolorVars
- color variables used to replace color links in config- Returns:
- PackColor with array of colors. If used as a single color, the first color from the array will be used
- Throws:
PackColor.ColorConfigFormatException
-
fromColors
-
parseColorConfig
public static PackColor parseColorConfig(String colorCfg, ObjectMap<String, PackColor> colorVars) throws PackColor.ColorConfigFormatExceptionParse color configuration with optional color modifiers. Modifiers are chained with '>' character. If no modifiers specified, color will be parsed with regular parseColorValue(). Color channel values will be clamped in case some modifier exceeds channel range. Ranges such as [0..1] are for reference, you are not limited to use values only in this range. Modifiers: + (r,g,b,a) | + (v) | + (colorValue) - add ([0..1]) channels / value / other color. For example, + (1,0,0,0) or + (rgb(255,0,0,0)) - (r,g,b,a) | - (v) | - (colorValue) - subtract ([0..1]) channels / value / other color. For example, - (1,0,0,0) or - (rgb(255,0,0,0)) * (r,g,b,a) | * (v) | * (colorValue) - multiply ([0..1]) by channels / value / other color. For example, * (1,0,0,0) or * (rgb(255,0,0,0)) l (colorValue, v) - interpolate (lerp) ([0..1]) with some other color. For example, l (!RED.P500, 0.75). Upper or lower-case L can be used. r (v) | g (v) | b (v) | a (v) - set red / green / blue / alpha channel value in range [0..1]. For example, r (0.75). Upper or lower-case R / G / B / A can be used. h (d) - hue-rotate the color by some value in degrees [0..360]. For example, h (180) to get an 'opposite' color (red to green etc). Upper or lower-case H can be used. s+ (v) | s- (v) | s* (v) | s/ (v) - add / subtract / multiply / divide saturation value [0..1] of the color v+ (v) | v- (v) | v* (v) | v/ (v) - add / subtract / multiply / divide brightness ('value') value [0..1] of the color Examples: $text > a(0.56) !BLUE.P300 > *(1.0, 0.56, 0.0, 1.0) hsv(255,0.5,0.7,0.28) > *(#FF9900FF) > -(1,0,0,0)- Parameters:
colorCfg
-colorVars
-- Returns:
- parsed and modified color or throws exception if failed to parse
- Throws:
PackColor.ColorConfigFormatException
-
parseColorValue
public static Color parseColorValue(String colorCfg, ObjectMap<String, PackColor> colorVars) throws PackColor.ColorConfigFormatExceptionParse single color value without modifiers. - $colorName - use color named 'colorName' from colorVars - !NAME.VARIANT - use color from ColorPalette, such as !RED.P500. Additional colors are !WHITE (=#FFFFFFFF), !BLACK (=#000000FF), !TRANSPARENT (=#00000000) - #RRGGBB / #RRGGBBAA - color from regular RGB/RGBA notation, such as #FF990080 - hsv(255, 0.5, 0.5) / hsv(255, 0.5, 0.5, 0.75) - hue [0..255], saturation [0..1], value [0..1], alpha (optional) [0..1] - raw(0.5, 1.0, 0.5) / raw(0.5, 1.0, 0.5, 0.75) - raw color values for r, g, b, a (optional) [0..1] - rgb(255, 255, 255) / rgb(255, 255, 255, 1.0) - same as raw() but in [0..255] range, alpha (optional) is in [0..1] range- Parameters:
colorCfg
- string representation of the colorcolorVars
- map of color variables to be used in case of $colorName- Returns:
- parsed color or null if format is not recognized
- Throws:
PackColor.ColorConfigFormatException
-
isLooksLikeColorValue
- Returns:
- true if it looks like a color configuration and can be passed to parseColorValue() Note: does not guarantee it is a correct configuration
-