Class: ColorConverters::CmykConverter
- Inherits:
-
BaseConverter
- Object
- BaseConverter
- ColorConverters::CmykConverter
- Defined in:
- lib/color_converters/converters/cmyk_converter.rb
Constant Summary
Constants inherited from BaseConverter
BaseConverter::IMPORT_DP, BaseConverter::OUTPUT_DP
Instance Attribute Summary
Attributes inherited from BaseConverter
Class Method Summary collapse
Methods inherited from BaseConverter
#alpha, #cielab, #cielch, #cmyk, factory, #hex, #hsb, #hsl, #hsv, inherited, #initialize, #name, #oklab, #oklch, #rgb, #xyz
Constructor Details
This class inherits a constructor from ColorConverters::BaseConverter
Class Method Details
.bounds ⇒ Object
11 12 13 |
# File 'lib/color_converters/converters/cmyk_converter.rb', line 11 def self.bounds { c: [0.0, 100.0], m: [0.0, 100.0], y: [0.0, 100.0], k: [0.0, 100.0] } end |
.matches?(colour_input) ⇒ Boolean
5 6 7 8 9 |
# File 'lib/color_converters/converters/cmyk_converter.rb', line 5 def self.matches?(colour_input) return false unless colour_input.is_a?(Hash) colour_input.keys - [:c, :m, :y, :k] == [] end |
.rgb_to_cmyk(rgb_array_frac) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/color_converters/converters/cmyk_converter.rb', line 45 def self.rgb_to_cmyk(rgb_array_frac) r, g, b = rgb_array_frac k = (1.0 - [r, g, b].max) k_frac = k == 1.0 ? 1.0 : 1.0 - k c = (1.0 - r - k) / k_frac m = (1.0 - g - k) / k_frac y = (1.0 - b - k) / k_frac c *= 100 m *= 100 y *= 100 k *= 100 [c, m, y, k] end |