Class: RMQColor

Inherits:
Android::Graphics::Color
  • Object
show all
Defined in:
lib/project/ruby_motion_query/rmq_color.rb

Class Method Summary collapse

Class Method Details

.add_named(key, hex_or_color) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/project/ruby_motion_query/rmq_color.rb', line 45

def add_named(key, hex_or_color)
  c = if hex_or_color.is_a?(String)
    RMQColor.parseColor(hex_or_color)
  else
    hex_or_color
  end

  rmq_color_cache[key] = c
end

.blackObject



28
# File 'lib/project/ruby_motion_query/rmq_color.rb', line 28

def black ; self::BLACK ; end

.clearObject



21
# File 'lib/project/ruby_motion_query/rmq_color.rb', line 21

def clear ; self::TRANSPARENT ; end

.dark_grayObject



27
# File 'lib/project/ruby_motion_query/rmq_color.rb', line 27

def dark_gray ; self::DKGRAY ; end

.from_hex(str) ⇒ UIColor

Creates a color from a hex triplet (rgb) or quartet (rgba)

Examples:

color.from_hex('#ffffff')
color.from_hex('ffffff')
color.from_hex('#336699cc')
color.from_hex('369c')

Parameters:

  • hex

    with or without the #

Returns:

  • (UIColor)


69
70
71
# File 'lib/project/ruby_motion_query/rmq_color.rb', line 69

def from_hex(str)
  RMQColorFactory.from_hex(str)
end

.from_rgba(r, g, b, a) ⇒ UIColor

Examples:

rmq.color.from_rgba(255,255,255,0.5)

Returns:

  • (UIColor)


77
78
79
# File 'lib/project/ruby_motion_query/rmq_color.rb', line 77

def from_rgba(r,g,b,a)
  RMQColorFactory.from_rgba(r,g,b,a)
end

.grayObject



26
# File 'lib/project/ruby_motion_query/rmq_color.rb', line 26

def gray ; self::GRAY ; end

.light_grayObject



25
# File 'lib/project/ruby_motion_query/rmq_color.rb', line 25

def light_gray ; self::LTGRAY ; end

.method_missing(color_key) ⇒ Object



55
56
57
58
# File 'lib/project/ruby_motion_query/rmq_color.rb', line 55

def method_missing(color_key)
  # define_singleton_method isn't implemented in Android :'(
  rmq_color_cache[color_key]
end

.randomObject



81
82
83
# File 'lib/project/ruby_motion_query/rmq_color.rb', line 81

def random
  RMQColorFactory.from_rgba(rand(255), rand(255), rand(255), 1.0)
end

.rmq_color_cacheObject



85
86
87
# File 'lib/project/ruby_motion_query/rmq_color.rb', line 85

def rmq_color_cache
  @_rmq_color_cache ||= {}
end

.transparentObject



22
# File 'lib/project/ruby_motion_query/rmq_color.rb', line 22

def transparent ; self::TRANSPARENT ; end

.whiteObject



24
# File 'lib/project/ruby_motion_query/rmq_color.rb', line 24

def white ; self::WHITE ; end