Class: Clutter::Color
- Inherits:
-
Object
- Object
- Clutter::Color
- Defined in:
- lib/clutter/color.rb
Class Method Summary collapse
- .hls(hue, luminance, saturation, alpha = 255) ⇒ Object
- .hlsa(hue, luminance, saturation, alpha) ⇒ Object
- .new(*args) ⇒ Object
- .parse(string) ⇒ Object
- .pixel(pixel) ⇒ Object
- .rgb(red, green, blue, alpha = 255) ⇒ Object
- .rgba(red, green, blue, alpha) ⇒ Object
Class Method Details
.hls(hue, luminance, saturation, alpha = 255) ⇒ Object
44 45 46 |
# File 'lib/clutter/color.rb', line 44 def hls(hue, luminance, saturation, alpha=255) hlsa(hue, luminance, saturation, alpha) end |
.hlsa(hue, luminance, saturation, alpha) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/clutter/color.rb', line 48 def hlsa(hue, luminance, saturation, alpha) if respond_to?(:from_hls, true) color = from_hls(hue, luminance, saturation) else color = new color.from_hls(hue, luminance, saturation) end color.alpha = alpha color end |
.new(*args) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/clutter/color.rb', line 24 def new(*args) if [Symbol] == args.collect(&:class) name = args[0] get_static(name) else if args.empty? args = [0, 0, 0, 1] unless private_method_defined?(:initialize_alloc) end super(*args) end end |
.parse(string) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/clutter/color.rb', line 69 def parse(string) if respond_to?(:from_string, true) succeeded, color = from_string(string) else color = new succeeded = color.from_string(string) end unless succeeded raise ArgumentError, "invalid color string: <#{string}>" end color end |
.pixel(pixel) ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/clutter/color.rb', line 59 def pixel(pixel) if respond_to?(:from_pixel, true) color = from_pixel(pixel) else color = new color.from_pixel(pixel) end color end |
.rgb(red, green, blue, alpha = 255) ⇒ Object
36 37 38 |
# File 'lib/clutter/color.rb', line 36 def rgb(red, green, blue, alpha=255) rgba(red, green, blue, alpha) end |
.rgba(red, green, blue, alpha) ⇒ Object
40 41 42 |
# File 'lib/clutter/color.rb', line 40 def rgba(red, green, blue, alpha) new(red, green, blue, alpha) end |