Class: Color::QTR

Inherits:
Base
  • Object
show all
Defined in:
lib/quadtone/color/qtr.rb

Constant Summary collapse

Channels =

QTR channel map (in calibration mode):

R: inverse bitmask for channels

  7: K	 = 127 (01111111)
  6: C	 = 191 (10111111)
  5: M	 = 223 (11011111)
  4: Y	 = 239 (11101111)
  3: LC	 = 247 (11110111)
  2: LM	 = 251 (11111011)
  1: LK	 = 253 (11111101)
  0: LLK = 254 (11111110)

G: value (0-255)

B: unused -- should always be 255

For background, use R=127 / G=255 / B=255
[:llk, :lk, :lm, :lc, :y, :m, :c, :k]

Instance Attribute Summary

Attributes inherited from Base

#components

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#<=>, average, colorspace_name, #eql?, from_cgats, #hash, #initialize, num_components, #to_s, #to_str

Methods included from Math

#deg2rad, #rad2deg

Constructor Details

This class inherits a constructor from Color::Base

Class Method Details

.cgats_fieldsObject



35
36
37
# File 'lib/quadtone/color/qtr.rb', line 35

def self.cgats_fields
  %w{QTR_CHANNEL QTR_VALUE}
end

.component_namesObject



31
32
33
# File 'lib/quadtone/color/qtr.rb', line 31

def self.component_names
  [:channel, :value]
end

Instance Method Details

#channelObject



39
40
41
# File 'lib/quadtone/color/qtr.rb', line 39

def channel
  @components[0]
end

#channel_numObject



43
44
45
# File 'lib/quadtone/color/qtr.rb', line 43

def channel_num
  Channels.index(channel)
end

#to_cgatsObject



62
63
64
65
66
67
# File 'lib/quadtone/color/qtr.rb', line 62

def to_cgats
  {
    'QTR_CHANNEL' => channel,
    'QTR_VALUE' => value,
  }
end

#to_grayObject



58
59
60
# File 'lib/quadtone/color/qtr.rb', line 58

def to_gray
  Color::Gray.new(k: value)
end

#to_rgbObject



51
52
53
54
55
56
# File 'lib/quadtone/color/qtr.rb', line 51

def to_rgb
  Color::RGB.new(
    r: (255 - (1 << channel_num)) / 255.0,
    g: (1 - value) / 100,
    b: 1)
end

#valueObject



47
48
49
# File 'lib/quadtone/color/qtr.rb', line 47

def value
  @components[1]
end