lib/color_lib/cmyk.rb
# Converts the CMYK colour to RGB. Most colour experts strongly suggest
# that this is not a good idea (some even suggesting that it's a very bad
# idea). CMYK represents additive percentages of inks on white paper,
# whereas RGB represents mixed colour intensities on a black screen.
#
# However, the colour conversion can be done, and there are two different
# methods for the conversion that provide slightly different results.
# Adobe PDF conversions are done with the first form.
#
#     # Adobe PDF Display Formula
#   r = 1.0 - min(1.0, c + k)
#   g = 1.0 - min(1.0, m + k)
#   b = 1.0 - min(1.0, y + k)
#
#     # Other
#   r = 1.0 - (c * (1.0 - k) + k)
#   g = 1.0 - (m * (1.0 - k) + k)
#   b = 1.0 - (y * (1.0 - k) + k)
#
# If we have a CMYK colour of [33% 66% 83% 25%], the first method will
# give an approximate RGB colour of (107, 23, 0) or #6b1700. The second
# method will give an approximate RGB colour of (128, 65, 33) or #804121.
# Which is correct? Although the colours may seem to be drastically
# different in the RGB colour space, they are very similar colours,
# differing mostly in intensity. The first is a darker, slightly redder
# brown; the second is a lighter brown.
#
# Because of this subtlety, both methods are now offered for conversion.
# The Adobe method is not used by default; to enable it, pass +true+ to
# #to_rgb.
#
# Future versions of ColorLib may offer other conversion mechanisms that
# offer greater colour fidelity, including recognition of ICC colour
# profiles.
Converts the CMYK colour to RGB. Most colour experts strongly suggest
that this is not a good idea (some even suggesting that it's a very bad
idea). CMYK represents additive percentages of inks on white paper,
whereas RGB represents mixed colour intensities on a black screen.

However, the colour conversion can be done, and there are two different
methods for the conversion that provide slightly different results.
Adobe PDF conversions are done with the first form.





If we have a CMYK colour of [33% 66% 83% 25%], the first method will
give an approximate RGB colour of (107, 23, 0) or #6b1700. The second
method will give an approximate RGB colour of (128, 65, 33) or #804121.
Which is correct. Although the colours may seem to be drastically
different in the RGB colour space, they are very similar colours,
differing mostly in intensity. The first is a darker, slightly redder
brown; the second is a lighter brown.

Because of this subtlety, both methods are now offered for conversion.
The Adobe method is not used by default; to enable it, pass +true+ to
to_rgb.

Future versions of ColorLib may offer other conversion mechanisms that
offer greater colour fidelity, including recognition of ICC colour
profiles.
Converts the CMYK colour to RGB . Most colour experts strongly suggest that this is not a good idea ( some even suggesting that it ' s a very bad idea ) . CMYK represents additive percentages of inks on white paper whereas RGB represents mixed colour intensities on a black screen . However the colour conversion can be done and there are two different methods for the conversion that provide slightly different results . Adobe PDF conversions are done with the first form . If we have a CMYK colour of [ 33% 66% 83% 25% ] the first method will give an approximate RGB colour of ( 107 23 0 ) or #6b1700 . The second method will give an approximate RGB colour of ( 128 65 33 ) or #804121 . Which is correct . Although the colours may seem to be drastically different in the RGB colour space they are very similar colours differing mostly in intensity . The first is a darker slightly redder brown ; the second is a lighter brown . Because of this subtlety both methods are now offered for conversion . The Adobe method is not used by default ; to enable it pass + true + to to_rgb . Future versions of ColorLib may offer other conversion mechanisms that offer greater colour fidelity including recognition of ICC colour profiles .
def to_rgb(use_adobe_method = false)
    if use_adobe_method
      r = 1.0 - [1.0, @c + @k].min
      g = 1.0 - [1.0, @m + @k].min
      b = 1.0 - [1.0, @y + @k].min
    else
      r = 1.0 - (@c.to_f * (1.0 - @k.to_f) + @k.to_f)
      g = 1.0 - (@m.to_f * (1.0 - @k.to_f) + @k.to_f)
      b = 1.0 - (@y.to_f * (1.0 - @k.to_f) + @k.to_f)
    end
    ColorLib::RGB.from_fraction(r, g, b)
  end
def to_rgb ( use_adobe_method = false ) if use_adobe_method r = 1.0 - [ 1.0 , @c + @k ] . min g = 1.0 - [ 1.0 , @m + @k ] . min b = 1.0 - [ 1.0 , @y + @k ] . min else r = 1.0 - ( @c . to_f * ( 1.0 - @k . to_f ) + @k . to_f ) g = 1.0 - ( @m . to_f * ( 1.0 - @k . to_f ) + @k . to_f ) b = 1.0 - ( @y . to_f * ( 1.0 - @k . to_f ) + @k . to_f ) end ColorLib :: RGB . from_fraction ( r , g , b ) end
Converts the CMYK colour to RGB.
Converts the CMYK colour to RGB .
use_adobe_method
<not_specific>