Class: Color::YIQ
Overview
A colour object representing YIQ (NTSC) colour encoding.
Constant Summary
Constants included
from Color
COLOR_EPSILON, COLOR_TOLERANCE, COLOR_VERSION, GreyScale
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Color
#==, coerce, const_missing, equivalent?, #name, #names, #names=, near?, near_one?, near_one_or_more?, near_zero?, near_zero_or_less?, new, normalize, normalize_byte, normalize_to_range, normalize_word
Constructor Details
permalink
#initialize(y = 0, i = 0, q = 0, radix = 100.0, &block) ⇒ YIQ
Creates a YIQ colour object from percentages 0 .. 100.
Color::YIQ.new(10, 20, 30)
[View source]
15
16
17
18
|
# File 'lib/color/yiq.rb', line 15
def initialize(y = 0, i = 0, q = 0, radix = 100.0, &block) @y, @i, @q = [ y, i, q ].map { |v| Color.normalize(v / radix) }
block.call if block
end
|
Class Method Details
permalink
.from_fraction(y = 0, i = 0, q = 0, &block) ⇒ Object
Creates a YIQ colour object from fractional values 0 .. 1.
Color::YIQ.new(0.3, 0.2, 0.1)
[View source]
8
9
10
|
# File 'lib/color/yiq.rb', line 8
def self.from_fraction(y = 0, i = 0, q = 0, &block)
new(y, i, q, 1.0, &block)
end
|
Instance Method Details
permalink
#brightness ⇒ Object
[View source]
28
29
30
|
# File 'lib/color/yiq.rb', line 28
def brightness
@y
end
|
permalink
#coerce(other) ⇒ Object
[View source]
20
21
22
|
# File 'lib/color/yiq.rb', line 20
def coerce(other)
other.to_yiq
end
|
[View source]
42
43
44
|
# File 'lib/color/yiq.rb', line 42
def i
@i
end
|
[View source]
55
56
57
|
# File 'lib/color/yiq.rb', line 55
def inspect
"YIQ [%.2f%%, %.2f%%, %.2f%%]" % [ @y * 100, @i * 100, @q * 100 ]
end
|
[View source]
48
49
50
|
# File 'lib/color/yiq.rb', line 48
def q
@q
end
|
[View source]
59
60
61
|
# File 'lib/color/yiq.rb', line 59
def to_a
[ y, i, q ]
end
|
[View source]
24
25
26
|
# File 'lib/color/yiq.rb', line 24
def to_yiq
self
end
|
[View source]
36
37
38
|
# File 'lib/color/yiq.rb', line 36
def y
@y
end
|