public static int hex(String hex){
  if (hex.charAt(0) == HEX_PREFIX)   hex=hex.substring(1);
  if (hex.length() > 6) {
    int rgb=Integer.parseInt(hex.substring(2),16);
    int alpha=Integer.parseInt(hex.substring(0,2),16);
    return ColorLib.setAlpha(rgb,alpha);
  }
 else {
    return setAlpha(Integer.parseInt(hex,16),255);
  }
}

public static int hex ( String hex ) { if ( hex . charAt ( 0 ) == HEX_PREFIX ) hex = hex . substring ( 1 ) ; if ( hex . length ( ) > 6 ) { int rgb = Integer . parseInt ( hex . substring ( 2 ) , 16 ) ; int alpha = Integer . parseInt ( hex . substring ( 0 , 2 ) , 16 ) ; return ColorLib . setAlpha ( rgb , alpha ) ; } else { return setAlpha ( Integer . parseInt ( hex , 16 ) , 255 ) ; } }
parse a hexadecimal string as a color code . the color convention is the same as that used in webpages , with two - decimal hexadecimal numbers representing rgb color values in the range 0 - 255 . a single ' # ' character may be included at the beginning of the string , but is not required . for example ' # 000000 ' is black , ' ffffff ' is white , ' 0000ff ' is blue , and ' # ffff00 ' is orange . color values may also include transparency ( alpha ) values , ranging from 00 ( fully transparent ) to ff ( fully opaque ) . if included , alpha values should come first in the string . for example , " # 770000ff " is a translucent blue .
