Class: Color::YIQ
- Inherits:
-
Object
- Object
- Color::YIQ
- Defined in:
- lib/color/yiq.rb,
lib/color.rb
Overview
A colour object representing YIQ (NTSC) colour encoding.
Instance Attribute Summary collapse
-
#i ⇒ Object
Returns the value of attribute i.
-
#q ⇒ Object
Returns the value of attribute q.
-
#y ⇒ Object
Returns the value of attribute y.
Class Method Summary collapse
-
.from_fraction(y = 0, i = 0, q = 0) ⇒ Object
Creates a YIQ colour object from fractional values 0 ..
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compares the other colour to this one.
- #brightness ⇒ Object
-
#initialize(y = 0, i = 0, q = 0) ⇒ YIQ
constructor
Creates a YIQ colour object from percentages 0 ..
- #to_grayscale ⇒ Object (also: #to_greyscale)
- #to_yiq ⇒ Object
Constructor Details
Instance Attribute Details
#i ⇒ Object
Returns the value of attribute i.
61 62 63 |
# File 'lib/color/yiq.rb', line 61 def i @i end |
#q ⇒ Object
Returns the value of attribute q.
61 62 63 |
# File 'lib/color/yiq.rb', line 61 def q @q end |
#y ⇒ Object
Returns the value of attribute y.
61 62 63 |
# File 'lib/color/yiq.rb', line 61 def y @y end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
Compares the other colour to this one. The other colour will be converted to YIQ before comparison, so the comparison between a YIQ colour and a non-YIQ colour will be approximate and based on the other colour’s #to_yiq conversion. If there is no #to_yiq conversion, this will raise an exception. This will report that two YIQ values are equivalent if all component colours are within 1e-4 (0.0001) of each other.
41 42 43 44 45 46 47 |
# File 'lib/color/yiq.rb', line 41 def ==(other) other = other.to_yiq other.kind_of?(Color::YIQ) and ((@y - other.y).abs <= 1e-4) and ((@i - other.i).abs <= 1e-4) and ((@q - other.q).abs <= 1e-4) end |
#brightness ⇒ Object
53 54 55 |
# File 'lib/color/yiq.rb', line 53 def brightness @y end |
#to_grayscale ⇒ Object Also known as: to_greyscale
56 57 58 |
# File 'lib/color/yiq.rb', line 56 def to_grayscale Color::GrayScale.new(@y) end |
#to_yiq ⇒ Object
49 50 51 |
# File 'lib/color/yiq.rb', line 49 def to_yiq self end |