Module: Colorist::ColorNames

Defined in:
lib/colorist/color_names.rb

Constant Summary collapse

COLORS =
{      
   "maroon"  => '#800000',
   "red"     => '#FF0000',
   "orange"  => '#FFA500',
   "yellow"  => '#FFFF00',
   "olive"   => '#808000',
   "purple"  => '#800080',
   "fuchsia" => '#FF00FF',
   "white"   => '#FFFFFF',
   "lime"    => '#00FF00',
   "green"   => '#008000',
   "navy"    => '#000080',
   "blue"    => '#0000FF',
   "aqua"    => '#00FFFF',
   "teal"    => '#008080',
   "black"   => '#000000',
   "silver"  => '#C0C0C0',
   "gray"    => '#808080',      
# 'black' => '#000000',
'midnightblue' => '#000033',
'navy' => '#000080',
'darkblue' => '#00008B',
'newmidnightblue' => '#00009C',
'mediumblue' => '#0000CD',
'pinegreen' => '#003300',
'dumpster' => '#004F00',
'starbucks' => '#006633',
'slateblue' => '#007FFF',
'turquoise4' => '#00868B',
'darkcyan' => '#008B8B',
'deepskyblue3' => '#009ACD',
'deepskyblue' => '#00BFFF',
'emeraldgreen' => '#00C957',
'cyan3' => '#00CDCD',
'green2' => '#00EE00',
'turquoise1' => '#00F5FF',
'springgreen' => '#00FF33',
'seagreen' => '#00FFAA',
'cyan' => '#00FFFF',
'mouthwash' => '#01C5BB',
'manganeseblue' => '#03A89E',
'indiglo' => '#05E9FF',
'gray3' => '#080808',
'police strobe' => '#0BB5FF',
'diamond blue' => '#0EBFE9',
'dodgerblue4' => '#104E8B',
'gray7' => '#121212',
'ulysses butterfly' => '#1464F4',
'dodgerblue3' => '#1874CD',
'alaska sky' => '#1B3F8B',
'dodgerblue2' => '#1C86EE',
'dodgerblue' => '#1E90FF',
'emerald city' => '#20BF9F',
'huntergreen' => '#215E21',
'forestgreen' => '#228B22',
'seagreen' => '#238E68',
'blue spider' => '#26466D',
'cooler' => '#284942',
'gray16' => '#292929',
'blue angels' => '#2B4F81',
'indigo' => '#2E0854',
'lampblack' => '#2E473B',
'midnightblue' => '#2F2F4F',
'darkslategrey' => '#2F4F4F',
'gray19' => '#303030',
'pool table' => '#31B94D',
'limerind' => '#324F17',
'skyblue6' => '#3299CC',
'mediumaquamarine3' => '#32CD99',
'gray20' => '#333333',
'peacock' => '#33A1C9',
'blue corn' => '#344152',
'pacific blue' => '#35586C',
'steelblue4' => '#36648B',
'metallic mint' => '#37FDFC',
'terreverte' => '#385E0F',
'green pepper' => '#397D02',
'royalblue3' => '#3A5FCD',
'dress blue' => '#3B3178',
'romaine lettuce' => '#3B5323',
'blue green algae' => '#3B8471',
'wet moss' => '#3D5229',
'green lantern' => '#3D8B37',
'mediterranean' => '#3E766D',
'clover' => '#3EA055',
'gray25' => '#404040',
'royalblue' => '#4169E1',
'blue jeans' => '#42526C',
'mediumseagreen' => '#426F42',
'royalblue2' => '#436EEE',
'go' => '#43D58C',
'chartreuse4' => '#458B00',
'od green' => '#46523C',
'gray28' => '#474747',
'park ranger' => '#484D46',
'holly' => '#488214',
'blue ridge mtns' => '#4981CE',
'electric turquoise' => '#49E9BD',
'skyblue4' => '#4A708B',
'wales' => '#4AC948',
'bluegrass' => '#4C7064',
'gray30' => '#4D4D4D',
'pollock blue' => '#4D6FAC',
'grass' => '#4DBD33',
'violet' => '#4F2F4F',
'green scrubs' => '#4F8E83',
'blue stone' => '#50729F',
'malta blue' => '#517693',
'blue dog' => '#525C65',
'darkslategray4' => '#528B8B',
'grape' => '#543948',
'burntsienna' => '#551011',
'gray33' => '#555555',
'forestgreen2' => '#567E3A',
'broccoli' => '#586949',
'snake' => '#596C56',
'lizard' => '#5A6351',
'emerald' => '#5B9C64',
'verydarkbrown' => '#5C4033',
'mediumpurple4' => '#5D478B',
'blue sponge' => '#5D92B1',
'sepia' => '#5E2612',
'tea leaves' => '#5F755E',
'sign brown' => '#603311',
'palm' => '#608341',
'gray38' => '#616161',
'green apple' => '#629632',
'cactus' => '#636F57',
'surf' => '#63D1F4',
'lindsay eyes' => '#65909A',
'blue safe' => '#6600FF',
'cobalt' => '#6666FF',
'green ash' => '#668E86',
'mediumaquamarine' => '#66CDAA',
'swimming pool' => '#67E6EC',
'blue tuna' => '#687C97',
'england pound' => '#688571',
'slateblue3' => '#6959CD',
'olivedrab4' => '#698B22',
'putting' => '#699864',
'darkslateblue' => '#6B238E',
'olivedrab' => '#6B8E23',
'neptune' => '#6D9BF1',
'darkolivegreen4' => '#6E8B3D',
'dolphin' => '#6F7285',
'slategray' => '#708090',
'mediumturquoise' => '#70DBDB',
'sgichartreuse' => '#71C671',
'rawumber' => '#734A12',
'old copper' => '#73B1B7',
'lavender field' => '#754C78',
'blueberry' => '#75A1D0',
'ganegreen' => '#777733',
'green goo' => '#77896C',
'pea' => '#78AB46',
'darkslategray3' => '#79CDCD',
'gray48' => '#7A7A7A',
'cadetblue3' => '#7AC5CD',
'green moth' => '#7BBF6A',
'lawngreen' => '#7CFC00',
'blue nile' => '#7D7F94',
'skyblue2' => '#7EC0EE',
'flight jacket' => '#7F8778',
'aquamarine' => '#7FFFD4',
'brown' => '#802A2A',
'grey' => '#808080',
'eggplant' => '#816687',
'blue mist' => '#82CFFD',
'azure4' => '#838B8B',
'lightslateblue' => '#8470FF',
'dustyrose' => '#856363',
'100 euro' => '#86C67C',
'brownochre' => '#87421F',
'lightskyblue' => '#87CEFA',
'mediumpurple3' => '#8968CD',
'burntsienna' => '#8A360F',
'darkred' => '#8B0000',
'firebrick4' => '#8B1A1A',
'brown4' => '#8B2323',
'indianred4' => '#8B3A3A',
'darkorange4' => '#8B4500',
'palevioletred4' => '#8B475D',
'lightsalmon4' => '#8B5742',
'lightpink4' => '#8B5F65',
'plum4' => '#8B668B',
'burlywood4' => '#8B7355',
'navajowhite4' => '#8B795E',
'mistyrose4' => '#8B7D7B',
'antiquewhite4' => '#8B8378',
'seashell4' => '#8B8682',
'snow4' => '#8B8989',
'ivory4' => '#8B8B83',
'scarlet' => '#8C1717',
'green soap' => '#8CDD81',
'firebrick5' => '#8E2323',
'sienna' => '#8E6B23',
'violet' => '#8F5E99',
'green cheese' => '#8FA880',
'lightgreen' => '#90EE90',
'purple2' => '#912CEE',
'pastel green' => '#92CCA6',
'darkviolet' => '#9400D3',
'gray59' => '#969696',
'darktan' => '#97694F',
'cadetblue1' => '#98F5FF',
'bordeaux' => '#99182C',
'chocolate' => '#993300',
'wavecrest' => '#99CDC9',
'yellowgreen' => '#9ACD32',
'cerulean blue' => '#9BC4E2',
'purple ink' => '#9C6B98',
'jolly green' => '#9CCB19',
'camo3' => '#9DB68C',
'blueviolet' => '#9F5F9F',
'slategray3' => '#9FB6CD',
'gray63' => '#A1A1A1',
'kermit' => '#A2BC13',
'darkolivegreen3' => '#A2CD5A',
'20 pound' => '#A46582',
'brown' => '#A52A2A',
'bronzeii' => '#A67D3D',
'guacamole' => '#A6D785',
'gray66' => '#A8A8A8',
'aluminum' => '#A9ACB6',
'coffee' => '#AA5303',
'periwinkle' => '#AAAAFF',
'gray67' => '#ABABAB',
'lightblue' => '#ADD8E6',
'wasabi sauce' => '#AEBB51',
'cola' => '#AF4035',
'maroonb0' => '#B03060',
'powderblue' => '#B0E0E6',
'firebrick' => '#B22222',
'shamrock shake' => '#B2D0B4',
'key lime pie' => '#B3C95A',
'lightcyan3' => '#B4CDCD',
'thistle' => '#B5509C',
'harolds crayon' => '#B62084',
'brushed aluminum' => '#B6C5BE',
'copper' => '#B87333',
'slategray2' => '#B9D3EE',
'paleturquoise1' => '#BBFFFF',
'chartreuse verte' => '#BCE937',
'darkkhaki' => '#BDB76B',
'gray' => '#BEBEBE',
'violet flower' => '#BF5FFF',
'silver' => '#C0C0C0',
'olivedrab1' => '#C0FF3E',
'pastel blue' => '#C1F0F6',
'robins egg' => '#C3E4ED',
'mint ice cream' => '#C5E3BF',
'slategray1' => '#C6E2FF',
'rawsienna' => '#C76114',
'ruby red' => '#C82536',
'lightsteelblue1' => '#CAE1FF',
'grape' => '#CC00FF',
'violetred' => '#CC3299',
'gold5' => '#CC7F32',
'gray80' => '#CCCCCC',
'red3' => '#CD0000',
'firebrick3' => '#CD2626',
'brown3' => '#CD3333',
'indianred3' => '#CD5555',
'hotpink3' => '#CD6090',
'sienna3' => '#CD6839',
'salmon3' => '#CD7054',
'orange3' => '#CD8500',
'pink3' => '#CD919E',
'goldenrod3' => '#CD9B1D',
'gold3' => '#CDAD00',
'thistle3' => '#CDB5CD',
'wheat3' => '#CDBA96',
'lavenderblush3' => '#CDC1C5',
'cornsilk3' => '#CDC8B1',
'yellow3' => '#CDCD00',
'verylightgrey' => '#CDCDCD',
'green grape' => '#CECC15',
'celery' => '#CFD784',
'conch' => '#D0A9AA',
'feldspar' => '#D19275',
'lightcyan2' => '#D1EEEE',
'pink glass' => '#D3BECF',
'venetianred' => '#D41A1F',
'chili' => '#D44942',
'gray84' => '#D6D6D6',
'cool copper' => '#D98719',
'quartz' => '#D9D9F3',
'blue ice' => '#DAF4F0',
'palevioletred' => '#DB7093',
'ham' => '#DB9EA6',
'moon' => '#DBE6E0',
'gainsboro' => '#DCDCDC',
'carnation' => '#DE85B1',
'melonrindgreen' => '#DFFFA5',
'stainless steel' => '#E0DFDB',
'azure2' => '#E0EEEE',
'geraniumlake' => '#E31230',
'madderlakedeep' => '#E32E30',
'marsyellow' => '#E3701A',
'banana' => '#E3CF57',
'gray90' => '#E5E5E5',
'silver' => '#E6E8FA',
'dark wheat' => '#E8C782',
'darksalmon' => '#E9967A',
'mediumgoldenrod' => '#EAEAAE',
'gray92' => '#EBEBEB',
'carrot' => '#ED9121',
'red2' => '#EE0000',
'firebrick2' => '#EE2C2C',
'brown2' => '#EE3B3B',
'indianred2' => '#EE6363',
'darkorange2' => '#EE7600',
'palevioletred2' => '#EE799F',
'violet' => '#EE82EE',
'orange2' => '#EE9A00',
'pink2' => '#EEA9B8',
'goldenrod2' => '#EEB422',
'gold2' => '#EEC900',
'thistle2' => '#EED2EE',
'beach sand' => '#EED6AF',
'lightgoldenrod' => '#EEDD82',
'seashell2' => '#EEE5DE',
'cornsilk2' => '#EEE8CD',
'yellow2' => '#EEEE00',
'lightcoral' => '#F08080',
'gray94' => '#F0F0F0',
'azure' => '#F0FFFF',
'sandybrown' => '#F4A460',
'beige' => '#F5F5DC',
'dog tongue' => '#F6A4D5',
'pink shell' => '#F6CCDA',
'ghostwhite' => '#F8F8FF',
'linen' => '#FAF0E6',
'apricot' => '#FBA16C',
'sign yellow' => '#FCD116',
'gray99' => '#FCFCFC',
'zincwhite' => '#FDF8FF',
'peach' => '#FEF0DB',
'bright red' => '#FF0033',
'fuchsia2' => '#FF00AA',
'fuchsia' => '#FF00FF',
'spicypink' => '#FF1CAE',
'nectarine' => '#FF3300',
'greenishumber' => '#FF3D0D',
'orangered' => '#FF4500',
'cadmiumorange' => '#FF6103',
'seattle salmon' => '#FF6666',
'hotpink1' => '#FF6EB4',
'oregon salmon' => '#FF7722',
'chocolate1' => '#FF7F24',
'sienna1' => '#FF8247',
'darkorange5' => '#FF8600',
'bubble gum' => '#FF92BB',
'lightsalmon' => '#FFA07A',
'naplesyellowdeep' => '#FFA812',
'peachpuff' => '#FFADB9',
'pink1' => '#FFB5C5',
'plum1' => '#FFBBFF',
'rosybrown1' => '#FFC1C1',
'sand' => '#FFCC99',
'gold' => '#FFD700',
'thistle1' => '#FFE1FF',
'bisque' => '#FFE4C4',
'wheat1' => '#FFE7BA',
'papayawhip' => '#FFEFD5',
'seashell' => '#FFF5EE',
'lemonchiffon' => '#FFFACD',
'coconut' => '#FFFCCF',
'popcornyellow' => '#FFFFAA',
'ivory' => '#FFFFF0'
#'white' => '#FFFFFF'
}

Class Method Summary collapse

Class Method Details

.color(name, *options) ⇒ Object

Raises:

  • (ArgumentError)


376
377
378
379
380
381
382
383
384
385
386
387
388
389
# File 'lib/colorist/color_names.rb', line 376

def self.color(name, *options)     
  name = hexify(name.to_s) if hex?(name)
  options.flatten!
  col = name
  col = COLORS[name.downcase.strip] if !hex?(name)
  raise ArgumentError, "The color name '#{name}' cannot be coerced into a color." if !col           
  res = if options.include?(:hex)
    col.sub /#/, '0x'
  else
    col
  end                         
  res = options.include?(:lower) ? res.downcase : res      
  res = options.include?(:simple) ? remove(res, '#', '0x') : res
end

.remove(txt, *args) ⇒ Object



391
392
393
394
# File 'lib/colorist/color_names.rb', line 391

def self.remove(txt, *args)
  args.each{|a| txt.gsub! a, '' }
  txt
end

.to_color(hex_number) ⇒ Object

Raises:

  • (ArgumentError)


396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# File 'lib/colorist/color_names.rb', line 396

def self.to_color(hex_number)
  hex_number = hex_number.to_s      
  if !hex?(hex_number)
    col = color(hex_number)        
    return col if col
    raise ArgumentError, "The hex number '#{hex_number}' to search for must start with either '#' or '0x' and contain 6 hex chars"
  end
  search = hexify(hex_number)      
  
  found  = nil
  
  COLORS.each_pair do |k, v|
    if v == search
      found = k 
      break
    end
  end      
  raise ArgumentError, "No named color could be found for '#{hex_number}'" if !found           
  found
end