Returns a string representation of the color.
 This is usually the color's hex value,
 but if the color has a name that's used instead.

 @return [String] The string representation
352840
def to_s(opts = {})
      return smallest if options[:style] == :compressed
      return representation if representation

      # IE10 doesn't properly support the color name "transparent", so we emit
      # generated transparent colors as rgba(0, 0, 0, 0) in favor of that. See
      # #1782.
      return rgba_str if Number.basically_equal?(alpha, 0)
      return name if name
      alpha? ? rgba_str : hex_str
    end
1315758
def stringify(self):
        
        hexcode = "#"
        for x in self.value:
            part = hex(x)[2:]
            if len(part) < 2: part = "0" + part
            hexcode += part
        return hexcode
390379
def _hex_to_rgb(color: str) -> Tuple[int, ...]:
        
        if color.startswith('#'):
            color = color.lstrip('#')
        return tuple(int(color[i:i + 2], 16) for i in (0, 2, 4))
405199
def color_to_rgb(color):
        
        if isinstance(color, tuple):
            return color
        if color.startswith('#'):
            try:
                return webcolors.hex_to_rgb(color)
            except ValueError:
                raise InvalidColor(color)

        try:
            return webcolors.name_to_rgb(color)
        except ValueError:
            raise InvalidColor(color)
314843
def uncolor(string = nil, &block)
      if block_given?
        block.call.to_str.gsub(ANSI_REGEX, '')
      elsif string.respond_to?(:to_str)
        string.to_str.gsub(ANSI_REGEX, '')
      elsif respond_to?(:to_str)
        to_str.gsub(ANSI_REGEX, '')
      else
        ''
      end
    end
966070
public static Color nameToColor(String strColor)
    {
        final Object[][] obj = {
            {"black", Color.black},
            {"blue", Color.blue},
            {"cyan", Color.cyan},
            {"darkGray", Color.darkGray},
            {"gray", Color.gray},
            {"green", Color.green},
            {"lightGray", Color.lightGray},
            {"magenta", Color.magenta},
            {"orange", Color.orange},
            {"pink", Color.pink},
            {"red", Color.red},
            {"white", Color.white},
            {"yellow", Color.yellow}
        };      // Not static, because this method is usually not called.
        for (int i = 0; i < obj.length; i++)
        {
            if (strColor.equalsIgnoreCase((String)obj[i][0]))
                return (Color)obj[i][1];
        }
        try {
            return Color.decode(strColor);
        } catch (NumberFormatException ex)  {
        }
        return null;
    }
1308544
def running_as_string(self, add_colour=True):
        '''

        '''
        with self._mutex:
            if self.running:
                result = 'Running', ['bold', 'green']
            else:
                result = 'Stopped', ['reset']
        if add_colour:
            return utils.build_attr_string(result[1], supported=add_colour) + \
                    result[0] + utils.build_attr_string('reset', supported=add_colour)
        else:
            return result[0]
762835
public String getColorString() {

        StringBuffer result = new StringBuffer();
        if (m_color == Simapi.COLOR_TRANSPARENT) {
            result.append(COLOR_TRANSPARENT);
        } else {
            if (m_color.getRed() < 16) {
                result.append('0');
            }
            result.append(Integer.toString(m_color.getRed(), 16));
            if (m_color.getGreen() < 16) {
                result.append('0');
            }
            result.append(Integer.toString(m_color.getGreen(), 16));
            if (m_color.getBlue() < 16) {
                result.append('0');
            }
            result.append(Integer.toString(m_color.getBlue(), 16));
        }
        return result.toString();
    }
1243376
function getColorStr(color) {
    var hex = color.hexString();
    var alpha = getAlphaHex(color.alpha());
    var colorStr = '#' + alpha + hex.slice(1);

    return colorStr.toLowerCase();
}
756476
def hex_color(a)
      case a
      when FIXNUM_COL
        Java::Monkstone::ColorUtil.colorLong(a)
      when STRING_COL
        return Java::Monkstone::ColorUtil.colorString(a) if a =~ /#\h+/
        raise StandardError, 'Dodgy Hexstring'
      when FLOAT_COL
        Java::Monkstone::ColorUtil.colorDouble(a)
      else
        raise StandardError, 'Dodgy Color Conversion'
      end
    end
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;
	}
1017371
function ( color ) {
            var type = this.type( color, 'color.toHex() : "' + color + '" ' + MSG_NOT_COLOR );
    
            switch ( type ) {
                case 'hex':
                    return color;
                    break;
                case 'rgb':
                case 'rgba':
                    return this.rgbToHex( color );
                    break;
                case 'hsl':
                case 'hsla':
                    color = this.hslToRgb( color );
                    return this.rgbToHex( color );
                    break;
                case 'keyword':
                    return this.keyword( color, 'color.toHex() : "' + color + '" ' + MSG_NOT_COLOR );
                    break;
            }
        }
624724
def hex_color(self, safe: bool = False) -> str:
        
        if safe:
            return self.random.choice(SAFE_COLORS)

        return '#{:06x}'.format(
            self.random.randint(0x000000, 0xffffff))
874848
def rgb_color(self, safe: bool = False) -> Tuple[int, ...]:
        
        color = self.hex_color(safe)
        return self._hex_to_rgb(color)
1268974
def rgb_tuple_from_str(color_string):
    
    try:
        # English color names (limited)
        rgb_string = common_html_colors[color_string]
        return tuple([float(x) for x in re.findall(r'\d{1,3}', rgb_string)]) 
    
    except KeyError:
        try:
            # HEX color code
            hex_string = color_string.lstrip('#')
            return tuple(int(hex_string[i:i+2], 16) for i in (0, 2 ,4))
        
        except ValueError:
            # RGB or RGBA formatted strings
            return tuple([int(x) if float(x) > 1 else float(x) 
                          for x in re.findall(r"[-+]?\d*\.*\d+", color_string)])
881117
def _convert_tuple_color_to_hex(cls, color):
        
        if isinstance(color, tuple):
            return '#{:02x}{:02x}{:02x}'.format(*color)
        elif isinstance(color, str):
            if not color.startswith('#'):
                return '#{color_hex}'.format(color_hex=color)
            else:
                return color
        else:
            return '#000'
101920
static String getHex(Color color) {
        return String.format("#%02x%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
    }