Class: ZPNG::Color
- Inherits:
-
Struct
- Object
- Struct
- ZPNG::Color
- Defined in:
- lib/zpng/color.rb
Constant Summary collapse
- BLACK =
Color.new(0,0,0,0xff)
- WHITE =
Color.new(0xff,0xff,0xff,0xff)
Instance Attribute Summary collapse
-
#a ⇒ Object
(also: #alpha)
Returns the value of attribute a.
-
#b ⇒ Object
Returns the value of attribute b.
-
#g ⇒ Object
Returns the value of attribute g.
-
#r ⇒ Object
Returns the value of attribute r.
Instance Method Summary collapse
Instance Attribute Details
#a ⇒ Object Also known as: alpha
Returns the value of attribute a
2 3 4 |
# File 'lib/zpng/color.rb', line 2 def a @a end |
#b ⇒ Object
Returns the value of attribute b
2 3 4 |
# File 'lib/zpng/color.rb', line 2 def b @b end |
#g ⇒ Object
Returns the value of attribute g
2 3 4 |
# File 'lib/zpng/color.rb', line 2 def g @g end |
#r ⇒ Object
Returns the value of attribute r
2 3 4 |
# File 'lib/zpng/color.rb', line 2 def r @r end |
Instance Method Details
#black? ⇒ Boolean
13 14 15 |
# File 'lib/zpng/color.rb', line 13 def black? r == 0 && g == 0 && b == 0 end |
#to_grayscale ⇒ Object
17 18 19 |
# File 'lib/zpng/color.rb', line 17 def to_grayscale (r+g+b)/3 end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/zpng/color.rb', line 21 def to_s "%02X%02X%02X" % [r,g,b] end |
#white? ⇒ Boolean
9 10 11 |
# File 'lib/zpng/color.rb', line 9 def white? r == 0xff && g == 0xff && b == 0xff end |