paint 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,11 @@
1
- === 0.8 ===
1
+ === 0.8.1 ==
2
+ * Improve rgb function with better gray scale values
3
+ * Add Paint.mode:
4
+ * Set to false to deactivate colorizing
5
+ * Set to 16 or 8 and all color generation methods will generate simple ansi colors
6
+ * Set to 256 for 256 color support
7
+ * Tries to automatically detect your terminal's features
8
+ * Minor changes
9
+
10
+ === 0.8.0 ===
2
11
  * Initial release
@@ -1,15 +1,17 @@
1
1
  Paint manages terminal colors and effects for you. It combines the strengths of gems like term-ansicolor or rainbow into a simple to use and flexible colorizer.
2
2
 
3
+ {Travis}[http://travis-ci.org/janlelis/paint]: http://travis-ci.org/janlelis/paint.png
4
+
3
5
  == Features
4
6
  * No string extensions (suitable for library development)
5
7
  * Supports setting 256 colors (for capable terminals)
6
8
  * Supports setting any effects (although most terminals won't support it)
7
9
  * Simple to use
8
10
  * Custom shortcuts can be defined and flexibly mixed in
9
-
10
- == TODO next version (beginning of july)
11
- * Fall-back mode for non-256-color terminals (Paint.mode)
12
- * Detection of those old terminals
11
+ * Fall-back modes for non-256-color terminals (Paint.mode), supported modes:
12
+ * 256 colors
13
+ * 8 colors (ansi default)
14
+ * 16 colors (ansi default with bright effect)
13
15
 
14
16
  == Setup
15
17
 
@@ -45,6 +47,16 @@ If you pass multiple colors, the first one is taken as foreground color and the
45
47
 
46
48
  To see more examples, checkout the specs.
47
49
 
50
+ == Paint.mode
51
+
52
+ You can choose between three ways to use <tt>Paint.[]</tt> by setting <tt>Paint.mode</tt> to one of the following:
53
+ * 256: full support
54
+ * 16: don't use 256 colors, but the ansi 8 ones (combined with bright effect)
55
+ * 8: don't use 256 colors, but the ansi 8 ones (combined without bright effect)
56
+ * false: don't colorize at all
57
+
58
+ Paint tries to detect automatically the proper value, but this is still experimental. Please open an issue if <tt>Paint.detect_mode</tt> yields a wrong value.
59
+
48
60
  == More details about terminal colors and effects
49
61
 
50
62
  Terminal colors/effects are set by {ansi escape sequences}[http://en.wikipedia.org/wiki/ANSI_escape_code]. These are strings that look like this: <tt>\e[X;X;X;X;X]m</tt> where X are integers with some meaning. For example, 0 means reset, 31 means red foreground and 41 red background. When you tell Paint to use one of the eight ansi base colors as foreground color, it just inserts a number between 30 and 37 in the sequence. The following colors are available:
@@ -97,7 +109,7 @@ Also see {en.wikipedia.org/wiki/ANSI_escape_code}[http://en.wikipedia.org/wiki/A
97
109
 
98
110
  Now for the fancy part: Color shortcuts for your gems and scripts! Note: You don't have to use them (and only stick to <tt>Paint.[]</tt>) ;)
99
111
 
100
- It's easy: Just setup a hash of symbol keys and escape string values at: <tt>Paint::SHORTCUTS[:your_namespace]</tt>, for example:
112
+ It's easy: Just setup a hash of symbol keys and escape string values at: <tt>Paint::SHORTCUTS[:your_namespace]</tt>. They are stored directly as escape sequences for performance reasons (this also means, you need different namespaces for different <tt>Paint.mode</tt>s). Example:
101
113
 
102
114
  Paint::SHORTCUTS[:example] = {
103
115
  :white => Paint.color(:black),
@@ -146,6 +158,10 @@ Another one is <tt>Paint.unpaint</tt>, which removes any ansi colors:
146
158
 
147
159
  Paint.unpaint( Paint['J-_-L', :red, :bright] ).should == 'J-_-L'
148
160
 
161
+ == Todos
162
+ === Maybe
163
+ * 24-bit color support (konsole), see http://www.reddit.com/r/programming/comments/6gxnp/making_the_most_of_colour_on_text_consoles/c03t8k8
164
+
149
165
  == Credits
150
166
 
151
167
  Mainly influenced by rainbow[https://github.com/sickill/rainbow] and {term-ansicolor}[https://github.com/flori/term-ansicolor].
@@ -1,12 +1,13 @@
1
- require 'paint/version'
2
- require 'paint/shortcuts'
1
+ require 'paint/version' unless defined? Paint::VERSION
2
+ require 'paint/shortcuts'unless defined? Paint::SHORTCUTS
3
3
  require 'paint/util'
4
4
 
5
5
  module Paint
6
6
  autoload :RGB_COLORS, 'paint/rgb_colors'
7
+ autoload :RGB_COLORS_ANSI, 'paint/rgb_colors_ansi'
7
8
 
8
9
  # Important purpose
9
- NOTHING = "\e[0m"
10
+ NOTHING = "\033[0m"
10
11
 
11
12
  # Basic colors (often, the color differs when using the bright effect)
12
13
  # Final color will be 30 + value for foreground and 40 + value for background
@@ -57,12 +58,17 @@ module Paint
57
58
  # Takes a string and color options and colorizes the string
58
59
  # See README.rdoc for details
59
60
  def [](string, *args)
60
- color(*args) + string.to_s + NOTHING
61
+ if mode
62
+ color(*args) + string.to_s + NOTHING
63
+ else
64
+ string.to_s
65
+ end
61
66
  end
62
67
 
63
68
  # Sometimes, you only need the color
64
69
  # Used by []
65
70
  def color(*options)
71
+ return '' unless mode
66
72
  mix = []
67
73
  color_seen = false
68
74
 
@@ -94,7 +100,7 @@ module Paint
94
100
  mix << hex(option, color_seen)
95
101
  color_seen = true
96
102
  else
97
- mix << name(option, color_seen)
103
+ mix << rgb_name(option, color_seen)
98
104
  color_seen = true
99
105
  end
100
106
 
@@ -116,9 +122,17 @@ module Paint
116
122
  wrap(*mix)
117
123
  end
118
124
 
125
+ # This variable influences the color code generation
126
+ # Currently supported values:
127
+ # * 256 - 256 colors
128
+ # * 16 - only ansi colors
129
+ # * false - no colorization!
130
+ def mode() @mode.nil? ? detect_mode : @mode end
131
+ def mode=(val) @mode = val end
132
+
119
133
  # Adds ansi sequence
120
134
  def wrap(*ansi_codes)
121
- "\e[" + ansi_codes*";" + "m"
135
+ "\033[" + ansi_codes*";" + "m"
122
136
  end
123
137
 
124
138
  # Creates simple ansi color by looking it up on Paint::ANSI_COLORS
@@ -128,7 +142,11 @@ module Paint
128
142
 
129
143
  # Creates a 256-compatible color from rgb values
130
144
  def rgb(red, green, blue, background = false)
131
- "#{background ? 48 : 38};5;#{rgb_value(red, green, blue)}"
145
+ if mode == 8 || mode == 16
146
+ "#{background ? 4 : 3}#{rgb_like_value(red, green, blue, mode == 16)}"
147
+ else
148
+ "#{background ? 48 : 38}#{rgb_value(red, green, blue)}"
149
+ end
132
150
  end
133
151
 
134
152
  # Creates 256-compatible color from a html-like color string
@@ -145,9 +163,9 @@ module Paint
145
163
  end
146
164
 
147
165
  # Creates a 256-color from a name found in Paint::RGB_COLORS (based on rgb.txt)
148
- def name(color_name, background = false)
166
+ def rgb_name(color_name, background = false)
149
167
  if color_code = RGB_COLORS[color_name]
150
- "#{background ? 48 : 38};5;#{color_code}"
168
+ rgb(*(color_code + [background] )) # 1.8 workaround
151
169
  end
152
170
  end
153
171
 
@@ -163,11 +181,49 @@ module Paint
163
181
 
164
182
  private
165
183
 
166
- # Gets nearest supported color, heavily inspired by the rainbow gem
184
+ # Returns nearest supported 256-color an rgb value, without fore-/background information
185
+ # Inspired by the rainbow gem
167
186
  def rgb_value(red, green, blue)
168
- [16, *[red, green, blue].zip([36, 6, 1]).map{ |color, mod|
169
- (6 * (color.to_f / 256)).to_i * mod
170
- }].inject(:+)
187
+ gray_possible = true
188
+ sep = 42.5
189
+
190
+ while gray_possible
191
+ if red < sep || green < sep || blue < sep
192
+ gray = red < sep && green < sep && blue < sep
193
+ gray_possible = false
194
+ end
195
+ sep += 42.5
196
+ end
197
+
198
+ if gray
199
+ ";5;#{ 232 + ((red.to_f + green.to_f + blue.to_f)/33).round }"
200
+ else # rgb
201
+ ";5;#{ [16, *[red, green, blue].zip([36, 6, 1]).map{ |color, mod|
202
+ (6 * (color.to_f / 256)).to_i * mod
203
+ }].inject(:+) }"
204
+ end
205
+ end
206
+
207
+ # Returns ansi color matching an rgb value, without fore-/background information
208
+ # See http://mail.python.org/pipermail/python-list/2008-December/1150496.html
209
+ def rgb_like_value(red, green, blue, use_bright = false)
210
+ color_pool = RGB_COLORS_ANSI.values
211
+ color_pool += RGB_COLORS_ANSI_BRIGHT.values if use_bright
212
+
213
+ ansi_color_rgb = color_pool.min_by{ |col| distance([red, green, blue],col) }
214
+ key_method = RUBY_VERSION < "1.9" ? :index : :key
215
+ if ansi_color = RGB_COLORS_ANSI.send(key_method, ansi_color_rgb)
216
+ ANSI_COLORS[ansi_color]
217
+ else
218
+ ansi_color = RGB_COLORS_ANSI_BRIGHT.send(key_method, ansi_color_rgb)
219
+ "#{ANSI_COLORS[ansi_color]};1"
220
+ end
221
+ end
222
+
223
+ def distance(rgb1, rgb2)
224
+ rgb1.zip(rgb2).inject(0){ |acc, (cur1, cur2)|
225
+ acc + (cur1 - cur2)**2
226
+ }
171
227
  end
172
228
  end
173
229
  end
@@ -2,7 +2,7 @@ module Paint
2
2
  # A list of color names, based on X11's rgb.txt
3
3
  # Can be used with Paint.[] by passing a string containing the color name
4
4
  # See Paint::Util::update_rgb_colors for generating
5
- RGB_COLORS = {"snow"=>231, "ghost white"=>231, "GhostWhite"=>231, "white smoke"=>231, "WhiteSmoke"=>231, "gainsboro"=>231, "floral white"=>231, "FloralWhite"=>231, "old lace"=>231, "OldLace"=>231, "linen"=>231, "antique white"=>231, "AntiqueWhite"=>231, "papaya whip"=>230, "PapayaWhip"=>230, "blanched almond"=>230, "BlanchedAlmond"=>230, "bisque"=>230, "peach puff"=>230, "PeachPuff"=>230, "navajo white"=>230, "NavajoWhite"=>230, "moccasin"=>230, "cornsilk"=>231, "ivory"=>231, "lemon chiffon"=>230, "LemonChiffon"=>230, "seashell"=>231, "honeydew"=>231, "mint cream"=>231, "MintCream"=>231, "azure"=>231, "alice blue"=>231, "AliceBlue"=>231, "lavender"=>231, "lavender blush"=>231, "LavenderBlush"=>231, "misty rose"=>231, "MistyRose"=>231, "white"=>231, "black"=>16, "dark slate gray"=>59, "DarkSlateGray"=>59, "dark slate grey"=>59, "DarkSlateGrey"=>59, "dim gray"=>102, "DimGray"=>102, "dim grey"=>102, "DimGrey"=>102, "slate gray"=>109, "SlateGray"=>109, "slate grey"=>109, "SlateGrey"=>109, "light slate gray"=>109, "LightSlateGray"=>109, "light slate grey"=>109, "LightSlateGrey"=>109, "gray"=>188, "grey"=>188, "light grey"=>188, "LightGrey"=>188, "light gray"=>188, "LightGray"=>188, "midnight blue"=>18, "MidnightBlue"=>18, "navy"=>19, "navy blue"=>19, "NavyBlue"=>19, "cornflower blue"=>111, "CornflowerBlue"=>111, "dark slate blue"=>61, "DarkSlateBlue"=>61, "slate blue"=>104, "SlateBlue"=>104, "medium slate blue"=>105, "MediumSlateBlue"=>105, "light slate blue"=>141, "LightSlateBlue"=>141, "medium blue"=>20, "MediumBlue"=>20, "royal blue"=>69, "RoyalBlue"=>69, "blue"=>21, "dodger blue"=>39, "DodgerBlue"=>39, "deep sky blue"=>45, "DeepSkyBlue"=>45, "sky blue"=>153, "SkyBlue"=>153, "light sky blue"=>153, "LightSkyBlue"=>153, "steel blue"=>74, "SteelBlue"=>74, "light steel blue"=>189, "LightSteelBlue"=>189, "light blue"=>195, "LightBlue"=>195, "powder blue"=>195, "PowderBlue"=>195, "pale turquoise"=>195, "PaleTurquoise"=>195, "dark turquoise"=>44, "DarkTurquoise"=>44, "medium turquoise"=>80, "MediumTurquoise"=>80, "turquoise"=>86, "cyan"=>51, "light cyan"=>231, "LightCyan"=>231, "cadet blue"=>109, "CadetBlue"=>109, "medium aquamarine"=>115, "MediumAquamarine"=>115, "aquamarine"=>122, "dark green"=>28, "DarkGreen"=>28, "dark olive green"=>65, "DarkOliveGreen"=>65, "dark sea green"=>151, "DarkSeaGreen"=>151, "sea green"=>72, "SeaGreen"=>72, "medium sea green"=>78, "MediumSeaGreen"=>78, "light sea green"=>43, "LightSeaGreen"=>43, "pale green"=>157, "PaleGreen"=>157, "spring green"=>48, "SpringGreen"=>48, "lawn green"=>118, "LawnGreen"=>118, "green"=>46, "chartreuse"=>118, "medium spring green"=>49, "MediumSpringGreen"=>49, "green yellow"=>191, "GreenYellow"=>191, "lime green"=>77, "LimeGreen"=>77, "yellow green"=>149, "YellowGreen"=>149, "forest green"=>34, "ForestGreen"=>34, "olive drab"=>106, "OliveDrab"=>106, "dark khaki"=>186, "DarkKhaki"=>186, "khaki"=>229, "pale goldenrod"=>229, "PaleGoldenrod"=>229, "light goldenrod yellow"=>230, "LightGoldenrodYellow"=>230, "light yellow"=>231, "LightYellow"=>231, "yellow"=>226, "gold"=>226, "light goldenrod"=>229, "LightGoldenrod"=>229, "goldenrod"=>214, "dark goldenrod"=>178, "DarkGoldenrod"=>178, "rosy brown"=>181, "RosyBrown"=>181, "indian red"=>174, "IndianRed"=>174, "saddle brown"=>130, "SaddleBrown"=>130, "sienna"=>131, "peru"=>179, "burlywood"=>223, "beige"=>231, "wheat"=>230, "sandy brown"=>216, "SandyBrown"=>216, "tan"=>187, "chocolate"=>172, "firebrick"=>160, "brown"=>124, "dark salmon"=>216, "DarkSalmon"=>216, "salmon"=>216, "light salmon"=>216, "LightSalmon"=>216, "orange"=>214, "dark orange"=>214, "DarkOrange"=>214, "coral"=>209, "light coral"=>217, "LightCoral"=>217, "tomato"=>209, "orange red"=>202, "OrangeRed"=>202, "red"=>196, "hot pink"=>212, "HotPink"=>212, "deep pink"=>199, "DeepPink"=>199, "pink"=>224, "light pink"=>224, "LightPink"=>224, "pale violet red"=>211, "PaleVioletRed"=>211, "maroon"=>168, "medium violet red"=>163, "MediumVioletRed"=>163, "violet red"=>163, "VioletRed"=>163, "magenta"=>201, "violet"=>219, "plum"=>219, "orchid"=>213, "medium orchid"=>170, "MediumOrchid"=>170, "dark orchid"=>134, "DarkOrchid"=>134, "dark violet"=>128, "DarkViolet"=>128, "blue violet"=>135, "BlueViolet"=>135, "purple"=>129, "medium purple"=>141, "MediumPurple"=>141, "thistle"=>225, "snow1"=>231, "snow2"=>231, "snow3"=>188, "snow4"=>145, "seashell1"=>231, "seashell2"=>231, "seashell3"=>188, "seashell4"=>145, "AntiqueWhite1"=>231, "AntiqueWhite2"=>230, "AntiqueWhite3"=>188, "AntiqueWhite4"=>144, "bisque1"=>230, "bisque2"=>224, "bisque3"=>187, "bisque4"=>138, "PeachPuff1"=>230, "PeachPuff2"=>224, "PeachPuff3"=>187, "PeachPuff4"=>138, "NavajoWhite1"=>230, "NavajoWhite2"=>223, "NavajoWhite3"=>187, "NavajoWhite4"=>138, "LemonChiffon1"=>230, "LemonChiffon2"=>230, "LemonChiffon3"=>187, "LemonChiffon4"=>144, "cornsilk1"=>231, "cornsilk2"=>230, "cornsilk3"=>188, "cornsilk4"=>144, "ivory1"=>231, "ivory2"=>231, "ivory3"=>188, "ivory4"=>145, "honeydew1"=>231, "honeydew2"=>231, "honeydew3"=>188, "honeydew4"=>145, "LavenderBlush1"=>231, "LavenderBlush2"=>231, "LavenderBlush3"=>188, "LavenderBlush4"=>145, "MistyRose1"=>231, "MistyRose2"=>224, "MistyRose3"=>188, "MistyRose4"=>138, "azure1"=>231, "azure2"=>231, "azure3"=>188, "azure4"=>145, "SlateBlue1"=>141, "SlateBlue2"=>105, "SlateBlue3"=>104, "SlateBlue4"=>61, "RoyalBlue1"=>69, "RoyalBlue2"=>69, "RoyalBlue3"=>68, "RoyalBlue4"=>25, "blue1"=>21, "blue2"=>21, "blue3"=>20, "blue4"=>19, "DodgerBlue1"=>39, "DodgerBlue2"=>39, "DodgerBlue3"=>32, "DodgerBlue4"=>25, "SteelBlue1"=>117, "SteelBlue2"=>117, "SteelBlue3"=>74, "SteelBlue4"=>67, "DeepSkyBlue1"=>45, "DeepSkyBlue2"=>45, "DeepSkyBlue3"=>38, "DeepSkyBlue4"=>31, "SkyBlue1"=>153, "SkyBlue2"=>117, "SkyBlue3"=>110, "SkyBlue4"=>67, "LightSkyBlue1"=>195, "LightSkyBlue2"=>153, "LightSkyBlue3"=>152, "LightSkyBlue4"=>103, "SlateGray1"=>195, "SlateGray2"=>189, "SlateGray3"=>152, "SlateGray4"=>103, "LightSteelBlue1"=>195, "LightSteelBlue2"=>189, "LightSteelBlue3"=>152, "LightSteelBlue4"=>103, "LightBlue1"=>195, "LightBlue2"=>195, "LightBlue3"=>152, "LightBlue4"=>109, "LightCyan1"=>231, "LightCyan2"=>195, "LightCyan3"=>188, "LightCyan4"=>109, "PaleTurquoise1"=>195, "PaleTurquoise2"=>195, "PaleTurquoise3"=>152, "PaleTurquoise4"=>109, "CadetBlue1"=>159, "CadetBlue2"=>159, "CadetBlue3"=>116, "CadetBlue4"=>73, "turquoise1"=>51, "turquoise2"=>51, "turquoise3"=>44, "turquoise4"=>37, "cyan1"=>51, "cyan2"=>51, "cyan3"=>44, "cyan4"=>37, "DarkSlateGray1"=>159, "DarkSlateGray2"=>159, "DarkSlateGray3"=>116, "DarkSlateGray4"=>73, "aquamarine1"=>122, "aquamarine2"=>122, "aquamarine3"=>115, "aquamarine4"=>72, "DarkSeaGreen1"=>194, "DarkSeaGreen2"=>194, "DarkSeaGreen3"=>151, "DarkSeaGreen4"=>108, "SeaGreen1"=>85, "SeaGreen2"=>85, "SeaGreen3"=>79, "SeaGreen4"=>72, "PaleGreen1"=>157, "PaleGreen2"=>157, "PaleGreen3"=>114, "PaleGreen4"=>71, "SpringGreen1"=>48, "SpringGreen2"=>48, "SpringGreen3"=>42, "SpringGreen4"=>35, "green1"=>46, "green2"=>46, "green3"=>40, "green4"=>34, "chartreuse1"=>118, "chartreuse2"=>118, "chartreuse3"=>112, "chartreuse4"=>70, "OliveDrab1"=>191, "OliveDrab2"=>191, "OliveDrab3"=>149, "OliveDrab4"=>106, "DarkOliveGreen1"=>192, "DarkOliveGreen2"=>192, "DarkOliveGreen3"=>150, "DarkOliveGreen4"=>107, "khaki1"=>229, "khaki2"=>229, "khaki3"=>186, "khaki4"=>143, "LightGoldenrod1"=>229, "LightGoldenrod2"=>229, "LightGoldenrod3"=>186, "LightGoldenrod4"=>143, "LightYellow1"=>231, "LightYellow2"=>230, "LightYellow3"=>188, "LightYellow4"=>144, "yellow1"=>226, "yellow2"=>226, "yellow3"=>184, "yellow4"=>142, "gold1"=>226, "gold2"=>220, "gold3"=>184, "gold4"=>136, "goldenrod1"=>220, "goldenrod2"=>220, "goldenrod3"=>178, "goldenrod4"=>136, "DarkGoldenrod1"=>220, "DarkGoldenrod2"=>220, "DarkGoldenrod3"=>178, "DarkGoldenrod4"=>136, "RosyBrown1"=>224, "RosyBrown2"=>224, "RosyBrown3"=>181, "RosyBrown4"=>138, "IndianRed1"=>210, "IndianRed2"=>210, "IndianRed3"=>167, "IndianRed4"=>131, "sienna1"=>215, "sienna2"=>209, "sienna3"=>173, "sienna4"=>130, "burlywood1"=>223, "burlywood2"=>223, "burlywood3"=>180, "burlywood4"=>137, "wheat1"=>230, "wheat2"=>230, "wheat3"=>187, "wheat4"=>138, "tan1"=>215, "tan2"=>215, "tan3"=>179, "tan4"=>137, "chocolate1"=>208, "chocolate2"=>208, "chocolate3"=>172, "chocolate4"=>130, "firebrick1"=>203, "firebrick2"=>203, "firebrick3"=>160, "firebrick4"=>124, "brown1"=>203, "brown2"=>203, "brown3"=>167, "brown4"=>124, "salmon1"=>216, "salmon2"=>216, "salmon3"=>173, "salmon4"=>131, "LightSalmon1"=>216, "LightSalmon2"=>216, "LightSalmon3"=>180, "LightSalmon4"=>137, "orange1"=>214, "orange2"=>214, "orange3"=>178, "orange4"=>136, "DarkOrange1"=>208, "DarkOrange2"=>208, "DarkOrange3"=>172, "DarkOrange4"=>130, "coral1"=>210, "coral2"=>209, "coral3"=>173, "coral4"=>131, "tomato1"=>209, "tomato2"=>209, "tomato3"=>167, "tomato4"=>130, "OrangeRed1"=>202, "OrangeRed2"=>202, "OrangeRed3"=>166, "OrangeRed4"=>124, "red1"=>196, "red2"=>196, "red3"=>160, "red4"=>124, "DebianRed"=>197, "DeepPink1"=>199, "DeepPink2"=>199, "DeepPink3"=>162, "DeepPink4"=>125, "HotPink1"=>212, "HotPink2"=>211, "HotPink3"=>175, "HotPink4"=>132, "pink1"=>224, "pink2"=>218, "pink3"=>181, "pink4"=>138, "LightPink1"=>224, "LightPink2"=>218, "LightPink3"=>181, "LightPink4"=>138, "PaleVioletRed1"=>218, "PaleVioletRed2"=>211, "PaleVioletRed3"=>175, "PaleVioletRed4"=>132, "maroon1"=>206, "maroon2"=>205, "maroon3"=>163, "maroon4"=>126, "VioletRed1"=>205, "VioletRed2"=>205, "VioletRed3"=>168, "VioletRed4"=>125, "magenta1"=>201, "magenta2"=>201, "magenta3"=>164, "magenta4"=>127, "orchid1"=>219, "orchid2"=>213, "orchid3"=>176, "orchid4"=>133, "plum1"=>225, "plum2"=>225, "plum3"=>182, "plum4"=>139, "MediumOrchid1"=>213, "MediumOrchid2"=>177, "MediumOrchid3"=>170, "MediumOrchid4"=>97, "DarkOrchid1"=>171, "DarkOrchid2"=>171, "DarkOrchid3"=>134, "DarkOrchid4"=>91, "purple1"=>135, "purple2"=>135, "purple3"=>92, "purple4"=>55, "MediumPurple1"=>183, "MediumPurple2"=>141, "MediumPurple3"=>140, "MediumPurple4"=>97, "thistle1"=>231, "thistle2"=>225, "thistle3"=>188, "thistle4"=>139, "gray0"=>16, "grey0"=>16, "gray1"=>16, "grey1"=>16, "gray2"=>16, "grey2"=>16, "gray3"=>16, "grey3"=>16, "gray4"=>16, "grey4"=>16, "gray5"=>16, "grey5"=>16, "gray6"=>16, "grey6"=>16, "gray7"=>16, "grey7"=>16, "gray8"=>16, "grey8"=>16, "gray9"=>16, "grey9"=>16, "gray10"=>16, "grey10"=>16, "gray11"=>16, "grey11"=>16, "gray12"=>16, "grey12"=>16, "gray13"=>16, "grey13"=>16, "gray14"=>16, "grey14"=>16, "gray15"=>16, "grey15"=>16, "gray16"=>16, "grey16"=>16, "gray17"=>59, "grey17"=>59, "gray18"=>59, "grey18"=>59, "gray19"=>59, "grey19"=>59, "gray20"=>59, "grey20"=>59, "gray21"=>59, "grey21"=>59, "gray22"=>59, "grey22"=>59, "gray23"=>59, "grey23"=>59, "gray24"=>59, "grey24"=>59, "gray25"=>59, "grey25"=>59, "gray26"=>59, "grey26"=>59, "gray27"=>59, "grey27"=>59, "gray28"=>59, "grey28"=>59, "gray29"=>59, "grey29"=>59, "gray30"=>59, "grey30"=>59, "gray31"=>59, "grey31"=>59, "gray32"=>59, "grey32"=>59, "gray33"=>59, "grey33"=>59, "gray34"=>102, "grey34"=>102, "gray35"=>102, "grey35"=>102, "gray36"=>102, "grey36"=>102, "gray37"=>102, "grey37"=>102, "gray38"=>102, "grey38"=>102, "gray39"=>102, "grey39"=>102, "gray40"=>102, "grey40"=>102, "gray41"=>102, "grey41"=>102, "gray42"=>102, "grey42"=>102, "gray43"=>102, "grey43"=>102, "gray44"=>102, "grey44"=>102, "gray45"=>102, "grey45"=>102, "gray46"=>102, "grey46"=>102, "gray47"=>102, "grey47"=>102, "gray48"=>102, "grey48"=>102, "gray49"=>102, "grey49"=>102, "gray50"=>102, "grey50"=>102, "gray51"=>145, "grey51"=>145, "gray52"=>145, "grey52"=>145, "gray53"=>145, "grey53"=>145, "gray54"=>145, "grey54"=>145, "gray55"=>145, "grey55"=>145, "gray56"=>145, "grey56"=>145, "gray57"=>145, "grey57"=>145, "gray58"=>145, "grey58"=>145, "gray59"=>145, "grey59"=>145, "gray60"=>145, "grey60"=>145, "gray61"=>145, "grey61"=>145, "gray62"=>145, "grey62"=>145, "gray63"=>145, "grey63"=>145, "gray64"=>145, "grey64"=>145, "gray65"=>145, "grey65"=>145, "gray66"=>145, "grey66"=>145, "gray67"=>188, "grey67"=>188, "gray68"=>188, "grey68"=>188, "gray69"=>188, "grey69"=>188, "gray70"=>188, "grey70"=>188, "gray71"=>188, "grey71"=>188, "gray72"=>188, "grey72"=>188, "gray73"=>188, "grey73"=>188, "gray74"=>188, "grey74"=>188, "gray75"=>188, "grey75"=>188, "gray76"=>188, "grey76"=>188, "gray77"=>188, "grey77"=>188, "gray78"=>188, "grey78"=>188, "gray79"=>188, "grey79"=>188, "gray80"=>188, "grey80"=>188, "gray81"=>188, "grey81"=>188, "gray82"=>188, "grey82"=>188, "gray83"=>188, "grey83"=>188, "gray84"=>231, "grey84"=>231, "gray85"=>231, "grey85"=>231, "gray86"=>231, "grey86"=>231, "gray87"=>231, "grey87"=>231, "gray88"=>231, "grey88"=>231, "gray89"=>231, "grey89"=>231, "gray90"=>231, "grey90"=>231, "gray91"=>231, "grey91"=>231, "gray92"=>231, "grey92"=>231, "gray93"=>231, "grey93"=>231, "gray94"=>231, "grey94"=>231, "gray95"=>231, "grey95"=>231, "gray96"=>231, "grey96"=>231, "gray97"=>231, "grey97"=>231, "gray98"=>231, "grey98"=>231, "gray99"=>231, "grey99"=>231, "gray100"=>231, "grey100"=>231, "dark grey"=>145, "DarkGrey"=>145, "dark gray"=>145, "DarkGray"=>145, "dark blue"=>19, "DarkBlue"=>19, "dark cyan"=>37, "DarkCyan"=>37, "dark magenta"=>127, "DarkMagenta"=>127, "dark red"=>124, "DarkRed"=>124, "light green"=>157, "LightGreen"=>157}
5
+ RGB_COLORS = {"snow"=>[255, 250, 250], "ghost white"=>[248, 248, 255], "GhostWhite"=>[248, 248, 255], "white smoke"=>[245, 245, 245], "WhiteSmoke"=>[245, 245, 245], "gainsboro"=>[220, 220, 220], "floral white"=>[255, 250, 240], "FloralWhite"=>[255, 250, 240], "old lace"=>[253, 245, 230], "OldLace"=>[253, 245, 230], "linen"=>[250, 240, 230], "antique white"=>[250, 235, 215], "AntiqueWhite"=>[250, 235, 215], "papaya whip"=>[255, 239, 213], "PapayaWhip"=>[255, 239, 213], "blanched almond"=>[255, 235, 205], "BlanchedAlmond"=>[255, 235, 205], "bisque"=>[255, 228, 196], "peach puff"=>[255, 218, 185], "PeachPuff"=>[255, 218, 185], "navajo white"=>[255, 222, 173], "NavajoWhite"=>[255, 222, 173], "moccasin"=>[255, 228, 181], "cornsilk"=>[255, 248, 220], "ivory"=>[255, 255, 240], "lemon chiffon"=>[255, 250, 205], "LemonChiffon"=>[255, 250, 205], "seashell"=>[255, 245, 238], "honeydew"=>[240, 255, 240], "mint cream"=>[245, 255, 250], "MintCream"=>[245, 255, 250], "azure"=>[240, 255, 255], "alice blue"=>[240, 248, 255], "AliceBlue"=>[240, 248, 255], "lavender"=>[230, 230, 250], "lavender blush"=>[255, 240, 245], "LavenderBlush"=>[255, 240, 245], "misty rose"=>[255, 228, 225], "MistyRose"=>[255, 228, 225], "white"=>[255, 255, 255], "black"=>[0, 0, 0], "dark slate gray"=>[47, 79, 79], "DarkSlateGray"=>[47, 79, 79], "dark slate grey"=>[47, 79, 79], "DarkSlateGrey"=>[47, 79, 79], "dim gray"=>[105, 105, 105], "DimGray"=>[105, 105, 105], "dim grey"=>[105, 105, 105], "DimGrey"=>[105, 105, 105], "slate gray"=>[112, 128, 144], "SlateGray"=>[112, 128, 144], "slate grey"=>[112, 128, 144], "SlateGrey"=>[112, 128, 144], "light slate gray"=>[119, 136, 153], "LightSlateGray"=>[119, 136, 153], "light slate grey"=>[119, 136, 153], "LightSlateGrey"=>[119, 136, 153], "gray"=>[190, 190, 190], "grey"=>[190, 190, 190], "light grey"=>[211, 211, 211], "LightGrey"=>[211, 211, 211], "light gray"=>[211, 211, 211], "LightGray"=>[211, 211, 211], "midnight blue"=>[25, 25, 112], "MidnightBlue"=>[25, 25, 112], "navy"=>[0, 0, 128], "navy blue"=>[0, 0, 128], "NavyBlue"=>[0, 0, 128], "cornflower blue"=>[100, 149, 237], "CornflowerBlue"=>[100, 149, 237], "dark slate blue"=>[72, 61, 139], "DarkSlateBlue"=>[72, 61, 139], "slate blue"=>[106, 90, 205], "SlateBlue"=>[106, 90, 205], "medium slate blue"=>[123, 104, 238], "MediumSlateBlue"=>[123, 104, 238], "light slate blue"=>[132, 112, 255], "LightSlateBlue"=>[132, 112, 255], "medium blue"=>[0, 0, 205], "MediumBlue"=>[0, 0, 205], "royal blue"=>[65, 105, 225], "RoyalBlue"=>[65, 105, 225], "blue"=>[0, 0, 255], "dodger blue"=>[30, 144, 255], "DodgerBlue"=>[30, 144, 255], "deep sky blue"=>[0, 191, 255], "DeepSkyBlue"=>[0, 191, 255], "sky blue"=>[135, 206, 235], "SkyBlue"=>[135, 206, 235], "light sky blue"=>[135, 206, 250], "LightSkyBlue"=>[135, 206, 250], "steel blue"=>[70, 130, 180], "SteelBlue"=>[70, 130, 180], "light steel blue"=>[176, 196, 222], "LightSteelBlue"=>[176, 196, 222], "light blue"=>[173, 216, 230], "LightBlue"=>[173, 216, 230], "powder blue"=>[176, 224, 230], "PowderBlue"=>[176, 224, 230], "pale turquoise"=>[175, 238, 238], "PaleTurquoise"=>[175, 238, 238], "dark turquoise"=>[0, 206, 209], "DarkTurquoise"=>[0, 206, 209], "medium turquoise"=>[72, 209, 204], "MediumTurquoise"=>[72, 209, 204], "turquoise"=>[64, 224, 208], "cyan"=>[0, 255, 255], "light cyan"=>[224, 255, 255], "LightCyan"=>[224, 255, 255], "cadet blue"=>[95, 158, 160], "CadetBlue"=>[95, 158, 160], "medium aquamarine"=>[102, 205, 170], "MediumAquamarine"=>[102, 205, 170], "aquamarine"=>[127, 255, 212], "dark green"=>[0, 100, 0], "DarkGreen"=>[0, 100, 0], "dark olive green"=>[85, 107, 47], "DarkOliveGreen"=>[85, 107, 47], "dark sea green"=>[143, 188, 143], "DarkSeaGreen"=>[143, 188, 143], "sea green"=>[46, 139, 87], "SeaGreen"=>[46, 139, 87], "medium sea green"=>[60, 179, 113], "MediumSeaGreen"=>[60, 179, 113], "light sea green"=>[32, 178, 170], "LightSeaGreen"=>[32, 178, 170], "pale green"=>[152, 251, 152], "PaleGreen"=>[152, 251, 152], "spring green"=>[0, 255, 127], "SpringGreen"=>[0, 255, 127], "lawn green"=>[124, 252, 0], "LawnGreen"=>[124, 252, 0], "green"=>[0, 255, 0], "chartreuse"=>[127, 255, 0], "medium spring green"=>[0, 250, 154], "MediumSpringGreen"=>[0, 250, 154], "green yellow"=>[173, 255, 47], "GreenYellow"=>[173, 255, 47], "lime green"=>[50, 205, 50], "LimeGreen"=>[50, 205, 50], "yellow green"=>[154, 205, 50], "YellowGreen"=>[154, 205, 50], "forest green"=>[34, 139, 34], "ForestGreen"=>[34, 139, 34], "olive drab"=>[107, 142, 35], "OliveDrab"=>[107, 142, 35], "dark khaki"=>[189, 183, 107], "DarkKhaki"=>[189, 183, 107], "khaki"=>[240, 230, 140], "pale goldenrod"=>[238, 232, 170], "PaleGoldenrod"=>[238, 232, 170], "light goldenrod yellow"=>[250, 250, 210], "LightGoldenrodYellow"=>[250, 250, 210], "light yellow"=>[255, 255, 224], "LightYellow"=>[255, 255, 224], "yellow"=>[255, 255, 0], "gold"=>[255, 215, 0], "light goldenrod"=>[238, 221, 130], "LightGoldenrod"=>[238, 221, 130], "goldenrod"=>[218, 165, 32], "dark goldenrod"=>[184, 134, 11], "DarkGoldenrod"=>[184, 134, 11], "rosy brown"=>[188, 143, 143], "RosyBrown"=>[188, 143, 143], "indian red"=>[205, 92, 92], "IndianRed"=>[205, 92, 92], "saddle brown"=>[139, 69, 19], "SaddleBrown"=>[139, 69, 19], "sienna"=>[160, 82, 45], "peru"=>[205, 133, 63], "burlywood"=>[222, 184, 135], "beige"=>[245, 245, 220], "wheat"=>[245, 222, 179], "sandy brown"=>[244, 164, 96], "SandyBrown"=>[244, 164, 96], "tan"=>[210, 180, 140], "chocolate"=>[210, 105, 30], "firebrick"=>[178, 34, 34], "brown"=>[165, 42, 42], "dark salmon"=>[233, 150, 122], "DarkSalmon"=>[233, 150, 122], "salmon"=>[250, 128, 114], "light salmon"=>[255, 160, 122], "LightSalmon"=>[255, 160, 122], "orange"=>[255, 165, 0], "dark orange"=>[255, 140, 0], "DarkOrange"=>[255, 140, 0], "coral"=>[255, 127, 80], "light coral"=>[240, 128, 128], "LightCoral"=>[240, 128, 128], "tomato"=>[255, 99, 71], "orange red"=>[255, 69, 0], "OrangeRed"=>[255, 69, 0], "red"=>[255, 0, 0], "hot pink"=>[255, 105, 180], "HotPink"=>[255, 105, 180], "deep pink"=>[255, 20, 147], "DeepPink"=>[255, 20, 147], "pink"=>[255, 192, 203], "light pink"=>[255, 182, 193], "LightPink"=>[255, 182, 193], "pale violet red"=>[219, 112, 147], "PaleVioletRed"=>[219, 112, 147], "maroon"=>[176, 48, 96], "medium violet red"=>[199, 21, 133], "MediumVioletRed"=>[199, 21, 133], "violet red"=>[208, 32, 144], "VioletRed"=>[208, 32, 144], "magenta"=>[255, 0, 255], "violet"=>[238, 130, 238], "plum"=>[221, 160, 221], "orchid"=>[218, 112, 214], "medium orchid"=>[186, 85, 211], "MediumOrchid"=>[186, 85, 211], "dark orchid"=>[153, 50, 204], "DarkOrchid"=>[153, 50, 204], "dark violet"=>[148, 0, 211], "DarkViolet"=>[148, 0, 211], "blue violet"=>[138, 43, 226], "BlueViolet"=>[138, 43, 226], "purple"=>[160, 32, 240], "medium purple"=>[147, 112, 219], "MediumPurple"=>[147, 112, 219], "thistle"=>[216, 191, 216], "snow1"=>[255, 250, 250], "snow2"=>[238, 233, 233], "snow3"=>[205, 201, 201], "snow4"=>[139, 137, 137], "seashell1"=>[255, 245, 238], "seashell2"=>[238, 229, 222], "seashell3"=>[205, 197, 191], "seashell4"=>[139, 134, 130], "AntiqueWhite1"=>[255, 239, 219], "AntiqueWhite2"=>[238, 223, 204], "AntiqueWhite3"=>[205, 192, 176], "AntiqueWhite4"=>[139, 131, 120], "bisque1"=>[255, 228, 196], "bisque2"=>[238, 213, 183], "bisque3"=>[205, 183, 158], "bisque4"=>[139, 125, 107], "PeachPuff1"=>[255, 218, 185], "PeachPuff2"=>[238, 203, 173], "PeachPuff3"=>[205, 175, 149], "PeachPuff4"=>[139, 119, 101], "NavajoWhite1"=>[255, 222, 173], "NavajoWhite2"=>[238, 207, 161], "NavajoWhite3"=>[205, 179, 139], "NavajoWhite4"=>[139, 121, 94], "LemonChiffon1"=>[255, 250, 205], "LemonChiffon2"=>[238, 233, 191], "LemonChiffon3"=>[205, 201, 165], "LemonChiffon4"=>[139, 137, 112], "cornsilk1"=>[255, 248, 220], "cornsilk2"=>[238, 232, 205], "cornsilk3"=>[205, 200, 177], "cornsilk4"=>[139, 136, 120], "ivory1"=>[255, 255, 240], "ivory2"=>[238, 238, 224], "ivory3"=>[205, 205, 193], "ivory4"=>[139, 139, 131], "honeydew1"=>[240, 255, 240], "honeydew2"=>[224, 238, 224], "honeydew3"=>[193, 205, 193], "honeydew4"=>[131, 139, 131], "LavenderBlush1"=>[255, 240, 245], "LavenderBlush2"=>[238, 224, 229], "LavenderBlush3"=>[205, 193, 197], "LavenderBlush4"=>[139, 131, 134], "MistyRose1"=>[255, 228, 225], "MistyRose2"=>[238, 213, 210], "MistyRose3"=>[205, 183, 181], "MistyRose4"=>[139, 125, 123], "azure1"=>[240, 255, 255], "azure2"=>[224, 238, 238], "azure3"=>[193, 205, 205], "azure4"=>[131, 139, 139], "SlateBlue1"=>[131, 111, 255], "SlateBlue2"=>[122, 103, 238], "SlateBlue3"=>[105, 89, 205], "SlateBlue4"=>[71, 60, 139], "RoyalBlue1"=>[72, 118, 255], "RoyalBlue2"=>[67, 110, 238], "RoyalBlue3"=>[58, 95, 205], "RoyalBlue4"=>[39, 64, 139], "blue1"=>[0, 0, 255], "blue2"=>[0, 0, 238], "blue3"=>[0, 0, 205], "blue4"=>[0, 0, 139], "DodgerBlue1"=>[30, 144, 255], "DodgerBlue2"=>[28, 134, 238], "DodgerBlue3"=>[24, 116, 205], "DodgerBlue4"=>[16, 78, 139], "SteelBlue1"=>[99, 184, 255], "SteelBlue2"=>[92, 172, 238], "SteelBlue3"=>[79, 148, 205], "SteelBlue4"=>[54, 100, 139], "DeepSkyBlue1"=>[0, 191, 255], "DeepSkyBlue2"=>[0, 178, 238], "DeepSkyBlue3"=>[0, 154, 205], "DeepSkyBlue4"=>[0, 104, 139], "SkyBlue1"=>[135, 206, 255], "SkyBlue2"=>[126, 192, 238], "SkyBlue3"=>[108, 166, 205], "SkyBlue4"=>[74, 112, 139], "LightSkyBlue1"=>[176, 226, 255], "LightSkyBlue2"=>[164, 211, 238], "LightSkyBlue3"=>[141, 182, 205], "LightSkyBlue4"=>[96, 123, 139], "SlateGray1"=>[198, 226, 255], "SlateGray2"=>[185, 211, 238], "SlateGray3"=>[159, 182, 205], "SlateGray4"=>[108, 123, 139], "LightSteelBlue1"=>[202, 225, 255], "LightSteelBlue2"=>[188, 210, 238], "LightSteelBlue3"=>[162, 181, 205], "LightSteelBlue4"=>[110, 123, 139], "LightBlue1"=>[191, 239, 255], "LightBlue2"=>[178, 223, 238], "LightBlue3"=>[154, 192, 205], "LightBlue4"=>[104, 131, 139], "LightCyan1"=>[224, 255, 255], "LightCyan2"=>[209, 238, 238], "LightCyan3"=>[180, 205, 205], "LightCyan4"=>[122, 139, 139], "PaleTurquoise1"=>[187, 255, 255], "PaleTurquoise2"=>[174, 238, 238], "PaleTurquoise3"=>[150, 205, 205], "PaleTurquoise4"=>[102, 139, 139], "CadetBlue1"=>[152, 245, 255], "CadetBlue2"=>[142, 229, 238], "CadetBlue3"=>[122, 197, 205], "CadetBlue4"=>[83, 134, 139], "turquoise1"=>[0, 245, 255], "turquoise2"=>[0, 229, 238], "turquoise3"=>[0, 197, 205], "turquoise4"=>[0, 134, 139], "cyan1"=>[0, 255, 255], "cyan2"=>[0, 238, 238], "cyan3"=>[0, 205, 205], "cyan4"=>[0, 139, 139], "DarkSlateGray1"=>[151, 255, 255], "DarkSlateGray2"=>[141, 238, 238], "DarkSlateGray3"=>[121, 205, 205], "DarkSlateGray4"=>[82, 139, 139], "aquamarine1"=>[127, 255, 212], "aquamarine2"=>[118, 238, 198], "aquamarine3"=>[102, 205, 170], "aquamarine4"=>[69, 139, 116], "DarkSeaGreen1"=>[193, 255, 193], "DarkSeaGreen2"=>[180, 238, 180], "DarkSeaGreen3"=>[155, 205, 155], "DarkSeaGreen4"=>[105, 139, 105], "SeaGreen1"=>[84, 255, 159], "SeaGreen2"=>[78, 238, 148], "SeaGreen3"=>[67, 205, 128], "SeaGreen4"=>[46, 139, 87], "PaleGreen1"=>[154, 255, 154], "PaleGreen2"=>[144, 238, 144], "PaleGreen3"=>[124, 205, 124], "PaleGreen4"=>[84, 139, 84], "SpringGreen1"=>[0, 255, 127], "SpringGreen2"=>[0, 238, 118], "SpringGreen3"=>[0, 205, 102], "SpringGreen4"=>[0, 139, 69], "green1"=>[0, 255, 0], "green2"=>[0, 238, 0], "green3"=>[0, 205, 0], "green4"=>[0, 139, 0], "chartreuse1"=>[127, 255, 0], "chartreuse2"=>[118, 238, 0], "chartreuse3"=>[102, 205, 0], "chartreuse4"=>[69, 139, 0], "OliveDrab1"=>[192, 255, 62], "OliveDrab2"=>[179, 238, 58], "OliveDrab3"=>[154, 205, 50], "OliveDrab4"=>[105, 139, 34], "DarkOliveGreen1"=>[202, 255, 112], "DarkOliveGreen2"=>[188, 238, 104], "DarkOliveGreen3"=>[162, 205, 90], "DarkOliveGreen4"=>[110, 139, 61], "khaki1"=>[255, 246, 143], "khaki2"=>[238, 230, 133], "khaki3"=>[205, 198, 115], "khaki4"=>[139, 134, 78], "LightGoldenrod1"=>[255, 236, 139], "LightGoldenrod2"=>[238, 220, 130], "LightGoldenrod3"=>[205, 190, 112], "LightGoldenrod4"=>[139, 129, 76], "LightYellow1"=>[255, 255, 224], "LightYellow2"=>[238, 238, 209], "LightYellow3"=>[205, 205, 180], "LightYellow4"=>[139, 139, 122], "yellow1"=>[255, 255, 0], "yellow2"=>[238, 238, 0], "yellow3"=>[205, 205, 0], "yellow4"=>[139, 139, 0], "gold1"=>[255, 215, 0], "gold2"=>[238, 201, 0], "gold3"=>[205, 173, 0], "gold4"=>[139, 117, 0], "goldenrod1"=>[255, 193, 37], "goldenrod2"=>[238, 180, 34], "goldenrod3"=>[205, 155, 29], "goldenrod4"=>[139, 105, 20], "DarkGoldenrod1"=>[255, 185, 15], "DarkGoldenrod2"=>[238, 173, 14], "DarkGoldenrod3"=>[205, 149, 12], "DarkGoldenrod4"=>[139, 101, 8], "RosyBrown1"=>[255, 193, 193], "RosyBrown2"=>[238, 180, 180], "RosyBrown3"=>[205, 155, 155], "RosyBrown4"=>[139, 105, 105], "IndianRed1"=>[255, 106, 106], "IndianRed2"=>[238, 99, 99], "IndianRed3"=>[205, 85, 85], "IndianRed4"=>[139, 58, 58], "sienna1"=>[255, 130, 71], "sienna2"=>[238, 121, 66], "sienna3"=>[205, 104, 57], "sienna4"=>[139, 71, 38], "burlywood1"=>[255, 211, 155], "burlywood2"=>[238, 197, 145], "burlywood3"=>[205, 170, 125], "burlywood4"=>[139, 115, 85], "wheat1"=>[255, 231, 186], "wheat2"=>[238, 216, 174], "wheat3"=>[205, 186, 150], "wheat4"=>[139, 126, 102], "tan1"=>[255, 165, 79], "tan2"=>[238, 154, 73], "tan3"=>[205, 133, 63], "tan4"=>[139, 90, 43], "chocolate1"=>[255, 127, 36], "chocolate2"=>[238, 118, 33], "chocolate3"=>[205, 102, 29], "chocolate4"=>[139, 69, 19], "firebrick1"=>[255, 48, 48], "firebrick2"=>[238, 44, 44], "firebrick3"=>[205, 38, 38], "firebrick4"=>[139, 26, 26], "brown1"=>[255, 64, 64], "brown2"=>[238, 59, 59], "brown3"=>[205, 51, 51], "brown4"=>[139, 35, 35], "salmon1"=>[255, 140, 105], "salmon2"=>[238, 130, 98], "salmon3"=>[205, 112, 84], "salmon4"=>[139, 76, 57], "LightSalmon1"=>[255, 160, 122], "LightSalmon2"=>[238, 149, 114], "LightSalmon3"=>[205, 129, 98], "LightSalmon4"=>[139, 87, 66], "orange1"=>[255, 165, 0], "orange2"=>[238, 154, 0], "orange3"=>[205, 133, 0], "orange4"=>[139, 90, 0], "DarkOrange1"=>[255, 127, 0], "DarkOrange2"=>[238, 118, 0], "DarkOrange3"=>[205, 102, 0], "DarkOrange4"=>[139, 69, 0], "coral1"=>[255, 114, 86], "coral2"=>[238, 106, 80], "coral3"=>[205, 91, 69], "coral4"=>[139, 62, 47], "tomato1"=>[255, 99, 71], "tomato2"=>[238, 92, 66], "tomato3"=>[205, 79, 57], "tomato4"=>[139, 54, 38], "OrangeRed1"=>[255, 69, 0], "OrangeRed2"=>[238, 64, 0], "OrangeRed3"=>[205, 55, 0], "OrangeRed4"=>[139, 37, 0], "red1"=>[255, 0, 0], "red2"=>[238, 0, 0], "red3"=>[205, 0, 0], "red4"=>[139, 0, 0], "DebianRed"=>[215, 7, 81], "DeepPink1"=>[255, 20, 147], "DeepPink2"=>[238, 18, 137], "DeepPink3"=>[205, 16, 118], "DeepPink4"=>[139, 10, 80], "HotPink1"=>[255, 110, 180], "HotPink2"=>[238, 106, 167], "HotPink3"=>[205, 96, 144], "HotPink4"=>[139, 58, 98], "pink1"=>[255, 181, 197], "pink2"=>[238, 169, 184], "pink3"=>[205, 145, 158], "pink4"=>[139, 99, 108], "LightPink1"=>[255, 174, 185], "LightPink2"=>[238, 162, 173], "LightPink3"=>[205, 140, 149], "LightPink4"=>[139, 95, 101], "PaleVioletRed1"=>[255, 130, 171], "PaleVioletRed2"=>[238, 121, 159], "PaleVioletRed3"=>[205, 104, 137], "PaleVioletRed4"=>[139, 71, 93], "maroon1"=>[255, 52, 179], "maroon2"=>[238, 48, 167], "maroon3"=>[205, 41, 144], "maroon4"=>[139, 28, 98], "VioletRed1"=>[255, 62, 150], "VioletRed2"=>[238, 58, 140], "VioletRed3"=>[205, 50, 120], "VioletRed4"=>[139, 34, 82], "magenta1"=>[255, 0, 255], "magenta2"=>[238, 0, 238], "magenta3"=>[205, 0, 205], "magenta4"=>[139, 0, 139], "orchid1"=>[255, 131, 250], "orchid2"=>[238, 122, 233], "orchid3"=>[205, 105, 201], "orchid4"=>[139, 71, 137], "plum1"=>[255, 187, 255], "plum2"=>[238, 174, 238], "plum3"=>[205, 150, 205], "plum4"=>[139, 102, 139], "MediumOrchid1"=>[224, 102, 255], "MediumOrchid2"=>[209, 95, 238], "MediumOrchid3"=>[180, 82, 205], "MediumOrchid4"=>[122, 55, 139], "DarkOrchid1"=>[191, 62, 255], "DarkOrchid2"=>[178, 58, 238], "DarkOrchid3"=>[154, 50, 205], "DarkOrchid4"=>[104, 34, 139], "purple1"=>[155, 48, 255], "purple2"=>[145, 44, 238], "purple3"=>[125, 38, 205], "purple4"=>[85, 26, 139], "MediumPurple1"=>[171, 130, 255], "MediumPurple2"=>[159, 121, 238], "MediumPurple3"=>[137, 104, 205], "MediumPurple4"=>[93, 71, 139], "thistle1"=>[255, 225, 255], "thistle2"=>[238, 210, 238], "thistle3"=>[205, 181, 205], "thistle4"=>[139, 123, 139], "gray0"=>[0, 0, 0], "grey0"=>[0, 0, 0], "gray1"=>[3, 3, 3], "grey1"=>[3, 3, 3], "gray2"=>[5, 5, 5], "grey2"=>[5, 5, 5], "gray3"=>[8, 8, 8], "grey3"=>[8, 8, 8], "gray4"=>[10, 10, 10], "grey4"=>[10, 10, 10], "gray5"=>[13, 13, 13], "grey5"=>[13, 13, 13], "gray6"=>[15, 15, 15], "grey6"=>[15, 15, 15], "gray7"=>[18, 18, 18], "grey7"=>[18, 18, 18], "gray8"=>[20, 20, 20], "grey8"=>[20, 20, 20], "gray9"=>[23, 23, 23], "grey9"=>[23, 23, 23], "gray10"=>[26, 26, 26], "grey10"=>[26, 26, 26], "gray11"=>[28, 28, 28], "grey11"=>[28, 28, 28], "gray12"=>[31, 31, 31], "grey12"=>[31, 31, 31], "gray13"=>[33, 33, 33], "grey13"=>[33, 33, 33], "gray14"=>[36, 36, 36], "grey14"=>[36, 36, 36], "gray15"=>[38, 38, 38], "grey15"=>[38, 38, 38], "gray16"=>[41, 41, 41], "grey16"=>[41, 41, 41], "gray17"=>[43, 43, 43], "grey17"=>[43, 43, 43], "gray18"=>[46, 46, 46], "grey18"=>[46, 46, 46], "gray19"=>[48, 48, 48], "grey19"=>[48, 48, 48], "gray20"=>[51, 51, 51], "grey20"=>[51, 51, 51], "gray21"=>[54, 54, 54], "grey21"=>[54, 54, 54], "gray22"=>[56, 56, 56], "grey22"=>[56, 56, 56], "gray23"=>[59, 59, 59], "grey23"=>[59, 59, 59], "gray24"=>[61, 61, 61], "grey24"=>[61, 61, 61], "gray25"=>[64, 64, 64], "grey25"=>[64, 64, 64], "gray26"=>[66, 66, 66], "grey26"=>[66, 66, 66], "gray27"=>[69, 69, 69], "grey27"=>[69, 69, 69], "gray28"=>[71, 71, 71], "grey28"=>[71, 71, 71], "gray29"=>[74, 74, 74], "grey29"=>[74, 74, 74], "gray30"=>[77, 77, 77], "grey30"=>[77, 77, 77], "gray31"=>[79, 79, 79], "grey31"=>[79, 79, 79], "gray32"=>[82, 82, 82], "grey32"=>[82, 82, 82], "gray33"=>[84, 84, 84], "grey33"=>[84, 84, 84], "gray34"=>[87, 87, 87], "grey34"=>[87, 87, 87], "gray35"=>[89, 89, 89], "grey35"=>[89, 89, 89], "gray36"=>[92, 92, 92], "grey36"=>[92, 92, 92], "gray37"=>[94, 94, 94], "grey37"=>[94, 94, 94], "gray38"=>[97, 97, 97], "grey38"=>[97, 97, 97], "gray39"=>[99, 99, 99], "grey39"=>[99, 99, 99], "gray40"=>[102, 102, 102], "grey40"=>[102, 102, 102], "gray41"=>[105, 105, 105], "grey41"=>[105, 105, 105], "gray42"=>[107, 107, 107], "grey42"=>[107, 107, 107], "gray43"=>[110, 110, 110], "grey43"=>[110, 110, 110], "gray44"=>[112, 112, 112], "grey44"=>[112, 112, 112], "gray45"=>[115, 115, 115], "grey45"=>[115, 115, 115], "gray46"=>[117, 117, 117], "grey46"=>[117, 117, 117], "gray47"=>[120, 120, 120], "grey47"=>[120, 120, 120], "gray48"=>[122, 122, 122], "grey48"=>[122, 122, 122], "gray49"=>[125, 125, 125], "grey49"=>[125, 125, 125], "gray50"=>[127, 127, 127], "grey50"=>[127, 127, 127], "gray51"=>[130, 130, 130], "grey51"=>[130, 130, 130], "gray52"=>[133, 133, 133], "grey52"=>[133, 133, 133], "gray53"=>[135, 135, 135], "grey53"=>[135, 135, 135], "gray54"=>[138, 138, 138], "grey54"=>[138, 138, 138], "gray55"=>[140, 140, 140], "grey55"=>[140, 140, 140], "gray56"=>[143, 143, 143], "grey56"=>[143, 143, 143], "gray57"=>[145, 145, 145], "grey57"=>[145, 145, 145], "gray58"=>[148, 148, 148], "grey58"=>[148, 148, 148], "gray59"=>[150, 150, 150], "grey59"=>[150, 150, 150], "gray60"=>[153, 153, 153], "grey60"=>[153, 153, 153], "gray61"=>[156, 156, 156], "grey61"=>[156, 156, 156], "gray62"=>[158, 158, 158], "grey62"=>[158, 158, 158], "gray63"=>[161, 161, 161], "grey63"=>[161, 161, 161], "gray64"=>[163, 163, 163], "grey64"=>[163, 163, 163], "gray65"=>[166, 166, 166], "grey65"=>[166, 166, 166], "gray66"=>[168, 168, 168], "grey66"=>[168, 168, 168], "gray67"=>[171, 171, 171], "grey67"=>[171, 171, 171], "gray68"=>[173, 173, 173], "grey68"=>[173, 173, 173], "gray69"=>[176, 176, 176], "grey69"=>[176, 176, 176], "gray70"=>[179, 179, 179], "grey70"=>[179, 179, 179], "gray71"=>[181, 181, 181], "grey71"=>[181, 181, 181], "gray72"=>[184, 184, 184], "grey72"=>[184, 184, 184], "gray73"=>[186, 186, 186], "grey73"=>[186, 186, 186], "gray74"=>[189, 189, 189], "grey74"=>[189, 189, 189], "gray75"=>[191, 191, 191], "grey75"=>[191, 191, 191], "gray76"=>[194, 194, 194], "grey76"=>[194, 194, 194], "gray77"=>[196, 196, 196], "grey77"=>[196, 196, 196], "gray78"=>[199, 199, 199], "grey78"=>[199, 199, 199], "gray79"=>[201, 201, 201], "grey79"=>[201, 201, 201], "gray80"=>[204, 204, 204], "grey80"=>[204, 204, 204], "gray81"=>[207, 207, 207], "grey81"=>[207, 207, 207], "gray82"=>[209, 209, 209], "grey82"=>[209, 209, 209], "gray83"=>[212, 212, 212], "grey83"=>[212, 212, 212], "gray84"=>[214, 214, 214], "grey84"=>[214, 214, 214], "gray85"=>[217, 217, 217], "grey85"=>[217, 217, 217], "gray86"=>[219, 219, 219], "grey86"=>[219, 219, 219], "gray87"=>[222, 222, 222], "grey87"=>[222, 222, 222], "gray88"=>[224, 224, 224], "grey88"=>[224, 224, 224], "gray89"=>[227, 227, 227], "grey89"=>[227, 227, 227], "gray90"=>[229, 229, 229], "grey90"=>[229, 229, 229], "gray91"=>[232, 232, 232], "grey91"=>[232, 232, 232], "gray92"=>[235, 235, 235], "grey92"=>[235, 235, 235], "gray93"=>[237, 237, 237], "grey93"=>[237, 237, 237], "gray94"=>[240, 240, 240], "grey94"=>[240, 240, 240], "gray95"=>[242, 242, 242], "grey95"=>[242, 242, 242], "gray96"=>[245, 245, 245], "grey96"=>[245, 245, 245], "gray97"=>[247, 247, 247], "grey97"=>[247, 247, 247], "gray98"=>[250, 250, 250], "grey98"=>[250, 250, 250], "gray99"=>[252, 252, 252], "grey99"=>[252, 252, 252], "gray100"=>[255, 255, 255], "grey100"=>[255, 255, 255], "dark grey"=>[169, 169, 169], "DarkGrey"=>[169, 169, 169], "dark gray"=>[169, 169, 169], "DarkGray"=>[169, 169, 169], "dark blue"=>[0, 0, 139], "DarkBlue"=>[0, 0, 139], "dark cyan"=>[0, 139, 139], "DarkCyan"=>[0, 139, 139], "dark magenta"=>[139, 0, 139], "DarkMagenta"=>[139, 0, 139], "dark red"=>[139, 0, 0], "DarkRed"=>[139, 0, 0], "light green"=>[144, 238, 144], "LightGreen"=>[144, 238, 144]}
6
6
  end
7
7
 
8
8
  # J-_-L
@@ -0,0 +1,27 @@
1
+ module Paint
2
+ # A list of color names for standard ansi colors, needed for 16/8 color fallback mode
3
+ # See http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
4
+ RGB_COLORS_ANSI = {
5
+ :black => [0,0,0],
6
+ :red => [205,0,0],
7
+ :green => [0,205,0],
8
+ :yellow => [205,205,0],
9
+ :blue => [0,0,238],
10
+ :magenta => [205,0,205],
11
+ :cyan => [0,205,205],
12
+ :white => [229,229,229],
13
+ }
14
+
15
+ # A list of color names for standard bright ansi colors, needed for 16 color fallback mode
16
+ # See http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
17
+ RGB_COLORS_ANSI_BRIGHT = {
18
+ :black => [127,127,127],
19
+ :red => [255,0,0],
20
+ :green => [0,255,0],
21
+ :yellow => [255,255,0],
22
+ :blue => [92,92,255],
23
+ :magenta => [255,0,255],
24
+ :cyan => [0,255,255],
25
+ :white => [255,255,255],
26
+ }
27
+ end
@@ -8,8 +8,8 @@ module Paint
8
8
 
9
9
  # Tries to print all 256 colors
10
10
  def rainbow
11
- (0..256).each{ |color|
12
- print Paint[' ',48,5,color] # print empty bg color field
11
+ (0...256).each{ |color|
12
+ print Paint[' ', 48, 5, color] # print empty bg color field
13
13
  }
14
14
  puts
15
15
  end
@@ -22,13 +22,40 @@ module Paint
22
22
  File.open(path, 'r') do |file|
23
23
  file.each_line{ |line|
24
24
  line.chomp =~ /(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/
25
- Paint::RGB_COLORS[$4] = Paint.send:rgb_value, $1, $2, $3 if $4
25
+ Paint::RGB_COLORS[$4] = [$1.to_i, $2.to_i, $3.to_i] if $4
26
26
  }
27
27
  end
28
28
  else
29
29
  raise ArgumentError, "Not a valid file: #{path}"
30
30
  end
31
31
  end
32
+
33
+ # Determine supported colors
34
+ # This is just a naive approach, based on some things I could test
35
+ # Please open issues if it does not work correctly for you
36
+ def detect_mode
37
+ if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ # windows
38
+ if ENV['ANSICON']
39
+ 16
40
+ else
41
+ false
42
+ end
43
+ else
44
+ # case ENV['COLORTERM']
45
+ # when 'gnome-terminal'
46
+ # 256
47
+ # else
48
+ case ENV['TERM']
49
+ when /-256color$/, 'xterm'
50
+ 256
51
+ when /-color$/, 'rxvt'
52
+ 16
53
+ else # optimistic default
54
+ 256
55
+ end
56
+ # end
57
+ end
58
+ end
32
59
  end
33
60
  end
34
61
 
@@ -1,3 +1,3 @@
1
1
  module Paint
2
- VERSION = '0.8.0'
2
+ VERSION = '0.8.1'
3
3
  end
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Jan Lelis"]
9
9
  s.email = "mail@janlelis.de"
10
10
  s.homepage = "https://github.com/janlelis/paint"
11
- s.summary = "Yet another terminal colors gem"
12
- s.description = "Yet another terminal colors gem / no string extensions / 256 color support / effect support / define custom shortcuts"
11
+ s.summary = "Terminal painter!"
12
+ s.description = "Terminal painter / no string extensions / 256 color support / effect support / define custom shortcuts / basic usage: Paint['string', :red, :bright]"
13
13
  s.required_ruby_version = '>= 1.8.7'
14
14
  s.files = Dir.glob(%w[{lib,test,spec}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c}]) + %w{Rakefile paint.gemspec .gemtest}
15
15
  s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
@@ -13,18 +13,26 @@ describe 'Paint.simple' do
13
13
  end
14
14
 
15
15
  describe 'Paint.rgb' do
16
+ before do
17
+ Paint.mode = 256
18
+ end
19
+
16
20
  it 'returns ansi code sequence for one of 256 colors' do
17
- Paint.rgb(1,2,3).should == '38;5;16'
21
+ Paint.rgb(1,2,3).should == '38;5;232'
18
22
  end
19
23
 
20
24
  it 'returns background ansi code sequence for one of 256 colors if last parameter is true' do
21
- Paint.rgb(1, 2, 3, true).should == '48;5;16'
25
+ Paint.rgb(1, 2, 3, true).should == '48;5;232'
22
26
  end
23
27
  end
24
28
 
25
29
  describe 'Paint.hex' do
30
+ before do
31
+ Paint.mode = 256
32
+ end
33
+
26
34
  it 'returns ansi code sequence for one of 256 colors' do
27
- Paint.hex("#fff").should == "38;5;231"
35
+ Paint.hex("#fff").should == "38;5;255"
28
36
  end
29
37
 
30
38
  it 'returns background ansi code sequence for one of 256 colors if second parameter is true' do
@@ -32,13 +40,17 @@ describe 'Paint.hex' do
32
40
  end
33
41
  end
34
42
 
35
- describe 'Paint.name' do
43
+ describe 'Paint.rbb_name' do
44
+ before do
45
+ Paint.mode = 256
46
+ end
47
+
36
48
  it 'returns ansi code sequence for one of 256 colors' do
37
- Paint.name("gold").should == "38;5;226"
49
+ Paint.rgb_name("gold").should == "38;5;226"
38
50
  end
39
51
 
40
52
  it 'returns background ansi code sequence for one of 256 colors if second parameter is true' do
41
- Paint.name("gold", true).should == "48;5;226"
53
+ Paint.rgb_name("gold", true).should == "48;5;226"
42
54
  end
43
55
  end
44
56
 
@@ -0,0 +1,21 @@
1
+ describe 'Paint.mode' do
2
+ it "works normally if mode is 256 or another unknown true value" do
3
+ Paint.mode = 256
4
+ Paint['J-_-L', 'gold'].should == "\e[38;5;226mJ-_-L\e[0m"
5
+ end
6
+
7
+ it "doesn't colorize anything if mode is false" do
8
+ Paint.mode = false
9
+ Paint['J-_-L', 'gold'].should == "J-_-L"
10
+ end
11
+
12
+ it "only uses the 8 ansi colors if mode is 8" do
13
+ Paint.mode = 8
14
+ Paint['J-_-L', 'gold'].should == "\e[33mJ-_-L\e[0m"
15
+ end
16
+
17
+ it "only uses the 8 ansi colors with bright effect if mode is 16" do
18
+ Paint.mode = 16
19
+ Paint['J-_-L', 'gold'].should == "\e[33;1mJ-_-L\e[0m"
20
+ end
21
+ end
@@ -1,4 +1,8 @@
1
1
  describe 'Paint.[]' do
2
+ before do
3
+ Paint.mode = 256
4
+ end
5
+
2
6
  context '(with no options)' do
3
7
  it 'colorizes using a random ansi foreground color' do
4
8
  Paint['J-_-L'].should =~ /\e\[3\dmJ-_-L\e\[0m/
@@ -23,11 +27,11 @@ describe 'Paint.[]' do
23
27
  end
24
28
 
25
29
  it 'understands a hex string (with #, 3 digits) as rgb color definition and use it as foreground color' do
26
- Paint['J-_-L', "#fff"].should == "\e[38;5;231mJ-_-L\e[0m"
30
+ Paint['J-_-L', "#fff"].should == "\e[38;5;255mJ-_-L\e[0m"
27
31
  end
28
32
 
29
33
  it 'understands a hex string (no #, 3 digits) as rgb color definition and use it as foreground color' do
30
- Paint['J-_-L', "fff"].should == "\e[38;5;231mJ-_-L\e[0m"
34
+ Paint['J-_-L', "fff"].should == "\e[38;5;255mJ-_-L\e[0m"
31
35
  end
32
36
 
33
37
  it 'understands a non-hex string as rgb color name (rgb.txt) and use it as foreground color' do
@@ -41,7 +45,7 @@ describe 'Paint.[]' do
41
45
  end
42
46
 
43
47
  it 'interprets the first color as foreground color and the second one as background color (rgb)' do
44
- Paint['J-_-L', '#424242', [42, 142, 242]].should == "\e[38;5;59;48;5;39mJ-_-L\e[0m"
48
+ Paint['J-_-L', '#424242', [42, 142, 242]].should == "\e[38;5;238;48;5;39mJ-_-L\e[0m"
45
49
  end
46
50
 
47
51
  it 'sets only a background color, if first color is nil' do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: paint
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.8.0
5
+ version: 0.8.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jan Lelis
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-29 00:00:00 Z
13
+ date: 2011-07-07 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: "0"
46
46
  type: :development
47
47
  version_requirements: *id003
48
- description: Yet another terminal colors gem / no string extensions / 256 color support / effect support / define custom shortcuts
48
+ description: "Terminal painter / no string extensions / 256 color support / effect support / define custom shortcuts / basic usage: Paint['string', :red, :bright]"
49
49
  email: mail@janlelis.de
50
50
  executables: []
51
51
 
@@ -59,8 +59,10 @@ files:
59
59
  - lib/paint/util.rb
60
60
  - lib/paint/shortcuts.rb
61
61
  - lib/paint/pa.rb
62
+ - lib/paint/rgb_colors_ansi.rb
62
63
  - lib/paint/version.rb
63
64
  - lib/paint.rb
65
+ - spec/paint_mode_spec.rb
64
66
  - spec/spec_helper.rb
65
67
  - spec/paint_methods_spec.rb
66
68
  - spec/paint_spec.rb
@@ -97,6 +99,6 @@ rubyforge_project:
97
99
  rubygems_version: 1.8.1
98
100
  signing_key:
99
101
  specification_version: 3
100
- summary: Yet another terminal colors gem
102
+ summary: Terminal painter!
101
103
  test_files: []
102
104