Class PackColor

java.lang.Object
com.badlogic.gdx.graphics.Color
com.prineside.tdi2.utils.PackColor

public class PackColor extends Color
  • Constructor Details

    • PackColor

      public PackColor()
    • PackColor

      public PackColor(Color from)
    • PackColor

      public PackColor(int from)
  • Method Details

    • isArray

      public boolean isArray()
    • getColorArray

      public Array<Color> getColorArray()
    • getColorAtIndex

      public Color getColorAtIndex(int idx)
    • from

      public PackColor from(PackColor color)
    • toString

      public String toString()
      Description copied from class: com.badlogic.gdx.graphics.Color
      Returns the color encoded as hex string with the format RRGGBBAA.
      Overrides:
      toString in class Color
    • parseColorConfigArray

      public static PackColor parseColorConfigArray(String[] colorCfg, ObjectMap<String,PackColor> colorVars) throws PackColor.ColorConfigFormatException
      Parse array of PackColors from array of strings
      Parameters:
      colorCfg - array of string, similar to those you'd pass to the method with a single string
      colorVars - 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

      public static PackColor fromColors(Color... colors)
    • parseColorConfig

      public static PackColor parseColorConfig(String colorCfg, ObjectMap<String,PackColor> colorVars) throws PackColor.ColorConfigFormatException
      Parse 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.ColorConfigFormatException
      Parse 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 color
      colorVars - 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

      public static boolean isLooksLikeColorValue(String value)
      Returns:
      true if it looks like a color configuration and can be passed to parseColorValue() Note: does not guarantee it is a correct configuration