Class: Color::YIQ

### Home Classes Methods

### In Files

- lib/color.rb
- lib/color/yiq.rb

### Parent

Object

### Methods

- ::from_fraction
- ::new
- #brightness
- #coerce
- #i
- #i=
- #inspect
- #q
- #q=
- #to_a
- #to_grayscale
- #to_greyscale
- #to_yiq
- #y
- #y=

### Included Modules

- Color

### Files

- Manifest.txt

### Class/Module Index

Quicksearch

- Color
- Color::CMYK
- Color::CSS
- Color::GrayScale
- Color::GrayScale
- Color::HSL
- Color::Palette
- Color::Palette::AdobeColor
- Color::Palette::Gimp
- Color::Palette::MonoContrast
- Color::RGB
- Color::RGB::Metallic
- Color::YIQ
- Object
- Object::GreyScale

No matching classes.

# Color::YIQ

A colour object representing YIQ (NTSC) colour encoding.

### Public Class Methods

from_fraction(y = 0, i = 0, q = 0, &block) 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 8
    def self.from_fraction(y = 0, i = 0, q = 0, &block)
      new(y, i, q, 1.0, &block)
    end

new(y = 0, i = 0, q = 0, radix = 100.0, &block) 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 15
    def initialize(y = 0, i = 0, q = 0, radix = 100.0, &block) # :yields self:
      @y, @i, @q = [ y, i, q ].map { |v| Color.normalize(v / radix) }
      block.call if block
    end

### Public Instance Methods

brightness() click to toggle source

    # File lib/color/yiq.rb, line 28
    def brightness
      @y
    end

coerce(other) click to toggle source

    # File lib/color/yiq.rb, line 20
    def coerce(other)
      other.to_yiq
    end

i() click to toggle source

    # File lib/color/yiq.rb, line 42
    def i
      @i
    end

i=(ii) click to toggle source

    # File lib/color/yiq.rb, line 45
    def i=(ii)
      @i = Color.normalize(ii)
    end

inspect() click to toggle source

    # File lib/color/yiq.rb, line 55
    def inspect
      "YIQ [%.2f%%, %.2f%%, %.2f%%]" % [ @y * 100, @i * 100, @q * 100 ]
    end

q() click to toggle source

    # File lib/color/yiq.rb, line 48
    def q
      @q
    end

q=(qq) click to toggle source

    # File lib/color/yiq.rb, line 51
    def q=(qq)
      @q = Color.normalize(qq)
    end

to_a() click to toggle source

    # File lib/color/yiq.rb, line 59
    def to_a
      [ y, i, q ]
    end

to_grayscale() click to toggle source

    # File lib/color/yiq.rb, line 31
    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 24
    def to_yiq
      self
    end

y() click to toggle source

    # File lib/color/yiq.rb, line 36
    def y
      @y
    end

y=(yy) click to toggle source

    # File lib/color/yiq.rb, line 39
    def y=(yy)
      @y = Color.normalize(yy)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.