class Color::CMYK

Public Class Methods

cgats_color_rep() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 14
def self.cgats_color_rep
  'CMYKcmk1k'
end
cgats_fields() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 9
def self.cgats_fields
  %w{CMYKcmk1k_C CMYKcmk1k_M CMYKcmk1k_Y CMYKcmk1k_K
     CMYKcmk1k_c CMYKcmk1k_m CMYKcmk1k_k CMYKcmk1k_1k}
end
component_names() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 5
def self.component_names
  [:c, :m, :y, :k, :lc, :lm, :lk, :llk]
end

Public Instance Methods

c() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 18
def c
  @components[0]
end
k() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 30
def k
  @components[3]
end
lc() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 34
def lc
  @components[4]
end
lk() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 42
def lk
  @components[6]
end
llk() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 46
def llk
  @components[7]
end
lm() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 38
def lm
  @components[5]
end
m() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 22
def m
  @components[1]
end
to_a() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 106
def to_a
  @components
end
to_cgats() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 50
def to_cgats
  {
    'CMYKcmk1k_C'  => c,
    'CMYKcmk1k_M'  => m,
    'CMYKcmk1k_Y'  => y,
    'CMYKcmk1k_K'  => k,
    'CMYKcmk1k_c'  => lc,
    'CMYKcmk1k_m'  => lm,
    'CMYKcmk1k_k'  => lk,
    'CMYKcmk1k_1k' => llk,
  }
end
to_cmy() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 77
def to_cmy
  # after http://www.easyrgb.com/index.php?X=MATH&H=14#text14

  c0, m0, y0, k0 = *to_cmyk
  c0 /= 100.0
  m0 /= 100.0
  y0 /= 100.0
  k0 /= 100.0

  c0 = (c0 * (1 - k0)) + k0
  m0 = (m0 * (1 - k0)) + k0
  y0 = (y0 * (1 - k0)) + k0

  Color::CMYK.new([c0 * 100, m0 * 100, y0 * 100])
end
to_cmyk() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 63
def to_cmyk
  # estimates for light & light-light inks
  l_factor = 0.5
  ll_factor = 0.25

  # first adjust for light inks
  c0 = c + (lc * l_factor)
  m0 = m + (lm * l_factor)
  y0 = y
  k0 = k + (lk * l_factor) + (llk * ll_factor)

  Color::CMYK.new([c0, m0, y0, k0])
end
to_lab() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 98
def to_lab
  to_xyz.to_lab
end
to_rgb() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 93
def to_rgb
  cmy = to_cmy
  Color::RGB.new([1 - (cmy.c / 100), 1 - (cmy.m / 100), 1 - (cmy.y / 100)])
end
to_xyz() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 102
def to_xyz
  to_rgb.to_xyz
end
y() click to toggle source
# File lib/quadtone/color/cmyk.rb, line 26
def y
  @components[2]
end