Class: Abachrome::Converters::SrgbToCmyk
- Inherits:
-
Object
- Object
- Abachrome::Converters::SrgbToCmyk
- Defined in:
- lib/abachrome/converters/srgb_to_cmyk.rb
Class Method Summary collapse
-
.convert(srgb_color, gcr_amount: 1.0) ⇒ Abachrome::Color
Converts a color from sRGB color space to CMYK color space.
-
.convert_naive(srgb_color) ⇒ Abachrome::Color
Converts a color from sRGB to CMYK using the naive method (no UCR/GCR).
Class Method Details
.convert(srgb_color, gcr_amount: 1.0) ⇒ Abachrome::Color
Converts a color from sRGB color space to CMYK color space. Uses full GCR (Gray Component Replacement) by default for optimal ink usage.
with the same alpha value as the input color
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/abachrome/converters/srgb_to_cmyk.rb', line 31 def self.convert(srgb_color, gcr_amount: 1.0) r, g, b = srgb_color.coordinates.map { |c| AbcDecimal(c) } # Use GCR conversion from the CMYK color model c, m, y, k = ColorModels::CMYK.from_rgb_gcr(r, g, b, gcr_amount) Color.new( ColorSpace.find(:cmyk), [c, m, y, k], srgb_color.alpha ) end |
.convert_naive(srgb_color) ⇒ Abachrome::Color
Converts a color from sRGB to CMYK using the naive method (no UCR/GCR). This produces higher ink coverage but simpler conversion. Generally not recommended for production printing.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/abachrome/converters/srgb_to_cmyk.rb', line 50 def self.convert_naive(srgb_color) r, g, b = srgb_color.coordinates.map { |c| AbcDecimal(c) } # Use naive conversion from the CMYK color model c, m, y, k = ColorModels::CMYK.from_rgb_naive(r, g, b) Color.new( ColorSpace.find(:cmyk), [c, m, y, k], srgb_color.alpha ) end |