module Iroki::Color

Constants

BLUE
BLUE_HUE
COLORS
DARK_GREEN
FULLY_SATURATED
GRAY
GREEN
GREEN_HUE

TOP

HSL
PURE_COLOR
PURE_LIGHT
RGB
WHITE
WHITE_HUE
default_color_tag

Public Class Methods

default_color_tag() click to toggle source
# File lib/iroki/color/color.rb, line 747
def self.default_color_tag
  @@default_color ||= nil
end
default_color_tag=(tag_hash) click to toggle source
# File lib/iroki/color/color.rb, line 743
def self.default_color_tag= tag_hash
  @@default_color = tag_hash
end
get_tag(str, palette=nil) click to toggle source
# File lib/iroki/color/color.rb, line 703
def self.get_tag str, palette=nil
  if str.hex?
    self.tag_from_hex str
  else
    self.tag_from_color str, palette
  end
end
tag_from_color(color, palette=nil) click to toggle source
# File lib/iroki/color/color.rb, line 717
def self.tag_from_color color, palette=nil
  col = color.downcase.strip

  if palette
    hash =
      Hash[palette.keys.zip palette.map(&:last).map{|h| h[:hex]}]
    colors = COLORS.merge hash
  else
    colors = COLORS
  end

  unless colors.has_key? col
    if col.match(/\A[0-9]+\Z/)
      msg = "Color '#{col}' is not defined. " +
            "Did you forget the --auto-color option?"
    else
      msg = "Color '#{col}' is not defined."
    end

    abort_if true, msg
  end

  hex = colors[col]
  %Q{[&!color="#{hex.upcase}"]}
end
tag_from_hex(hex) click to toggle source
# File lib/iroki/color/color.rb, line 711
def self.tag_from_hex hex
  assert hex.hex?, "'#{hex}' was not a valid hex code"

  %Q{[&!color="#{hex.upcase}"]}
end