Package cn.mapway.ui.client.util
Class Colors
- java.lang.Object
-
- cn.mapway.ui.client.util.Colors
-
public class Colors extends Object
Colors 颜色处理- Author:
- zhangjianshe@gmail.com
-
-
Field Summary
Fields Modifier and Type Field Description static StringCOLOR_BLACKstatic StringCOLOR_BLUEstatic StringCOLOR_GREENstatic StringCOLOR_REDstatic StringCOLOR_YELLOW
-
Constructor Summary
Constructors Constructor Description Colors()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static inta(int color)static intb(int color)static StringbytesToRGB(byte[] rgb)static Stringcolor(int index)static intcolorFromBytes(byte[] rgba)static byte[]fromColor(String fillColor)from #AABBCC to bytesstatic intfromColorByte(byte r, byte g, byte b, byte a)static intfromColorInt(int r, int g, int b, int a)static intfromHex(String colorHex)将 #RRGGBBAA -> int color valuestatic byte[]fromRgba(String color)static intfromRGBA(String rgbaColor)static intg(int color)static int[]hsv2rgb(double hue, double saturation, double value)static Stringindex(int i)static intinvertColor(int color, boolean bw)不处理透明度信息static StringinvertColor(String color, boolean bw)static voidmain(String[] args)static IntegerparseAlpha(String value)// 用户输入了 78% -> 0.78*255 // 用户输入了 78 -> 78 // .......static intr(int color)static StringrandomBasicColor()static StringrandomColor()static double[]rgb2hsv(int r, int g, int b)static intsetA(int color, int red)static intsetB(int color, int red)static intsetG(int color, int red)static intsetR(int color, int red)static byte[]toBytes(int color)static StringtoColor(byte[] singleColor)static StringtoHex(String bgColor)颜色转换 rgb(12,12,12) -> #112233static StringtoHexRGBA(int color, boolean withAlpha)int to #RRGGBB(AA)static StringtoRGB(int[] rgb)static StringtoRGBA(byte[] singleColor)static StringtoRGBA(int color)int color 0xRRGGBBAA => rgba(RR,GG,BB,AA/255)
-
-
-
Field Detail
-
COLOR_BLACK
public static final String COLOR_BLACK
- See Also:
- Constant Field Values
-
COLOR_RED
public static final String COLOR_RED
- See Also:
- Constant Field Values
-
COLOR_YELLOW
public static final String COLOR_YELLOW
- See Also:
- Constant Field Values
-
COLOR_BLUE
public static final String COLOR_BLUE
- See Also:
- Constant Field Values
-
COLOR_GREEN
public static final String COLOR_GREEN
- See Also:
- Constant Field Values
-
-
Method Detail
-
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)
-
-