|
|
|
@ -272,7 +272,7 @@ public class WebColors extends HashMap {
|
|
|
|
|
c[k] = parseColorValue(tok.nextToken()); |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
c[3] = parseColorValue(tok.nextToken()); |
|
|
|
|
c[3] = parseAlphaValue(tok.nextToken()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
//alpha 值可写可不写
|
|
|
|
|
} |
|
|
|
@ -287,6 +287,24 @@ public class WebColors extends HashMap {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 转化 alpha 值 |
|
|
|
|
* @param v |
|
|
|
|
* @return 0~ 255 |
|
|
|
|
*/ |
|
|
|
|
public static int parseAlphaValue(String v) { |
|
|
|
|
if (v.endsWith("%")) { |
|
|
|
|
return parseColorValue(v); |
|
|
|
|
} |
|
|
|
|
float r = Float.parseFloat(v) * 255; |
|
|
|
|
if (r < 0) |
|
|
|
|
r = 0; |
|
|
|
|
else if (r > 255) |
|
|
|
|
r = 255; |
|
|
|
|
return (int) r; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 转化 rgb 值 |
|
|
|
|
* @param v |
|
|
|
|
* @return 0~ 255 |
|
|
|
|
*/ |
|
|
|
|