Shorthand the hex single color if possible

@param color
hex single color
@return shorthand hex color or original value
492754
public static String shorthandHexSingle(String color) {
		validateHexSingle(color);
		if (color.length() > 1
				&& Character.toUpperCase(color.charAt(0)) == Character
						.toUpperCase(color.charAt(1))) {
			color = color.substring(0, 1);
		}
		return color;
	}
826017
@ColorInt
    public static int opaqueColor(@ColorInt int color) {
        int alpha = Color.alpha(color);
        if (alpha == 0) return color;
        int red = Color.red(color);
        int green = Color.green(color);
        int blue = Color.blue(color);
        return Color.argb(255, red, green, blue);
    }
368224
private static String getHexSingle(String hex, int colorIndex) {
		validateHex(hex);

		if (hex.startsWith("#")) {
			hex = hex.substring(1);
		}

		int colorCharacters = 1;
		int numColors = hex.length();
		if (numColors > 4) {
			colorCharacters++;
			numColors /= 2;
		}

		String color = null;
		if (colorIndex >= 0 || numColors > 3) {
			if (numColors > 3) {
				colorIndex++;
			}
			int startIndex = colorIndex;
			if (colorCharacters > 1) {
				startIndex *= 2;
			}
			color = hex.substring(startIndex, startIndex + colorCharacters);
			color = expandShorthandHexSingle(color);
		}

		return color;
	}
397809
public static int toRGB(String color) {
		validateHexSingle(color);
		if (color.length() == 1) {
			color += color;
		}
		return Integer.parseInt(color, 16);
	}
559726
protected function _prepColor($color) {
		if (strpos($color, '#') !== false) {
			return str_replace('#', '0x', $color);
		}
		if (is_numeric($color)) {
			return '0x' . $color;
		}
		return $color;
	}
840674
public static String expandShorthandHex(String color) {
		validateHex(color);
		if (color.length() < 6) {
			StringBuilder expandColor = new StringBuilder();
			int startIndex = 0;
			if (color.startsWith("#")) {
				expandColor.append("#");
				startIndex++;
			}
			for (; startIndex < color.length(); startIndex++) {
				String expand = expandShorthandHexSingle(color.substring(
						startIndex, startIndex + 1));
				expandColor.append(expand);
			}
			color = expandColor.toString();
		}
		return color;
	}
67302
public static String toHex(Color color) {
		String R = Integer.toHexString(color.getRed());
		R = R.length() < 2 ? ('0' + R) : R;
		String G = Integer.toHexString(color.getGreen());
		G = G.length() < 2 ? ('0' + G) : G;
		String B = Integer.toHexString(color.getBlue());
		B = B.length() < 2 ? ('0' + B) : B;
		return '#' + R + G + B;
	}
716432
function parseColor (str) {
    if (str.substr(0,1) === '#') {
      // Handle color shorthands (like #abc)
      var shorthand = str.length === 4,
          m = str.match(shorthand ? /\w/g : /\w{2}/g);

      if (!m) return;
      m = m.map(function(s) { return parseInt(shorthand ? s+s : s, 16) });
      return new nodes.RGBA(m[0],m[1],m[2],1);
    }
    else if (str.substr(0,3) === 'rgb'){
      var m = str.match(/([0-9]*\.?[0-9]+)/g);
      if (!m) return;
      m = m.map(function(s){return parseFloat(s, 10)});
      return new nodes.RGBA(m[0], m[1], m[2], m[3] || 1);
    }
    else {
      var rgb = colors[str];
      if (!rgb) return;
      return new nodes.RGBA(rgb[0], rgb[1], rgb[2], 1);
    }
  }
903240
@CheckReturnValue
    public RoleAction setColor(Color color)
    {
        return this.setColor(color != null ? color.getRGB() : null);
    }
101079
public static String toRGB(Color color) {
		if(color != null) {
			return "rgb(" + Integer.toString(color.getRed()) + "," + Integer.toString(color.getGreen()) + "," + Integer.toString(color.getBlue()) + ")"; 
		}
		return null;
	}
150549
public static function Hex2Rgb( string $color )
   {

      if ( $color[ 0 ] == '#' )
      {
         $color = \substr( $color, 1 );
      }

      if ( \strlen( $color ) == 8 )
      {
         $color = \substr( $color, 2 );
      }

      if ( \strlen( $color ) == 6 )
      {
         $r = $color[ 0 ] . $color[ 1 ];
         $g = $color[ 2 ] . $color[ 3 ];
         $b = $color[ 4 ] . $color[ 5 ];
      }
      else if ( \strlen( $color ) == 3 )
      {
         $r = $color[ 0 ] . $color[ 0 ];
         $g = $color[ 1 ] . $color[ 1 ];
         $b = $color[ 2 ] . $color[ 2 ];
      }
      else if ( \strlen( $color ) == 2 )
      {
         $r = $color;
         $g = $color;
         $b = $color;
      }
      else
      {
         return false;
      }

      return [ \hexdec( $r ), \hexdec( $g ), \hexdec( $b ) ];

   }
561974
public function setColor($color)
	{
		if (is_array($color))
		{
			$this->color[0] = $color[0];
			$this->color[1] = $color[1];
			$this->color[2] = $color[2];
		}
		else
		{
			if (false !== strpos($color, '#'))
			{
				$color = substr($color, 1);
			}
			$this->color[0] = hexdec(substr($color, 0, 2));
			$this->color[1] = hexdec(substr($color, 2, 2));
			$this->color[2] = hexdec(substr($color, 4, 2));
		}

		return $this;
	}
1312347
protected String colorString(PDColor pdcolor)
    {
        String color = null;
        try
        {
            float[] rgb = pdcolor.getColorSpace().toRGB(pdcolor.getComponents());
            color = colorString(rgb[0], rgb[1], rgb[2]);
        } catch (IOException e) {
            log.error("colorString: IOException: {}", e.getMessage());
        } catch (UnsupportedOperationException e) {
            log.error("colorString: UnsupportedOperationException: {}", e.getMessage());
        }
        return color;
    }
681497
public String selectColor(List<String> colors) {
        String tr="transparent";
        for (String c: colors) {
            if (!(c.equals(tr))) return c;
        }
        return tr;
    }
352785
public function getRgbaHexString(Color $color)
    {
        $alpha = dechex(255 * $color->alpha);
        return '#' . $color->hex . $alpha;
    }
217347
public static RgbaColor fromHex(String hex) {
        if (hex.length() == 0 || hex.charAt(0) != '#') return getDefaultColor();

        // #rgb
        if (hex.length() == 4) {

            return new RgbaColor(parseHex(hex, 1, 2),
                                 parseHex(hex, 2, 3),
                                 parseHex(hex, 3, 4));

        }
        // #rrggbb
        else if (hex.length() == 7) {

            return new RgbaColor(parseHex(hex, 1, 3),
                                 parseHex(hex, 3, 5),
                                 parseHex(hex, 5, 7));

        }
        else {
            return getDefaultColor();
        }
    }
597799
function() {
           
            var hex = this.get(this.OPT.HEX),
                l   = hex.length,
                c,i,rgb;

            // support #369 -> #336699 shorthand
            if (l === 3) {
                c = hex.split("");
                for (i=0; i<l; i=i+1) {
                    c[i] = c[i] + c[i];
                }

                hex = c.join("");
            }

            if (hex.length !== 6) {
                this.logger.log(this.get(this.TXT.ILLEGAL_HEX), "error");
                return false;
            }

            rgb = Color.hex2rgb(hex);

            this.logger.log(sub("Hex value set to {hex} ({rgb})", {
                    hex: hex, rgb: rgb
                }));

            this.setValue(rgb);
        }