pax_global_header00006660000000000000000000000064121350411540014506gustar00rootroot0000000000000052 comment=e080e02ab6866d77a3505ababbbe868a66c9c983 ruby-paint-0.8.6/000077500000000000000000000000001213504115400136135ustar00rootroot00000000000000ruby-paint-0.8.6/.gemtest000066400000000000000000000000001213504115400152520ustar00rootroot00000000000000ruby-paint-0.8.6/.gitignore000066400000000000000000000000731213504115400156030ustar00rootroot00000000000000*.rbc Rakefile.compiled.rbc *.swp *~ pkg .rbx Gemfile.lock ruby-paint-0.8.6/.rspec000066400000000000000000000000401213504115400147220ustar00rootroot00000000000000--colour --format documentation ruby-paint-0.8.6/.travis.yml000066400000000000000000000002151213504115400157220ustar00rootroot00000000000000language: ruby rvm: - ruby-head - 2.0.0 - 1.9.3 - 1.9.2 - 1.8.7 - ree - rbx-19mode - rbx-18mode - jruby-head - jruby-19mode - jruby-18mode ruby-paint-0.8.6/CHANGELOG.rdoc000066400000000000000000000015431213504115400157560ustar00rootroot00000000000000=== 0.8.6 * Add missing require 'rbconfig' and travis test everything === 0.8.5 * Support 256 color on windows' ConEmu === 0.8.4 * Fix post-install message unicode === 0.8.3 * Paint.[] also accepts uppercased hex strings (gh#2) * Performance tweaks (thanks to murphy) (gh#4, #5) * API change: deactivate colorizing with Paint.mode = 0 === 0.8.2 * Paint.[] with only a single string argument does not colorize the string anymore, but returns the plain string * New pseudo color :random - returns a random ansi color === 0.8.1 * Improve rgb function with better gray scale values * Add Paint.mode: * Set to 0 to deactivate colorizing * Set to 16 or 8 and all color generation methods will generate simple ansi colors * Set to 256 for 256 color support * Tries to automatically detect your terminal's features * Minor changes === 0.8.0 * Initial release ruby-paint-0.8.6/Gemfile000066400000000000000000000000471213504115400151070ustar00rootroot00000000000000source 'https://rubygems.org' gemspec ruby-paint-0.8.6/LICENSE.txt000066400000000000000000000020631213504115400154370ustar00rootroot00000000000000The MIT LICENSE Copyright (c) 2011-2013 Jan Lelis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ruby-paint-0.8.6/README.rdoc000066400000000000000000000173761213504115400154370ustar00rootroot00000000000000{}[https://travis-ci.org/janlelis/paint] Paint manages terminal colors and effects for you. It combines the strengths of *term-ansicolor*, *rainbow* and other similar projects into a simple to use, however still flexible terminal colorization gem with no core extensions by default. == Features * No string extensions (suitable for library development) * Supports setting 256 colors (for capable terminals) * Supports setting any effects (although most terminals won't support it) * Simple to use * Custom shortcuts can be defined and flexibly mixed in * Fall-back modes for non-256-color terminals (Paint.mode), supported modes: * 256 colors * 16 colors (only ansi colors, combined with bright effect) * 8 colors (only ansi colors) * 0 colors (deactivate) == Setup Install with: gem install paint In Ruby do: require 'paint' == Usage The only method you need to know to get started is: Paint.[] The first argument given to Paint.[] is the string to colorize (if the object is not a string, to_s will be called on the object). The other arguments describe how to modify/colorize the string. Let's learn by example: Paint['Ruby', :red] # sets ansi color red Paint['Ruby', :red, :bright] # also applies bright/bold effect Paint['Ruby', :bright, :red] # does the same as above Paint['Ruby', :red, :bright, :underline] # effects can often be combined Paint['Ruby', :red, :blue] # the second color you define is for background Paint['Ruby', nil, :blue] # pass a nil before a color to ignore foreground and only set background color Paint['Ruby', [100, 255, 5]] # you can define rgb colors that map to one of 256 colors. Only supported on 256-color terminals, of course Paint['Ruby', "gold", "snow"] # Paint supports rgb.txt color names, note that the arguments are strings (:yellow != "yellow")! Paint['Ruby', "#123456"] # html like definitions are possible. Paint['Ruby', "fff"] # another html hex definition Paint['Ruby', :random] # pass :random to get one of eight random ansi foreground colors Paint['Ruby', :inverse] # swaps fore- and background Paint['Ruby', :italic, :encircle, :rapid_blink, :overline] # probably not supported effects Paint['Ruby'] # don't pass any argument and the string will not be changed If you pass multiple colors, the first one is taken as foreground color and the second one defines the background color (all others will be ignored). To only change the background color, you have to pass a nil first. Effects can be passed in any order. You can find more examples in the specs. == Windows Support For ANSI support in Windows OS, you can use {ansicon}[https://github.com/adoxa/ansicon] or {ConEmu}[http://code.google.com/p/conemu-maximus5/]. == More details about terminal colors and effects Terminal colors/effects are set by {ansi escape sequences}[http://en.wikipedia.org/wiki/ANSI_escape_code]. These are strings that look like this: \e[X;X;X;X;X]m 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: :black, :red, :green, :yellow, :blue, :magenta, :cyan, :white, (:default) When combined with the :bright (= :bold) effect, the color in the terminal emulator often differs a little bit. Through special sequences it's also possible to set 256-colors, instead of 8, which is also supported by many - but not all - terminals. Paint automatically translates given rgb colors to a suitable color of the 256 available colors. When using the Paint.[] method, Paint wraps the given string between the calculated escape sequence and an reset sequence ("\e[0m"). You can get the raw escape sequence by using the Paint.color method. === Effects Also see {en.wikipedia.org/wiki/ANSI_escape_code}[http://en.wikipedia.org/wiki/ANSI_escape_code]: ==== Often supported 0) :reset, :nothing 1) :bright, :bold 4) :underline 7) :inverse, :negative 8) :conceal, :hide 22) :clean 24) :underline_off 26) :inverse_off, :positive 27) :conceal_off, :show, :reveal ==== Not widely supported 2) :faint 3) :italic 5) :blink, :slow_blink 6) :rapid_blink 9) :crossed, :crossed_out 10) :default_font, :font0 11-19) :font1, :font2, :font3, :font4, :font5, :font6, :font7, :font8, :font9 20) :fraktur 21) :bright_off, :bold_off, :double_underline 23) :italic_off, :fraktur_off 25) :blink_off 29) :crossed_off, :crossed_out_off 51) :frame 52) :encircle 53) :overline 54) :frame_off, :encircle_off 55) :overline_off == Paint.mode You can choose between four ways to use Paint.[] by setting Paint.mode to one of the following: * 256: full support * 16: don't use 256 colors, but the ansi eight ones (combined with bright effect) * 8: don't use 256 colors, but the ansi eight ones * 0: don't colorize at all Paint tries to automatically detect the proper value, please open an issue if Paint.detect_mode yields a wrong value for you. == Advanced Usage: Shortcuts Now for the fancy part: You can create color shortcuts for your gems and scripts! Note: You don't have to use this feature (and only stick to Paint.[] instead) ;) It's easy: Just setup a hash of symbol keys and escape string values at: Paint::SHORTCUTS[:your_namespace]. They are stored directly as escape sequences for performance reasons (this also means, you need different namespaces for different Paint.modes). Example: Paint::SHORTCUTS[:example] = { :white => Paint.color(:black), :red => Paint.color(:red, :bright), :title => Paint.color(:underline), } The methods become "rubymagically" available in a Paint child model: Paint::Example.red 'Ruby' # => "\e[31;1mRuby\e[0m" Paint::Example.white # => "\e[37m" As you can see, the helper methods look useful and can take either one (wrap string) or none (only color) arguments ...but they aren't really short yet. Fortunately, you can include them: include Paint::Example red # => "\e[31;1m" white 'Ruby' # => "\e[30m" All shortcuts, defined in your shortcut namespace at this time, are now (privately) available in your current namespace (without using a method_missing implementation). Furthermore, there are two variations of this approach: include Paint::Example::String "Ruby".title # => "\e[4mRuby\e[0m" 5.red # => "\e[31;1m5\e[0m" In this case, self will be converted to a string and wrapped with the specific color code. Note, that the helper methods doesn't take any arguments when using this inclusion method. The third way allows you to get a single color helper method to avoid cluttering namespaces: include Paint::Example::Prefix::ExampleName "Ruby".example_name(:red) # => "\e[31;1mRuby\e[0m" === Utilities There are some supporting methods available. You can get a p like alternative for calling puts Paint.[]: require 'paint/pa' pa "Ruby", :red, :underline # same as puts Paint["Ruby", :red, :underline] Another helper method is Paint.unpaint, which removes any ansi colors: Paint.unpaint( Paint['J-_-L', :red, :bright] ).should == 'J-_-L' == J-_-L Copyright (c) 2011-2013 Jan Lelis, http://rbjl.net, released under the MIT license. Mainly influenced by rainbow[https://github.com/sickill/rainbow] and {term-ansicolor}[https://github.com/flori/term-ansicolor]. Contributions[https://github.com/janlelis/paint/contributors] by and thanks to: * {murphy}[https://github.com/rubychan] * {CyberShadow}[https://github.com/CyberShadow] ruby-paint-0.8.6/Rakefile000066400000000000000000000045171213504115400152670ustar00rootroot00000000000000GEMSPEC = 'paint.gemspec' #require 'rake' #require 'rake/rdoctask' require 'fileutils' require 'rspec/core/rake_task' task :default => :spec task :test => :spec RSpec::Core::RakeTask.new(:spec) do |t| t.rspec_opts = [ '--colour', '--format documentation', '-r ' + File.expand_path( File.join( 'spec', 'spec_helper') ), ] end def gemspec @gemspec ||= eval(File.read(GEMSPEC), binding, GEMSPEC) end desc "Build the gem" task :gem => :gemspec do sh "gem build #{GEMSPEC}" FileUtils.mkdir_p 'pkg' FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg' end desc "Install the gem locally" task :install => :gem do sh %{gem install pkg/#{gemspec.name}-#{gemspec.version} --no-rdoc --no-ri} end desc "Generate the gemspec" task :generate do puts gemspec.to_ruby end desc "Validate the gemspec" task :gemspec do gemspec.validate end #Rake::RDocTask.new do |rdoc| # require File.expand_path( File.join( 'lib', 'paint') ) # # rdoc.rdoc_dir = 'doc' # rdoc.title = "paint #{Paint::VERSION}" # rdoc.rdoc_files.include('README*') # rdoc.rdoc_files.include('lib/**/*.rb') #end desc "Run a Benchmark" task :benchmark do require 'benchmark' require 'term/ansicolor' class String include Term::ANSIColor end require 'rainbow' $:.unshift '../lib' require 'paint' n = 100_000 colors = [:black, :red, :green, :yellow, :blue, :magenta, :cyan] def colors.next @index ||= 0 at((@index += 1) % size) end Benchmark.bmbm 30 do |results| string = 'Ruby is awesome!' results.report 'cycle' do n.times do colors.next end end results.report 'paint' do n.times do Paint[string, colors.next] end end results.report 'term-ansicolor' do n.times do string.send(colors.next) end end results.report 'rainbow' do n.times do string.color(colors.next) end end results.report 'paint with background' do n.times do Paint[string, colors.next, colors.next] end end results.report 'term-ansicolor with background' do n.times do string.send(colors.next).send("on_#{colors.next}") end end results.report 'rainbow with background' do n.times do string.color(colors.next).background(colors.next) end end end end ruby-paint-0.8.6/lib/000077500000000000000000000000001213504115400143615ustar00rootroot00000000000000ruby-paint-0.8.6/lib/paint.rb000066400000000000000000000175131213504115400160300ustar00rootroot00000000000000require 'paint/version' unless defined? Paint::VERSION require 'paint/shortcuts'unless defined? Paint::SHORTCUTS require 'paint/util' module Paint autoload :RGB_COLORS, 'paint/rgb_colors' autoload :RGB_COLORS_ANSI, 'paint/rgb_colors_ansi' # Important purpose NOTHING = "\033[0m" # Basic colors (often, the color differs when using the bright effect) # Final color will be 30 + value for foreground and 40 + value for background ANSI_COLORS = { :black => 0, :red => 1, :green => 2, :yellow => 3, :blue => 4, :magenta => 5, :cyan => 6, :white => 7, :default => 9, } # Terminal effects - most of them are not supported ;) # See http://en.wikipedia.org/wiki/ANSI_escape_code ANSI_EFFECTS = { :reset => 0, :nothing => 0, # usually supported :bright => 1, :bold => 1, # usually supported :faint => 2, :italic => 3, :underline => 4, # usually supported :blink => 5, :slow_blink => 5, :rapid_blink => 6, :inverse => 7, :swap => 7, # usually supported :conceal => 8, :hide => 9, :default_font => 10, :font0 => 10, :font1 => 11, :font2 => 12, :font3 => 13, :font4 => 14, :font5 => 15, :font6 => 16, :font7 => 17, :font8 => 18, :font9 => 19, :fraktur => 20, :bright_off => 21, :bold_off => 21, :double_underline => 21, :clean => 22, :italic_off => 23, :fraktur_off => 23, :underline_off => 24, :blink_off => 25, :inverse_off => 26, :positive => 26, :conceal_off => 27, :show => 27, :reveal => 27, :crossed_off => 29, :crossed_out_off => 29, :frame => 51, :encircle => 52, :overline => 53, :frame_off => 54, :encircle_off => 54, :overline_off => 55, } # cache ANSI_COLORS_FOREGROUND = { :black => '30', :red => '31', :green => '32', :yellow => '33', :blue => '34', :magenta => '35', :cyan => '36', :white => '37', :default => '39', } # cache ANSI_COLORS_BACKGROUND = { :black => '40', :red => '41', :green => '42', :yellow => '43', :blue => '44', :magenta => '45', :cyan => '46', :white => '47', :default => '49', } class << self # Takes a string and color options and colorizes the string # See README.rdoc for details def [](string, *options) return string.to_s if mode.zero? || options.empty? if options.size == 1 && !options.first.respond_to?(:to_ary) options = options.first end cache[options] + string.to_s + NOTHING end # Sometimes, you only need the color # Used by [] def color(*options) return '' if mode.zero? || options.empty? mix = [] color_seen = false colors = ANSI_COLORS_FOREGROUND options.each{ |option| case option when Symbol if color = colors[option] mix << color color_seen = :set elsif ANSI_EFFECTS.key?(option) mix << effect(option) elsif option == :random mix << random(color_seen) color_seen = :set else raise ArgumentError, "Unknown color or effect: #{ option }" end when Array if option.size == 3 && option.all?{ |n| n.is_a? Numeric } mix << rgb(*(option + [color_seen])) # 1.8 workaround color_seen = :set else raise ArgumentError, "Array argument must contain 3 numerals" end when ::String if option =~ /^#?(?:[0-9a-f]{3}){1,2}$/i mix << hex(option, color_seen) color_seen = :set else mix << rgb_name(option, color_seen) color_seen = :set end when Numeric integer = option.to_i color_seen = :set if (30..49).include?(integer) mix << integer when nil color_seen = :set else raise ArgumentError, "Invalid argument: #{ option.inspect }" end if color_seen == :set colors = ANSI_COLORS_BACKGROUND color_seen = true end } wrap(*mix) end # This variable influences the color code generation # Currently supported values: # * 256 - 256 colors # * 16 - only ansi colors and bright effect # * 8 - only ansi colors # * 0 - no colorization! def mode() @mode ||= detect_mode end def mode=(val) cache.clear; @mode = val end # Adds ansi sequence def wrap(*ansi_codes) "\033[" + ansi_codes*";" + "m" end # Creates simple ansi color by looking it up on Paint::ANSI_COLORS def simple(color_name, background = false) (background ? 40 : 30) + ANSI_COLORS[color_name] end # Creates a 256-compatible color from rgb values def rgb(red, green, blue, background = false) if mode == 8 || mode == 16 "#{background ? 4 : 3}#{rgb_like_value(red, green, blue, mode == 16)}" else "#{background ? 48 : 38}#{rgb_value(red, green, blue)}" end end # Creates 256-compatible color from a html-like color string def hex(string, background = false) string.tr! '#','' rgb( *(if string.size == 6 # string.chars.each_cons(2).map{ |hex_color| hex_color.join.to_i(16) } [string[0,2].to_i(16), string[2,2].to_i(16), string[4,2].to_i(16)] else string.chars.map{ |hex_color_half| (hex_color_half*2).to_i(16) } end + [background]) # 1.8 workaround ) end # Creates a 256-color from a name found in Paint::RGB_COLORS (based on rgb.txt) def rgb_name(color_name, background = false) if color_code = RGB_COLORS[color_name] rgb(*(color_code + [background] )) # 1.8 workaround end end # Creates a random ansi color def random(background = false) (background ? 40 : 30) + rand(8) end # Creates the specified effect by looking it up in Paint::ANSI_EFFECTS def effect(effect_name) ANSI_EFFECTS[effect_name] end private def cache @cache ||= Hash.new { |h, k| h[k] = color(*k) } end # Returns nearest supported 256-color an rgb value, without fore-/background information # Inspired by the rainbow gem def rgb_value(red, green, blue) gray_possible = true sep = 42.5 while gray_possible if red < sep || green < sep || blue < sep gray = red < sep && green < sep && blue < sep gray_possible = false end sep += 42.5 end if gray ";5;#{ 232 + ((red.to_f + green.to_f + blue.to_f)/33).round }" else # rgb ";5;#{ [16, *[red, green, blue].zip([36, 6, 1]).map{ |color, mod| (6 * (color.to_f / 256)).to_i * mod }].inject(:+) }" end end # Returns ansi color matching an rgb value, without fore-/background information # See http://mail.python.org/pipermail/python-list/2008-December/1150496.html def rgb_like_value(red, green, blue, use_bright = false) color_pool = RGB_COLORS_ANSI.values color_pool += RGB_COLORS_ANSI_BRIGHT.values if use_bright ansi_color_rgb = color_pool.min_by{ |col| distance([red, green, blue],col) } key_method = RUBY_VERSION < "1.9" ? :index : :key if ansi_color = RGB_COLORS_ANSI.send(key_method, ansi_color_rgb) ANSI_COLORS[ansi_color] else ansi_color = RGB_COLORS_ANSI_BRIGHT.send(key_method, ansi_color_rgb) "#{ANSI_COLORS[ansi_color]};1" end end def distance(rgb1, rgb2) rgb1.zip(rgb2).inject(0){ |acc, (cur1, cur2)| acc + (cur1 - cur2)**2 } end end end # J-_-L ruby-paint-0.8.6/lib/paint/000077500000000000000000000000001213504115400154745ustar00rootroot00000000000000ruby-paint-0.8.6/lib/paint/pa.rb000066400000000000000000000003031213504115400164150ustar00rootroot00000000000000require 'paint' module Kernel private # A helper method similar to puts for printing a String on STDOUT # Passes all arguments to Paint.[] def pa(*args) puts Paint[*args] end end ruby-paint-0.8.6/lib/paint/rgb_colors.rb000066400000000000000000000525531213504115400201660ustar00rootroot00000000000000module Paint # A list of color names, based on X11's rgb.txt # Can be used with Paint.[] by passing a string containing the color name # See Paint::Util::update_rgb_colors for generating 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]} end # J-_-L ruby-paint-0.8.6/lib/paint/rgb_colors_ansi.rb000066400000000000000000000015041213504115400211660ustar00rootroot00000000000000module Paint # A list of color names for standard ansi colors, needed for 16/8 color fallback mode # See http://en.wikipedia.org/wiki/ANSI_escape_code#Colors RGB_COLORS_ANSI = { :black => [0,0,0], :red => [205,0,0], :green => [0,205,0], :yellow => [205,205,0], :blue => [0,0,238], :magenta => [205,0,205], :cyan => [0,205,205], :white => [229,229,229], } # A list of color names for standard bright ansi colors, needed for 16 color fallback mode # See http://en.wikipedia.org/wiki/ANSI_escape_code#Colors RGB_COLORS_ANSI_BRIGHT = { :black => [127,127,127], :red => [255,0,0], :green => [0,255,0], :yellow => [255,255,0], :blue => [92,92,255], :magenta => [255,0,255], :cyan => [0,255,255], :white => [255,255,255], } end ruby-paint-0.8.6/lib/paint/shortcuts.rb000066400000000000000000000052611213504115400200630ustar00rootroot00000000000000module Paint # Hash for defining color/effect shortcuts # See README for details SHORTCUTS = { # :example => { # would create a Paint::Example constant... # :light_red => "\e[31;1m", # with a method .light_red # } } SHORTCUTS.default = {} class << self # Paint::SomeModule --> Paint::SHORTCUTS[:some_module] def const_missing(mod_name) # get shortcuts shortcuts = SHORTCUTS[mod_name.to_s.gsub(/[A-Z]/,'_\0').downcase[1..-1].to_sym] || [] # create module class_eval "module #{mod_name}; end" mod = const_get(mod_name) eigen_mod = class << mod; self; end # 1.8 # define direct behaviour, class methods # mod.define_singleton_method :method_missing do |color_name, *args| eigen_mod.send:define_method, :method_missing do |color_name, *args| if color_code = shortcuts[color_name] if args.empty? then color_code else color_code + Array(args).join + NOTHING end else nil end end eigen_mod.send:define_method, :respond_to? do |color_name, *args| shortcuts.include?(color_name) || super(color_name, *args) end # define include behaviour, instance methods eigen_mod.send:define_method, :included do |_| shortcuts.each{ |color_name, color_code| define_method color_name do |*args| if args.empty? then color_code else color_code + Array(args).join + NOTHING end end } private(*shortcuts.keys) unless shortcuts.empty? end # include variations, defined in child modules mod.class_eval "module String; end" string = mod.const_get(:String) eigen_string = class << string; self; end # 1.8 eigen_string.send:define_method, :included do |_| shortcuts.each{ |color_name, color_code| define_method color_name do color_code + to_s + NOTHING end } end # OK, let's take it one level further ;) mod.class_eval "module Prefix; end" prefix_prefix = mod.const_get(:Prefix) eigen_prefix_prefix = class << prefix_prefix; self; end # 1.8 eigen_prefix_prefix.send:define_method, :const_missing do |prefix_name| class_eval "module #{prefix_name}; end" prefix = const_get(prefix_name) eigen_prefix = class << prefix; self; end # 1.8 eigen_prefix.send:define_method, :included do |_| define_method prefix_name.to_s.gsub(/[A-Z]/,'_\0').downcase[1..-1].to_sym do |color_name| shortcuts[color_name] && shortcuts[color_name] + to_s + NOTHING end end prefix end # :) mod end end end # J-_-L ruby-paint-0.8.6/lib/paint/util.rb000066400000000000000000000031211213504115400167730ustar00rootroot00000000000000require 'rbconfig' module Paint # These helpers add functionality you sometimes need when working with terminal colors class << self # Removes any color and effect strings def unpaint(string) string.gsub(/\e\[(?:[0-9];?)+m/, '') end # Tries to print all 256 colors def rainbow (0...256).each{ |color| print Paint[' ', 48, 5, color] # print empty bg color field } puts end # Updates color names def update_rgb_colors(path = '/etc/X11/rgb.txt') if File.file?(path) Paint::RGB_COLORS.clear File.open(path, 'r') do |file| file.each_line{ |line| line.chomp =~ /(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/ Paint::RGB_COLORS[$4] = [$1.to_i, $2.to_i, $3.to_i] if $4 } end else raise ArgumentError, "Not a valid file: #{path}" end end # Determine supported colors # This is just a naive approach, based on some things I could test # Please open issues if it does not work correctly for you def detect_mode if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ # windows if ENV['ANSICON'] 16 elsif ENV['ConEmuANSI'] == 'ON' 256 else 0 end else # case ENV['COLORTERM'] # when 'gnome-terminal' # 256 # else case ENV['TERM'] when /-256color$/, 'xterm' 256 when /-color$/, 'rxvt' 16 else # optimistic default 256 end # end end end end end # J-_-L ruby-paint-0.8.6/lib/paint/version.rb000066400000000000000000000000451213504115400175050ustar00rootroot00000000000000module Paint VERSION = '0.8.6' end ruby-paint-0.8.6/paint.gemspec000066400000000000000000000030331213504115400162720ustar00rootroot00000000000000# -*- encoding: utf-8 -*- require 'rubygems' unless defined? Gem require File.dirname(__FILE__) + "/lib/paint/version" Gem::Specification.new do |s| s.name = "paint" s.version = Paint::VERSION s.authors = ["Jan Lelis"] s.email = "mail@janlelis.de" s.homepage = "https://github.com/janlelis/paint" s.summary = "Terminal painter!" s.description = "Terminal painter / no string extensions / 256 color support / effect support / define custom shortcuts / basic usage: Paint['string', :red, :bright]" s.required_ruby_version = '>= 1.8.7' s.files = Dir.glob(%w[{lib,test,spec}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c}]) + %w{Rakefile paint.gemspec .gemtest} s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"] s.license = 'MIT' s.add_development_dependency 'rspec' s.add_development_dependency 'rspec-core' s.add_development_dependency 'rake' s.add_development_dependency 'rainbow' s.add_development_dependency 'term-ansicolor' len = s.homepage.size s.post_install_message = \ (" ┌── " + "info ".ljust(len-2,'%') + "─┐\n" + " J-_-L │ " + s.homepage + " │\n" + " ├── " + "usage ".ljust(len-2,'%') + "─┤\n" + " │ " + "require 'paint'".ljust(len,' ') + " │\n" + " │ " + "puts Paint['J-_-L', :red] # \e[31mJ-_-L\e[0m".ljust(len,' ') + " │\n" + " └─" + '─'*len + "─┘").gsub('%', '─') # 1.8 workaround end ruby-paint-0.8.6/spec/000077500000000000000000000000001213504115400145455ustar00rootroot00000000000000ruby-paint-0.8.6/spec/paint_methods_spec.rb000066400000000000000000000045131213504115400207450ustar00rootroot00000000000000require File.dirname(__FILE__) + '/spec_helper' describe 'Paint.color' do it 'only returns a the color escape sequnce and is directly used by Paint.[] with all paramenters except the first; see there fore specs' do end end describe 'Paint.simple' do it 'returns ansi code number for one of the eight ansi base colors' do Paint.simple(:red).should == 31 end it 'returns background ansi code number for one of the eight ansi base colors if second parameter is true' do Paint.simple(:red, true).should == 41 end end describe 'Paint.rgb' do before do Paint.mode = 256 end it 'returns ansi code sequence for one of 256 colors' do Paint.rgb(1,2,3).should == '38;5;232' end it 'returns background ansi code sequence for one of 256 colors if last parameter is true' do Paint.rgb(1, 2, 3, true).should == '48;5;232' end end describe 'Paint.hex' do before do Paint.mode = 256 end it 'returns ansi code sequence for one of 256 colors' do Paint.hex("#fff").should == "38;5;255" end it 'returns background ansi code sequence for one of 256 colors if second parameter is true' do Paint.hex("123456", true).should == "48;5;24" end end describe 'Paint.rbb_name' do before do Paint.mode = 256 end it 'returns ansi code sequence for one of 256 colors' do Paint.rgb_name("gold").should == "38;5;226" end it 'returns background ansi code sequence for one of 256 colors if second parameter is true' do Paint.rgb_name("gold", true).should == "48;5;226" end end describe 'Paint.random' do it 'returns ansi code for one of the eight ansi base colors' do (30...38) === Paint.random.should end end describe 'Paint.effect' do it 'returns ansi code for effect using EFFECTS hash' do Paint.effect(:bright).should == 1 end end describe 'Paint.wrap' do it 'wraps an ansi color code (array of integers) into an ansi escape sequence' do Paint.wrap(31, 1).should == "\e[31;1m" end end # util.rb describe 'Paint.unpaint' do it 'removes any ansi color escape sequences in the string' do Paint.unpaint( Paint['J-_-L', :red, :bright] ).should == 'J-_-L' end end describe 'Paint.rainbow' do it 'prints all available 256 colors' do end end describe 'Paint.update_rgb_colors' do it 'updates the Paint::RGB_COLORS hash using rgb.txt (takes path to it as argument)' do end end ruby-paint-0.8.6/spec/paint_mode_spec.rb000066400000000000000000000012061213504115400202220ustar00rootroot00000000000000require File.dirname(__FILE__) + '/spec_helper' describe 'Paint.mode' do it "works normally if mode is 256 or another unknown true value" do Paint.mode = 256 Paint['J-_-L', 'gold'].should == "\e[38;5;226mJ-_-L\e[0m" end it "doesn't colorize anything if mode is 0" do Paint.mode = 0 Paint['J-_-L', 'gold'].should == "J-_-L" end it "only uses the 8 ansi colors if mode is 8" do Paint.mode = 8 Paint['J-_-L', 'gold'].should == "\e[33mJ-_-L\e[0m" end it "only uses the 8 ansi colors with bright effect if mode is 16" do Paint.mode = 16 Paint['J-_-L', 'gold'].should == "\e[33;1mJ-_-L\e[0m" end end ruby-paint-0.8.6/spec/paint_shortcuts_spec.rb000066400000000000000000000032751213504115400213440ustar00rootroot00000000000000require File.dirname(__FILE__) + '/spec_helper' # TODO fix include specs, probably failing because of some rspec voodoo describe 'Paint::SHORTCUTS' do before do Paint::SHORTCUTS[:example] = { :white => Paint.color(:black), :red => Paint.color(:red, :bright), :title => Paint.color(:underline), } end context 'Paint::Example.method_missing' do it 'returns a color defined in the SHORTCUTS hash under the :example key' do Paint::Example.red == "\e[31m" end it 'returns a color defined in the SHORTCUTS hash under the :some_module key; method takes string to colorize' do Paint::Example.red 'J-_-L' == "\e[31;1mJ-_-L\e[0m" end end context 'include Paint::Example' do include Paint::Example #red.should == "\e[31;1m" #white( 'Ruby' ).should "\e[30m" end context 'include Paint::Example::String' do it 'adds shortcuts methods that colorize self' do class MyString < String # could also have used original String include Paint::Example::String end # MyString.new("J-_-L").red.should == "\e[31;1mJ-_-L\e[0m" end it 'adds shortcuts methods that colorize self (also works for non-String classes by calling to_s)' do Paint::SHORTCUTS[:example][:gold] = Paint.color "gold" class Integer include Paint::Example::String end #123.red.should == "\e[38;5;226m123\e[0m" end end context 'include Paint::Example::Prefix::ExampleName' do it 'sets a single color helper method to avoid cluttering namespaces' do class Object include Paint::Example::Prefix::ExampleName end #"Ruby".example_name(:red).should == "\e[31;1mRuby\e[0m" end end end ruby-paint-0.8.6/spec/paint_spec.rb000066400000000000000000000063451213504115400172270ustar00rootroot00000000000000require File.dirname(__FILE__) + '/spec_helper' describe 'Paint.[]' do before do Paint.mode = 256 end context '(with no options)' do it "doesn't colorize at all" do Paint['J-_-L'].should == "J-_-L" end end context '(with one color)' do it 'understands a simple symbol color and use it as foreground color' do Paint['J-_-L', :yellow].should == "\e[33mJ-_-L\e[0m" end it 'understands an array as rgb color definition and use it as foreground color' do Paint['J-_-L', [255, 200, 0]].should == "\e[38;5;220mJ-_-L\e[0m" end it 'understands a hex string (with #, 6 digits) as rgb color definition and use it as foreground color' do Paint['J-_-L', "#123456"].should == "\e[38;5;24mJ-_-L\e[0m" end it 'understands a hex string (no #, 6 digits) as rgb color definition and use it as foreground color' do Paint['J-_-L', "123456"].should == "\e[38;5;24mJ-_-L\e[0m" end it 'understands a hex string (with #, 3 digits) as rgb color definition and use it as foreground color' do Paint['J-_-L', "#fff"].should == "\e[38;5;255mJ-_-L\e[0m" end it 'understands a hex string (no #, 3 digits) as rgb color definition and use it as foreground color' do Paint['J-_-L', "fff"].should == "\e[38;5;255mJ-_-L\e[0m" end it 'understands a hex string (with uppercased letters) as rgb color definition and use it as foreground color' do Paint['J-_-L', "#4183C4"].should == "\e[38;5;74mJ-_-L\e[0m" end it 'understands a non-hex string as rgb color name (rgb.txt) and use it as foreground color' do Paint['J-_-L', "medium purple"].should == "\e[38;5;141mJ-_-L\e[0m" end it 'colorizes using a random ansi foreground color' do Paint['J-_-L', :random].should =~ /\e\[3\dmJ-_-L\e\[0m/ end end context '(with two colors)' do it 'interprets the first color as foreground color and the second one as background color' do Paint['J-_-L', :yellow, :red].should == "\e[33;41mJ-_-L\e[0m" end it 'interprets the first color as foreground color and the second one as background color (rgb)' do Paint['J-_-L', '#424242', [42, 142, 242]].should == "\e[38;5;238;48;5;39mJ-_-L\e[0m" end it 'sets only a background color, if first color is nil' do Paint['J-_-L', nil, [42, 142, 242]].should == "\e[48;5;39mJ-_-L\e[0m" end end context '(with effects)' do it 'passes effects' do Paint['J-_-L', :bright].should == "\e[1mJ-_-L\e[0m" end it 'passes effects, mixed with colors' do Paint['J-_-L', :yellow, :bright].should == "\e[33;1mJ-_-L\e[0m" end it 'passes effects, mixed with colors, order does not matter' do Paint['J-_-L', :bright, :yellow].should == "\e[1;33mJ-_-L\e[0m" end it 'passes multiple effects' do Paint['J-_-L', :yellow, :red, :bright, :underline, :inverse].should == "\e[33;41;1;4;7mJ-_-L\e[0m" end end context '(with plain integers)' do it 'passes integers to final escape sequence' do Paint['J-_-L', 31, 1, 42].should == "\e[31;1;42mJ-_-L\e[0m" end it 'passes integers to final escape sequence (mixed with normal arguments)' do Paint['J-_-L', :red, :bright, 42, :underline].should == "\e[31;1;42;4mJ-_-L\e[0m" end end end ruby-paint-0.8.6/spec/spec_helper.rb000066400000000000000000000000611213504115400173600ustar00rootroot00000000000000require File.dirname(__FILE__) + '/../lib/paint'