Class: Abachrome::Converters::YiqToSrgb
- Inherits:
-
Object
- Object
- Abachrome::Converters::YiqToSrgb
- Defined in:
- lib/abachrome/converters/yiq_to_srgb.rb
Class Method Summary collapse
-
.convert(yiq_color) ⇒ Abachrome::Color
Converts a color from YIQ color space to sRGB color space.
Class Method Details
.convert(yiq_color) ⇒ Abachrome::Color
Converts a color from YIQ color space to sRGB color space. This method applies the inverse NTSC transformation matrix.
with the same alpha value as the input color
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/abachrome/converters/yiq_to_srgb.rb', line 28 def self.convert(yiq_color) y, i, q = yiq_color.coordinates.map { |c| AbcDecimal(c) } # Inverse NTSC YIQ to RGB transformation matrix # R = Y + 0.956I + 0.619Q # G = Y - 0.272I - 0.647Q # B = Y - 1.106I + 1.703Q r = y + (AD("0.9563") * i) + (AD("0.6210") * q) g = y - (AD("0.2721") * i) - (AD("0.6474") * q) b = y - (AD("1.1070") * i) + (AD("1.7046") * q) Color.new( ColorSpace.find(:srgb), [r, g, b], yiq_color.alpha ) end |