Module: AutoColors

Defined in:
lib/autocolors.rb,
lib/autocolors/color.rb,
lib/autocolors/mapping.rb,
lib/autocolors/colorscheme.rb

Defined Under Namespace

Classes: Color, ColorScheme, MapEntry, Mapping

Constant Summary collapse

VERSION =
File.exist?(File.join(File.dirname(__FILE__),'VERSION')) ? File.read(File.join(File.dirname(__FILE__),'VERSION')) : ""
TEMPLATE_PATH =
File.join(File.dirname(__FILE__),'autocolors','templates')
LRGB2XYZ =
Matrix[[0.4124,0.3576,0.1805]
XYZ2LRGB =
CUBE256_8NORM =

Primary 3-bit (8 colors). Unique representation!

[[0x00,0x00,0x00],[0x80,0x00,0x00],[0x00,0x80,0x00],[0x80,0x80,0x00],
[0x00,0x00,0x80],[0x80,0x00,0x80],[0x00,0x80,0x80],[0xc0,0xc0,0xc0]]
CUBE256_BRIGHT =

Equivalent "bright" versions of original 8 colors.

[[0x80,0x80,0x80],[0xff,0x00,0x00],[0x00,0xff,0x00],[0xff,0xff,0x00],
[0x00,0x00,0xff],[0xff,0x00,0xff],[0x00,0xff,0xff],[0xff,0xff,0xff]]
CUBE256_STEPS =

Strictly ascending.

[0x00,0x5f,0x87,0xaf,0xd7,0xff]
CUBE256_GRAYS =

Gray-scale range.

[[0x08,0x08,0x08],[0x12,0x12,0x12],[0x1c,0x1c,0x1c],[0x26,0x26,0x26],
[0x30,0x30,0x30],[0x3a,0x3a,0x3a],[0x44,0x44,0x44],[0x4e,0x4e,0x4e],
[0x58,0x58,0x58],[0x62,0x62,0x62],[0x6c,0x6c,0x6c],[0x76,0x76,0x76],
[0x80,0x80,0x80],[0x8a,0x8a,0x8a],[0x94,0x94,0x94],[0x9e,0x9e,0x9e],
[0xa8,0xa8,0xa8],[0xb2,0xb2,0xb2],[0xbc,0xbc,0xbc],[0xc6,0xc6,0xc6],
[0xd0,0xd0,0xd0],[0xda,0xda,0xda],[0xe4,0xe4,0xe4],[0xee,0xee,0xee]]
CUBE256 =
CUBE256_8NORM.map {|rgb| Color.new(rgb)} +
CUBE256_BRIGHT.map{|rgb| Color.new(rgb)} +
(0..(6*6*6 - 1)).map do |i|
  b = i % 6; i = (i - b) / 6
  g = i % 6; i = (i - g) / 6
  Color.new([CUBE256_STEPS[i % 6],
                     CUBE256_STEPS[g],
                     CUBE256_STEPS[b]])
end +
CUBE256_GRAYS.map{|rgb| Color.new(rgb)}
KEYS =
[:fg_idx, :fg_intensity, :fg_saturation,
:bg_idx, :bg_intensity, :bg_saturation, :styles,
:to_vim, :to_textmate,  :to_pygments,   :to_emacs]
MAPPING =
Mapping.new

Class Method Summary collapse

Class Method Details

.generate_vim_colors(name = nil) ⇒ Object



14
15
16
17
18
# File 'lib/autocolors.rb', line 14

def generate_vim_colors(name=nil)
  scheme = ColorScheme.new(name)
  template = ERB.new(template('colorscheme.erb.vim'),nil,'-')
  return template.result(binding)
end

.template(name) ⇒ Object



10
11
12
# File 'lib/autocolors.rb', line 10

def template(name)
  IO.read(File.join(TEMPLATE_PATH, name))
end

.versionObject



8
# File 'lib/autocolors.rb', line 8

def version() VERSION end