color_converters 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,106 +1,109 @@
1
- module ColorConverters
2
- class RgbConverter < BaseConverter
3
- def self.matches?(color_input)
4
- return false unless color_input.is_a?(Hash)
5
-
6
- color_input.keys - [:r, :g, :b] == [] || color_input.keys - [:r, :g, :b, :a] == []
7
- end
8
-
9
- def self.bounds
10
- { r: [0.0, 255.0], g: [0.0, 255.0], b: [0.0, 255.0] }
11
- end
12
-
13
- private
14
-
15
- def validate_input(color_input)
16
- bounds = RgbConverter.bounds
17
- color_input[:r].to_f.between?(*bounds[:r]) && color_input[:g].to_f.between?(*bounds[:g]) && color_input[:b].to_f.between?(*bounds[:b])
18
- end
19
-
20
- def input_to_rgba(color_input)
21
- r = color_input[:r].to_f
22
- g = color_input[:g].to_f
23
- b = color_input[:b].to_f
24
- a = (color_input[:a] || 1.0).to_f
25
-
26
- [r, g, b, a]
27
- end
28
-
29
- def self.rgb_to_lrgb(rgb_array_frac)
30
- # [0, 1]
31
- r, g, b = rgb_array_frac
32
-
33
- # Inverse sRGB companding. Linearizes RGB channels with respect to energy.
34
- # Assumption that r, g, b are always positive
35
- rr, gg, bb = [r, g, b].map do
36
- if _1.to_d <= 0.04045.to_d
37
- _1.to_d / 12.92.to_d
38
- else
39
- # sRGB Inverse Companding (Non-linear to Linear RGB)
40
- # The sRGB specification (IEC 61966-2-1) defines the exponent as 2.4.
41
- #
42
- (((_1.to_d + 0.055.to_d) / 1.055.to_d)**2.4.to_d)
43
-
44
- # IMPORTANT NUMERICAL NOTE:
45
- # On this specific system (and confirmed by Wolfram Alpha for direct calculation),
46
- # the power function for val**2.4 yields a result that deviates from the value expected by widely-used color science libraries (like Bruce Lindbloom's).
47
- #
48
- # To compensate for this numerical discrepancy and ensure the final CIELAB values match standard online calculators and specifications,
49
- # an empirically determined exponent of 2.5 has been found to produce the correct linearized sRGB values on this environment.
50
- #
51
- # Choose 2.4 for strict adherence to the standard's definition (knowing your results may slightly deviate from common calculators),
52
- # or choose 2.5 to ensure your calculated linear RGB values (and thus CIELAB) match authoritative external tools on this system.
53
- #
54
- # ((_1 + 0.055) / 1.055)**2.5
55
- end
56
- end
57
-
58
- # [0, 1]
59
- [rr, gg, bb]
60
- end
61
-
62
- def self.lrgb_to_rgb(lrgb_array)
63
- rr, gg, bb = lrgb_array
64
-
65
- # Apply sRGB Companding (gamma correction) to convert from Linear RGB to non-linear sRGB.
66
- # This is defined by the sRGB specification (IEC 61966-2-1).
67
- # The exponent for the non-linear segment is 1/2.4 (approximately 0.41666...).
68
- # Assumption that rr, gg, bb are always positive
69
- r, g, b = [rr, gg, bb].map do
70
- if _1.to_d <= 0.0031308.to_d
71
- # Linear portion of the sRGB curve
72
- _1.to_d * 12.92.to_d
73
- else
74
- # Non-linear (gamma-corrected) portion of the sRGB curve
75
- # The sRGB specification uses an exponent of 1/2.4.
76
- #
77
- (1.055.to_d * (_1.to_d**(1.0.to_d / 2.4.to_d))) - 0.055.to_d
78
-
79
- # IMPORTANT NUMERICAL NOTE:
80
- # On this specific system (and confirmed by Wolfram Alpha for direct calculation),
81
- # the inverse power function for val**2.4 yields a result that deviates from the value expected by widely-used color science libraries (like Bruce Lindbloom's).
82
- #
83
- # To compensate for this numerical discrepancy and ensure the final CIELAB values match standard online calculators and specifications,
84
- # an empirically determined exponent of 2.5 has been found to produce the correct linearized sRGB values on this environment.
85
- #
86
- # Choose 1/2.4 for strict adherence to the standard's definition (knowing your results may slightly deviate from common calculators),
87
- # or choose 1/2.5 to ensure your calculated linear RGB values (and thus CIELAB) match authoritative external tools on this system.
88
- #
89
- # (1.055 * (_1**(1.0 / 2.5))) - 0.055
90
- end
91
- end
92
-
93
- # Scale the 0-1 sRGB value to the 0-255 range for 8-bit color components.
94
- r *= 255.0.to_d
95
- g *= 255.0.to_d
96
- b *= 255.0.to_d
97
-
98
- # Clamping RGB values to prevent out-of-gamut issues and numerical errors and ensures these values stay within the valid and expected range.
99
- r = r.clamp(0.0..255.0)
100
- g = g.clamp(0.0..255.0)
101
- b = b.clamp(0.0..255.0)
102
-
103
- [r, g, b]
104
- end
105
- end
106
- end
1
+ # frozen_string_literal: true
2
+
3
+ module ColorConverters
4
+ class RgbConverter < BaseConverter
5
+ def self.matches?(colour_input)
6
+ return false unless colour_input.is_a?(Hash)
7
+
8
+ colour_input.keys - [:r, :g, :b] == [] || colour_input.keys - [:r, :g, :b, :a] == []
9
+ end
10
+
11
+ def self.bounds
12
+ { r: [0.0, 255.0], g: [0.0, 255.0], b: [0.0, 255.0], a: [0.0, 1.0] }
13
+ end
14
+
15
+ private
16
+
17
+ def validate_input(colour_input)
18
+ RgbConverter.bounds.collect do |key, range|
19
+ "#{key} must be between #{range[0]} and #{range[1]}" unless colour_input[key].to_f.between?(*range)
20
+ end.compact
21
+ end
22
+
23
+ def input_to_rgba(colour_input)
24
+ r = colour_input[:r].to_f
25
+ g = colour_input[:g].to_f
26
+ b = colour_input[:b].to_f
27
+ a = (colour_input[:a] || 1.0).to_f
28
+
29
+ [r, g, b, a]
30
+ end
31
+
32
+ def self.rgb_to_lrgb(rgb_array_frac)
33
+ # [0, 1]
34
+ r, g, b = rgb_array_frac
35
+
36
+ # Inverse sRGB companding. Linearizes RGB channels with respect to energy.
37
+ # Assumption that r, g, b are always positive
38
+ rr, gg, bb = [r, g, b].map do
39
+ if _1.to_d <= 0.04045.to_d
40
+ _1.to_d / 12.92.to_d
41
+ else
42
+ # sRGB Inverse Companding (Non-linear to Linear RGB)
43
+ # The sRGB specification (IEC 61966-2-1) defines the exponent as 2.4.
44
+ #
45
+ (((_1.to_d + 0.055.to_d) / 1.055.to_d)**2.4.to_d)
46
+
47
+ # IMPORTANT NUMERICAL NOTE:
48
+ # On this specific system (and confirmed by Wolfram Alpha for direct calculation),
49
+ # the power function for val**2.4 yields a result that deviates from the value expected by widely-used colour science libraries (like Bruce Lindbloom's).
50
+ #
51
+ # To compensate for this numerical discrepancy and ensure the final CIELAB values match standard online calculators and specifications,
52
+ # an empirically determined exponent of 2.5 has been found to produce the correct linearized sRGB values on this environment.
53
+ #
54
+ # Choose 2.4 for strict adherence to the standard's definition (knowing your results may slightly deviate from common calculators),
55
+ # or choose 2.5 to ensure your calculated linear RGB values (and thus CIELAB) match authoritative external tools on this system.
56
+ #
57
+ # ((_1 + 0.055) / 1.055)**2.5
58
+ end
59
+ end
60
+
61
+ # [0, 1]
62
+ [rr, gg, bb]
63
+ end
64
+
65
+ def self.lrgb_to_rgb(lrgb_array)
66
+ rr, gg, bb = lrgb_array
67
+
68
+ # Apply sRGB Companding (gamma correction) to convert from Linear RGB to non-linear sRGB.
69
+ # This is defined by the sRGB specification (IEC 61966-2-1).
70
+ # The exponent for the non-linear segment is 1/2.4 (approximately 0.41666...).
71
+ # Assumption that rr, gg, bb are always positive
72
+ r, g, b = [rr, gg, bb].map do
73
+ if _1.to_d <= 0.0031308.to_d
74
+ # Linear portion of the sRGB curve
75
+ _1.to_d * 12.92.to_d
76
+ else
77
+ # Non-linear (gamma-corrected) portion of the sRGB curve
78
+ # The sRGB specification uses an exponent of 1/2.4.
79
+ #
80
+ (1.055.to_d * (_1.to_d**(1.0.to_d / 2.4.to_d))) - 0.055.to_d
81
+
82
+ # IMPORTANT NUMERICAL NOTE:
83
+ # On this specific system (and confirmed by Wolfram Alpha for direct calculation),
84
+ # the inverse power function for val**2.4 yields a result that deviates from the value expected by widely-used colour science libraries (like Bruce Lindbloom's).
85
+ #
86
+ # To compensate for this numerical discrepancy and ensure the final CIELAB values match standard online calculators and specifications,
87
+ # an empirically determined exponent of 2.5 has been found to produce the correct linearized sRGB values on this environment.
88
+ #
89
+ # Choose 1/2.4 for strict adherence to the standard's definition (knowing your results may slightly deviate from common calculators),
90
+ # or choose 1/2.5 to ensure your calculated linear RGB values (and thus CIELAB) match authoritative external tools on this system.
91
+ #
92
+ # (1.055 * (_1**(1.0 / 2.5))) - 0.055
93
+ end
94
+ end
95
+
96
+ # Scale the 0-1 sRGB value to the 0-255 range for 8-bit colour components.
97
+ r *= 255.0.to_d
98
+ g *= 255.0.to_d
99
+ b *= 255.0.to_d
100
+
101
+ # Clamping RGB values to prevent out-of-gamut issues and numerical errors and ensures these values stay within the valid and expected range.
102
+ r = r.clamp(0.0..255.0)
103
+ g = g.clamp(0.0..255.0)
104
+ b = b.clamp(0.0..255.0)
105
+
106
+ [r, g, b]
107
+ end
108
+ end
109
+ end
@@ -1,32 +1,49 @@
1
- module ColorConverters
2
- class RgbStringConverter < BaseConverter
3
- def self.matches?(color_input)
4
- return false unless color_input.is_a?(String)
5
-
6
- color_input.include?('rgb(') || color_input.include?('rgba(')
7
- end
8
-
9
- private
10
-
11
- def validate_input(_color_input)
12
- true
13
- end
14
-
15
- def input_to_rgba(color_input)
16
- matches = color_input.match(/rgba?\(([0-9.,\s]+)\)/)
17
- raise InvalidColorError unless matches
18
-
19
- r, g, b, a = matches[1].split(',').map(&:strip)
20
- raise InvalidColorError unless r.present? && g.present? && b.present?
21
-
22
- a ||= 1.0
23
-
24
- r = r.to_f
25
- g = g.to_f
26
- b = b.to_f
27
- a = a.to_f
28
-
29
- [r, g, b, a]
30
- end
31
- end
32
- end
1
+ # frozen_string_literal: true
2
+
3
+ module ColorConverters
4
+ class RgbStringConverter < BaseConverter
5
+ def self.matches?(colour_input)
6
+ return false unless colour_input.is_a?(String)
7
+
8
+ colour_input.include?('rgb(') || colour_input.include?('rgba(')
9
+ end
10
+
11
+ def self.bounds
12
+ RgbConverter.bounds
13
+ end
14
+
15
+ private
16
+
17
+ def validate_input(colour_input)
18
+ keys = colour_input.include?('rgba(') ? [:r, :g, :b, :a] : [:r, :g, :b]
19
+ colour_input = RgbStringConverter.sanitize_input(colour_input)
20
+
21
+ errors = keys.collect do |key|
22
+ "#{key} must be present" if colour_input[key].blank?
23
+ end.compact
24
+
25
+ return errors if errors.present?
26
+
27
+ RgbStringConverter.bounds.collect do |key, range|
28
+ "#{key} must be between #{range[0]} and #{range[1]}" unless colour_input[key].to_f.between?(*range)
29
+ end.compact
30
+ end
31
+
32
+ def input_to_rgba(colour_input)
33
+ colour_input = RgbStringConverter.sanitize_input(colour_input)
34
+
35
+ r = colour_input[:r].to_f
36
+ g = colour_input[:g].to_f
37
+ b = colour_input[:b].to_f
38
+ a = (colour_input[:a] || 1.0).to_f
39
+
40
+ [r, g, b, a]
41
+ end
42
+
43
+ def self.sanitize_input(colour_input)
44
+ matches = colour_input.match(/rgba?\(([0-9.,%\s]+)\)/) || []
45
+ r, g, b, a = matches[1]&.split(',')&.map(&:strip)
46
+ { r: r, g: g, b: b, a: a }
47
+ end
48
+ end
49
+ end
@@ -1,107 +1,110 @@
1
- module ColorConverters
2
- class XyzConverter < BaseConverter
3
- def self.matches?(color_input)
4
- return false unless color_input.is_a?(Hash)
5
-
6
- color_input.keys - [:x, :y, :z] == []
7
- end
8
-
9
- def self.d65
10
- { x: 95.047, y: 100.0, z: 108.883 }
11
- end
12
-
13
- def self.bounds
14
- { x: [0.0, 100.0], y: [0.0, 100.0], z: [0.0, 110.0] }
15
- end
16
-
17
- private
18
-
19
- def validate_input(color_input)
20
- bounds = XyzConverter.bounds
21
- color_input[:x].to_f.between?(*bounds[:x]) && color_input[:y].to_f.between?(*bounds[:y]) && color_input[:z].to_f.between?(*bounds[:z])
22
- end
23
-
24
- def input_to_rgba(color_input)
25
- r, g, b = XyzConverter.xyz_to_rgb(color_input)
26
-
27
- [r, g, b, 1.0]
28
- end
29
-
30
- def self.xyz_to_rgb(xyz_hash)
31
- # [0, 100]
32
- x = xyz_hash[:x].to_d
33
- y = xyz_hash[:y].to_d
34
- z = xyz_hash[:z].to_d
35
-
36
- # Convert XYZ (typically with Y=100 for white) to normalized XYZ (Y=1 for white).
37
- # The transformation matrix expects X, Y, Z values in the 0-1 range.
38
- x /= 100.0.to_d
39
- y /= 100.0.to_d
40
- z /= 100.0.to_d
41
-
42
- # Convert normalized XYZ to Linear sRGB values using sRGB's own white, D65 (no chromatic adaptation)
43
- # https://www.w3.org/TR/css-color-4/#color-conversion-code
44
- conversion_matrix = ::Matrix[
45
- [BigDecimal('3.2409699419045213'), BigDecimal('-1.5373831775700935'), BigDecimal('-0.4986107602930033')],
46
- [BigDecimal('-0.9692436362808798'), BigDecimal('1.8759675015077206'), BigDecimal('0.04155505740717561')],
47
- [BigDecimal('0.05563007969699361'), BigDecimal('-0.20397695888897657'), BigDecimal('1.0569715142428786')]
48
- ]
49
-
50
- rr, gg, bb = (conversion_matrix * ::Matrix.column_vector([x, y, z])).to_a.flatten
51
-
52
- # [0, 1]
53
- RgbConverter.lrgb_to_rgb([rr, gg, bb])
54
- end
55
-
56
- # http://www.brucelindbloom.com/index.html?Eqn_RGB_to_XYZ.html
57
- def self.rgb_to_xyz(rgb_array_frac)
58
- rr, gg, bb = RgbConverter.rgb_to_lrgb(rgb_array_frac)
59
-
60
- # Convert using the RGB/XYZ matrix and sRGB's own white, D65 (no chromatic adaptation)
61
- # https://www.w3.org/TR/css-color-4/#color-conversion-code
62
- conversion_matrix = ::Matrix[
63
- [BigDecimal('0.4123907992659595'), BigDecimal('0.35758433938387796'), BigDecimal('0.1804807884018343')],
64
- [BigDecimal('0.21263900587151036'), BigDecimal('0.7151686787677559'), BigDecimal('0.07219231536073371')],
65
- [BigDecimal('0.01933081871559185'), BigDecimal('0.11919477979462599'), BigDecimal('0.9505321522496606')]
66
- ]
67
-
68
- x, y, z = (conversion_matrix * ::Matrix.column_vector([rr, gg, bb])).to_a.flatten
69
-
70
- # Now, scale X, Y, Z so that Y for D65 white would be 100.
71
- x *= 100.0
72
- y *= 100.0
73
- z *= 100.0
74
-
75
- # Clamping XYZ values to prevent out-of-gamut issues and numerical errors and ensures these values stay within the valid and expected range.
76
- # x = x.clamp(0.0..95.047)
77
- # y = y.clamp(0.0..100.0)
78
- # z = z.clamp(0.0..108.883)
79
-
80
- [x, y, z]
81
- end
82
-
83
- def self.d50_to_d65(xyz_array)
84
- x, y, z = xyz_array
85
-
86
- conversion_matrix = ::Matrix[
87
- [BigDecimal('0.955473421488075'), BigDecimal('-0.02309845494876471'), BigDecimal('0.06325924320057072')],
88
- [BigDecimal('-0.0283697093338637'), BigDecimal('1.0099953980813041'), BigDecimal('0.021041441191917323')],
89
- [BigDecimal('0.012314014864481998'), BigDecimal('-0.020507649298898964'), BigDecimal('1.330365926242124')]
90
- ]
91
-
92
- (conversion_matrix * ::Matrix.column_vector([x, y, z])).to_a.flatten
93
- end
94
-
95
- def self.d65_to_d50(xyz_array)
96
- x, y, z = xyz_array
97
-
98
- conversion_matrix = ::Matrix[
99
- [BigDecimal('1.0479297925449969'), BigDecimal('0.022946870601609652'), BigDecimal('-0.05019226628920524')],
100
- [BigDecimal('0.02962780877005599'), BigDecimal('0.9904344267538799'), BigDecimal('-0.017073799063418826')],
101
- [BigDecimal('-0.009243040646204504'), BigDecimal('0.015055191490298152'), BigDecimal('0.7518742814281371')]
102
- ]
103
-
104
- (conversion_matrix * ::Matrix.column_vector([x, y, z])).to_a.flatten
105
- end
106
- end
107
- end
1
+ # frozen_string_literal: true
2
+
3
+ module ColorConverters
4
+ class XyzConverter < BaseConverter
5
+ def self.matches?(colour_input)
6
+ return false unless colour_input.is_a?(Hash)
7
+
8
+ colour_input.keys - [:x, :y, :z] == []
9
+ end
10
+
11
+ def self.d65
12
+ { x: 95.047, y: 100.0, z: 108.883 }
13
+ end
14
+
15
+ def self.bounds
16
+ { x: [0.0, 100.0], y: [0.0, 100.0], z: [0.0, 110.0] }
17
+ end
18
+
19
+ private
20
+
21
+ def validate_input(colour_input)
22
+ XyzConverter.bounds.collect do |key, range|
23
+ "#{key} must be between #{range[0]} and #{range[1]}" unless colour_input[key].to_f.between?(*range)
24
+ end.compact
25
+ end
26
+
27
+ def input_to_rgba(colour_input)
28
+ r, g, b = XyzConverter.xyz_to_rgb(colour_input)
29
+
30
+ [r, g, b, 1.0]
31
+ end
32
+
33
+ def self.xyz_to_rgb(xyz_hash)
34
+ # [0, 100]
35
+ x = xyz_hash[:x].to_d
36
+ y = xyz_hash[:y].to_d
37
+ z = xyz_hash[:z].to_d
38
+
39
+ # Convert XYZ (typically with Y=100 for white) to normalized XYZ (Y=1 for white).
40
+ # The transformation matrix expects X, Y, Z values in the 0-1 range.
41
+ x /= 100.0.to_d
42
+ y /= 100.0.to_d
43
+ z /= 100.0.to_d
44
+
45
+ # Convert normalized XYZ to Linear sRGB values using sRGB's own white, D65 (no chromatic adaptation)
46
+ # https://www.w3.org/TR/css-color-4/#color-conversion-code
47
+ conversion_matrix = ::Matrix[
48
+ [BigDecimal('3.2409699419045213'), BigDecimal('-1.5373831775700935'), BigDecimal('-0.4986107602930033')],
49
+ [BigDecimal('-0.9692436362808798'), BigDecimal('1.8759675015077206'), BigDecimal('0.04155505740717561')],
50
+ [BigDecimal('0.05563007969699361'), BigDecimal('-0.20397695888897657'), BigDecimal('1.0569715142428786')]
51
+ ]
52
+
53
+ rr, gg, bb = (conversion_matrix * ::Matrix.column_vector([x, y, z])).to_a.flatten
54
+
55
+ # [0, 1]
56
+ RgbConverter.lrgb_to_rgb([rr, gg, bb])
57
+ end
58
+
59
+ # http://www.brucelindbloom.com/index.html?Eqn_RGB_to_XYZ.html
60
+ def self.rgb_to_xyz(rgb_array_frac)
61
+ rr, gg, bb = RgbConverter.rgb_to_lrgb(rgb_array_frac)
62
+
63
+ # Convert using the RGB/XYZ matrix and sRGB's own white, D65 (no chromatic adaptation)
64
+ # https://www.w3.org/TR/css-color-4/#color-conversion-code
65
+ conversion_matrix = ::Matrix[
66
+ [BigDecimal('0.4123907992659595'), BigDecimal('0.35758433938387796'), BigDecimal('0.1804807884018343')],
67
+ [BigDecimal('0.21263900587151036'), BigDecimal('0.7151686787677559'), BigDecimal('0.07219231536073371')],
68
+ [BigDecimal('0.01933081871559185'), BigDecimal('0.11919477979462599'), BigDecimal('0.9505321522496606')]
69
+ ]
70
+
71
+ x, y, z = (conversion_matrix * ::Matrix.column_vector([rr, gg, bb])).to_a.flatten
72
+
73
+ # Now, scale X, Y, Z so that Y for D65 white would be 100.
74
+ x *= 100.0
75
+ y *= 100.0
76
+ z *= 100.0
77
+
78
+ # Clamping XYZ values to prevent out-of-gamut issues and numerical errors and ensures these values stay within the valid and expected range.
79
+ # x = x.clamp(0.0..95.047)
80
+ # y = y.clamp(0.0..100.0)
81
+ # z = z.clamp(0.0..108.883)
82
+
83
+ [x, y, z]
84
+ end
85
+
86
+ def self.d50_to_d65(xyz_array)
87
+ x, y, z = xyz_array
88
+
89
+ conversion_matrix = ::Matrix[
90
+ [BigDecimal('0.955473421488075'), BigDecimal('-0.02309845494876471'), BigDecimal('0.06325924320057072')],
91
+ [BigDecimal('-0.0283697093338637'), BigDecimal('1.0099953980813041'), BigDecimal('0.021041441191917323')],
92
+ [BigDecimal('0.012314014864481998'), BigDecimal('-0.020507649298898964'), BigDecimal('1.330365926242124')]
93
+ ]
94
+
95
+ (conversion_matrix * ::Matrix.column_vector([x, y, z])).to_a.flatten
96
+ end
97
+
98
+ def self.d65_to_d50(xyz_array)
99
+ x, y, z = xyz_array
100
+
101
+ conversion_matrix = ::Matrix[
102
+ [BigDecimal('1.0479297925449969'), BigDecimal('0.022946870601609652'), BigDecimal('-0.05019226628920524')],
103
+ [BigDecimal('0.02962780877005599'), BigDecimal('0.9904344267538799'), BigDecimal('-0.017073799063418826')],
104
+ [BigDecimal('-0.009243040646204504'), BigDecimal('0.015055191490298152'), BigDecimal('0.7518742814281371')]
105
+ ]
106
+
107
+ (conversion_matrix * ::Matrix.column_vector([x, y, z])).to_a.flatten
108
+ end
109
+ end
110
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ColorConverters
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
@@ -1,30 +1,31 @@
1
- # frozen_string_literal: true
2
-
3
- require 'forwardable'
4
-
5
- require 'color_converters/version'
6
-
7
- require 'color_converters/color'
8
- require 'color_converters/base_converter'
9
-
10
- require 'color_converters/converters/rgb_converter'
11
- require 'color_converters/converters/rgb_string_converter'
12
- require 'color_converters/converters/hex_converter'
13
- require 'color_converters/converters/hsl_converter'
14
- require 'color_converters/converters/hsl_string_converter'
15
- require 'color_converters/converters/hsv_converter'
16
- require 'color_converters/converters/cmyk_converter'
17
- require 'color_converters/converters/xyz_converter'
18
- require 'color_converters/converters/cielab_converter'
19
- require 'color_converters/converters/cielch_converter'
20
- require 'color_converters/converters/oklab_converter'
21
- require 'color_converters/converters/oklch_converter'
22
-
23
- require 'color_converters/converters/name_converter'
24
- require 'color_converters/converters/null_converter'
25
-
26
- module ColorConverters
27
- class Error < StandardError; end
28
- class InvalidColorError < Error; end
29
- # Your code goes here...
30
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+
5
+ require 'color_converters/version'
6
+
7
+ require 'color_converters/color'
8
+ require 'color_converters/base_converter'
9
+
10
+ # Converters
11
+ require 'color_converters/converters/rgb_converter'
12
+ require 'color_converters/converters/rgb_string_converter'
13
+ require 'color_converters/converters/hex_converter'
14
+ require 'color_converters/converters/hsl_converter'
15
+ require 'color_converters/converters/hsl_string_converter'
16
+ require 'color_converters/converters/hsv_converter'
17
+ require 'color_converters/converters/cmyk_converter'
18
+ require 'color_converters/converters/xyz_converter'
19
+ require 'color_converters/converters/cielab_converter'
20
+ require 'color_converters/converters/cielch_converter'
21
+ require 'color_converters/converters/oklab_converter'
22
+ require 'color_converters/converters/oklch_converter'
23
+
24
+ require 'color_converters/converters/name_converter'
25
+ require 'color_converters/converters/null_converter'
26
+
27
+ module ColorConverters
28
+ class Error < StandardError; end
29
+ class InvalidColorError < Error; end
30
+ # Your code goes here...
31
+ end
metadata CHANGED
@@ -1,28 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: color_converters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Davis
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-08-18 00:00:00.000000000 Z
10
+ date: 2025-08-21 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 6.1.3
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 6.1.3
26
+ - !ruby/object:Gem::Dependency
27
+ name: color_swatch_collection
14
28
  requirement: !ruby/object:Gem::Requirement
15
29
  requirements:
16
30
  - - "~>"
17
31
  - !ruby/object:Gem::Version
18
- version: 8.0.2
32
+ version: 0.1.0
19
33
  type: :runtime
20
34
  prerelease: false
21
35
  version_requirements: !ruby/object:Gem::Requirement
22
36
  requirements:
23
37
  - - "~>"
24
38
  - !ruby/object:Gem::Version
25
- version: 8.0.2
39
+ version: 0.1.0
26
40
  - !ruby/object:Gem::Dependency
27
41
  name: matrix
28
42
  requirement: !ruby/object:Gem::Requirement