Class: ColortoolsColor
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseColor
#adjust, #blue, #blue=, #brightness, #green, #green=, #hue, #object, #red, #red=, #rgb, #rgb=, #saturation
Constructor Details
Returns a new instance of ColortoolsColor.
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/libisi/color/colortools.rb', line 38
def initialize(options = {})
case options
when Color::RGB
@rgb_color = options
when ColortoolsColor
@rgb_color = options.rgb_color.dup
else
raise "Require html color from options got: #{options.inspect}" unless
options.class == String or options.class == Symbol
if col = ColortoolsColor.get_color(options)
@rgb_color = col.rgb_color
else
begin
@rgb_color = Color::RGB.from_html(options)
rescue ArgumentError
raise "Color #{options} not found"
end
end
end
end
|
Instance Attribute Details
#rgb_color ⇒ Object
Returns the value of attribute rgb_color.
36
37
38
|
# File 'lib/libisi/color/colortools.rb', line 36
def rgb_color
@rgb_color
end
|
Class Method Details
.get_color(name) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/libisi/color/colortools.rb', line 24
def ColortoolsColor.get_color(name)
normalized_name = name.to_s.split("_").map {|n| n.capitalize}.join
Color::RGB.constants.each {|c|
if c == normalized_name or
c.scan(/[A-Z][a-z]*/).map {|n| n.downcase}.join.capitalize == normalized_name
return ColortoolsColor.new(Color::RGB.const_get(c))
end
}
return nil
end
|
Instance Method Details
#brightness_implementation ⇒ Object
83
|
# File 'lib/libisi/color/colortools.rb', line 83
def brightness_implementation; @rgb_color.brightness; end
|
#brightness_percentage_implementation(percentage) ⇒ Object
84
85
86
|
# File 'lib/libisi/color/colortools.rb', line 84
def brightness_percentage_implementation(percentage)
@rgb_color = @rgb_color.adjust_brightness(percentage)
end
|
#data(mime_type) ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/libisi/color/colortools.rb', line 62
def data(mime_type)
case mime_type
when "text/htmlcolor"
return @rgb_color.html
else
raise "Dont know how to be a #{mime_type}"
end
end
|
#html ⇒ Object
75
76
77
|
# File 'lib/libisi/color/colortools.rb', line 75
def html
@rgb_color.html
end
|
#html=(value) ⇒ Object
71
72
73
|
# File 'lib/libisi/color/colortools.rb', line 71
def html=(value)
@rgb_color = Color::RGB.from_html(value)
end
|
#hue_percentage_implementation(percentage) ⇒ Object
79
80
81
|
# File 'lib/libisi/color/colortools.rb', line 79
def hue_percentage_implementation(percentage)
@rgb_color = @rgb_color.adjust_hue(percentage)
end
|
#saturation_percentage_implementation(percentage) ⇒ Object
88
89
90
|
# File 'lib/libisi/color/colortools.rb', line 88
def saturation_percentage_implementation(percentage)
@rgb_color = @rgb_color.adjust_saturation(percentage)
end
|