Parent

Color::YIQ

A colour object representing YIQ (NTSC) colour encoding.

Public Class Methods

from_fraction(y = 0, i = 0, q = 0) click to toggle source

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

Color::YIQ.new(0.3, 0.2, 0.1)
# File lib/color/yiq.rb, line 6
def self.from_fraction(y = 0, i = 0, q = 0)
  color = Color::YIQ.new
  color.y = y
  color.i = i
  color.q = q
  color
end
new(y = 0, i = 0, q = 0) click to toggle source

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

Color::YIQ.new(10, 20, 30)
# File lib/color/yiq.rb, line 17
def initialize(y = 0, i = 0, q = 0)
  @y = y / 100.0
  @i = i / 100.0
  @q = q / 100.0
end

Public Instance Methods

==(other) click to toggle source

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 COLOR_TOLERANCE of each other.

# File lib/color/yiq.rb, line 30
def ==(other)
  other = other.to_yiq
  other.kind_of?(Color::YIQ) and
  ((@y - other.y).abs <= Color::COLOR_TOLERANCE) and
  ((@i - other.i).abs <= Color::COLOR_TOLERANCE) and
  ((@q - other.q).abs <= Color::COLOR_TOLERANCE)
end
brightness() click to toggle source
# File lib/color/yiq.rb, line 42
def brightness
  @y
end
i() click to toggle source
# File lib/color/yiq.rb, line 56
def i
  @i
end
i=(ii) click to toggle source
# File lib/color/yiq.rb, line 59
def i=(ii)
  @i = Color.normalize(ii)
end
inspect() click to toggle source
# File lib/color/yiq.rb, line 69
def inspect
  "YIQ [%.2f%%, %.2f%%, %.2f%%]" % [ @y * 100, @i * 100, @q * 100 ]
end
q() click to toggle source
# File lib/color/yiq.rb, line 62
def q
  @q
end
q=(qq) click to toggle source
# File lib/color/yiq.rb, line 65
def q=(qq)
  @q = Color.normalize(qq)
end
to_grayscale() click to toggle source
# File lib/color/yiq.rb, line 45
def to_grayscale
  Color::GrayScale.new(@y)
end
Also aliased as: to_greyscale
to_greyscale() click to toggle source
Alias for: to_grayscale
to_yiq() click to toggle source
# File lib/color/yiq.rb, line 38
def to_yiq
  self
end
y() click to toggle source
# File lib/color/yiq.rb, line 50
def y
  @y
end
y=(yy) click to toggle source
# File lib/color/yiq.rb, line 53
def y=(yy)
  @y = Color.normalize(yy)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.