Package cn.mapway.ui.client.util
Class Colors
java.lang.Object
cn.mapway.ui.client.util.Colors
Colors
颜色处理
- Author:
- zhangjianshe@gmail.com
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic inta(int color) static intb(int color) static StringbytesToRGB(byte[] rgb) static Stringcolor(int index) static intcolorFromBytes(byte[] rgba) static byte[]from #AABBCC to bytesstatic intfromColorByte(byte r, byte g, byte b, byte a) static intfromColorInt(int r, int g, int b, int a) static int将 #RRGGBBAA -> int color valuestatic byte[]static intstatic 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 voidstatic IntegerparseAlpha(String value) // 用户输入了 78% -> 0.78*255 // 用户输入了 78 -> 78 // .......static intr(int color) static Stringstatic Stringstatic 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 String颜色转换 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 Details
-
COLOR_BLACK
- See Also:
-
COLOR_RED
- See Also:
-
COLOR_YELLOW
- See Also:
-
COLOR_BLUE
- See Also:
-
COLOR_GREEN
- See Also:
-
-
Constructor Details
-
Colors
public Colors()
-
-
Method Details
-
randomBasicColor
-
randomColor
-
color
-
toHex
颜色转换 rgb(12,12,12) -> #112233- Parameters:
bgColor-- Returns:
-
toHexRGBA
int to #RRGGBB(AA)- Parameters:
color-withAlpha-- Returns:
-
fromHex
将 #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
-
bytesToRGB
-
index
-
invertColor
- Parameters:
color- #FF00EE- Returns:
-
invertColor
public static int invertColor(int color, boolean bw) 不处理透明度信息- Parameters:
color-bw-- Returns:
-
fromRgba
-
toColor
-
toRGBA
-
fromRGBA
-
toRGBA
int color 0xRRGGBBAA => rgba(RR,GG,BB,AA/255)- Parameters:
color-- Returns:
-
toBytes
public static byte[] toBytes(int color) -
main
-
fromColor
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
// 用户输入了 78% -> 0.78*255 // 用户输入了 78 -> 78 // ....... >255 -> 255 // ....... <0 -> 0- Parameters:
value- 可以使 AA% 也可以是 [0-255]之间的值- Returns:
- [0-255]之间的值
-