Class Color::YIQ
In: lib/color.rb
lib/color/yiq.rb
Parent: Object
Enumerable Gimp CMYK\n[lib/color.rb\nlib/color/cmyk.rb] GrayScale\n[lib/color.rb\nlib/color/grayscale.rb] RGB\n[lib/color.rb\nlib/color/rgb-colors.rb\nlib/color/rgb.rb] YIQ\n[lib/color.rb\nlib/color/yiq.rb] HSL MonoContrast lib/color/cmyk.rb lib/color/grayscale.rb lib/color/rgb.rb lib/color/yiq.rb lib/color/hsl.rb CSS lib/color/palette/gimp.rb lib/color/palette/monocontrast.rb Palette Color dot/m_9_0.png

A colour object representing YIQ (NTSC) colour encoding.

Methods

Attributes

i  [RW] 
q  [RW] 
y  [RW] 

Public Class methods

Creates a YIQ colour object from fractional values 0 .. 1.

  Color::YIQ.new(0.3, 0.2, 0.1)

[Source]

    # File lib/color/yiq.rb, line 17
17:   def self.from_fraction(y = 0, i = 0, q = 0)
18:     color = Color::YIQ.new
19:     color.y = y
20:     color.i = i
21:     color.q = q
22:     color
23:   end

Creates a YIQ colour object from percentages 0 .. 100.

  Color::YIQ.new(10, 20, 30)

[Source]

    # File lib/color/yiq.rb, line 28
28:   def initialize(y = 0, i = 0, q = 0)
29:     @y = y / 100.0
30:     @i = i / 100.0
31:     @q = q / 100.0
32:   end

Public Instance methods

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.

[Source]

    # File lib/color/yiq.rb, line 41
41:   def ==(other)
42:     other = other.to_yiq
43:     other.kind_of?(Color::YIQ) and
44:     ((@y - other.y).abs <= 1e-4) and
45:     ((@i - other.i).abs <= 1e-4) and
46:     ((@q - other.q).abs <= 1e-4) 
47:   end

[Source]

    # File lib/color/yiq.rb, line 53
53:   def brightness
54:     @y
55:   end

[Source]

    # File lib/color/yiq.rb, line 56
56:   def to_grayscale
57:     Color::GrayScale.new(@y)
58:   end
to_greyscale()

Alias for to_grayscale

[Source]

    # File lib/color/yiq.rb, line 49
49:   def to_yiq
50:     self
51:   end

[Validate]