Class Colors

java.lang.Object
cn.mapway.ui.client.util.Colors

public class Colors extends Object
Colors 颜色处理
Author:
zhangjianshe@gmail.com
  • Field Details

  • Constructor Details

    • Colors

      public Colors()
  • Method Details

    • randomBasicColor

      public static String randomBasicColor()
    • randomColor

      public static String randomColor()
    • color

      public static String color(int index)
    • toHex

      public static String toHex(String bgColor)
      颜色转换 rgb(12,12,12) -> #112233
      Parameters:
      bgColor -
      Returns:
    • toHexRGBA

      public static String toHexRGBA(int color, boolean withAlpha)
      int to #RRGGBB(AA)
      Parameters:
      color -
      withAlpha -
      Returns:
    • fromHex

      public static int fromHex(String colorHex)
      将 #RRGGBBAA -> int color value
      Parameters:
      colorHex -
      Returns:
    • hsv2rgb

      public static int[] hsv2rgb(double hue, double saturation, double value)
    • rgb2hsv

      public static double[] rgb2hsv(int r, int g, int b)
    • toRGB

      public static String toRGB(int[] rgb)
    • bytesToRGB

      public static String bytesToRGB(byte[] rgb)
    • index

      public static String index(int i)
    • invertColor

      public static String invertColor(String color, boolean bw)
      Parameters:
      color - #FF00EE
      Returns:
    • invertColor

      public static int invertColor(int color, boolean bw)
      不处理透明度信息
      Parameters:
      color -
      bw -
      Returns:
    • fromRgba

      public static byte[] fromRgba(String color)
    • toColor

      public static String toColor(byte[] singleColor)
    • toRGBA

      public static String toRGBA(byte[] singleColor)
    • fromRGBA

      public static int fromRGBA(String rgbaColor)
    • toRGBA

      public static String toRGBA(int color)
      int color 0xRRGGBBAA => rgba(RR,GG,BB,AA/255)
      Parameters:
      color -
      Returns:
    • toBytes

      public static byte[] toBytes(int color)
    • main

      public static void main(String[] args)
    • fromColor

      public static byte[] fromColor(String fillColor)
      from #AABBCC to bytes
      Parameters:
      fillColor -
      Returns:
    • r

      public static int r(int color)
    • g

      public static int g(int color)
    • b

      public static int b(int color)
    • a

      public static int a(int color)
    • colorFromBytes

      public static int colorFromBytes(byte[] rgba)
    • fromColorInt

      public static int fromColorInt(int r, int g, int b, int a)
    • fromColorByte

      public static int fromColorByte(byte r, byte g, byte b, byte a)
    • setR

      public static int setR(int color, int red)
    • setG

      public static int setG(int color, int red)
    • setB

      public static int setB(int color, int red)
    • setA

      public static int setA(int color, int red)
    • parseAlpha

      public static Integer parseAlpha(String value)
      // 用户输入了 78% -> 0.78*255 // 用户输入了 78 -> 78 // ....... >255 -> 255 // ....... <0 -> 0
      Parameters:
      value - 可以使 AA% 也可以是 [0-255]之间的值
      Returns:
      [0-255]之间的值