color_calculator 1.2.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c28ff3b2ee26120ac996daf23d28a84caded747
4
- data.tar.gz: a04f4447df496d86fb51a0aa91545a95001528c2
3
+ metadata.gz: c2f9eedde9d186b943d2d263bcb7b9cdca955aa1
4
+ data.tar.gz: 83aa5302132baffb9c67de6cce7c5d176e2a7a36
5
5
  SHA512:
6
- metadata.gz: 59532f7b280fb30a5c29dc5ae0415ea55bc3cefc4ad3e9bfc850cbfc12f4d8512efe76df5fa797d54784160e744c4fd8f2b093b76d3fec11cac203180c1f6565
7
- data.tar.gz: 9a4a4923aeea6c33e442fa9a91ade506335dd8a1b5da8395e718055f052a28d41963ad8ecd30582c58939608f76ae8905be06ad47f6fcbae8b56ec0aa7e58985
6
+ metadata.gz: 4e5a2eaa5e169eca697a9f927fe1947674e3402c2161fd3f1e875bf3c96f7daa0dbb57052f66c8d7b49c99c979b2a3d14cff88211a600c5bbd219932b7faab10
7
+ data.tar.gz: cff36116887ef46289a7a50ae45dfc84f7e133fe4b3b8c340084aa56d13aa7226cb23a06f856d3a59430ff8452991844fcd0edc6ca20354a0dac32250f9e8340
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'conversion/build'
3
4
  require_relative 'conversion/lab_to_lch'
4
5
  require_relative 'conversion/lab_to_xyz'
5
6
  require_relative 'conversion/lch_to_lab'
@@ -9,41 +10,5 @@ require_relative 'conversion/xyz_to_lab'
9
10
  require_relative 'conversion/xyz_to_rgb'
10
11
 
11
12
  module ColorCalculator
12
- module Conversion
13
- NOOP = -> (value) { value }
14
-
15
- # Doesn't seem like it's worth it to build a proper graph for this yet.
16
- # This map is fine, even if it is a bit repetitive.
17
- MAP = {
18
- lab: {
19
- lab: NOOP,
20
- lch: LabToLch.to_proc,
21
- rgb: [LabToXyz, XyzToRgb].map(&:to_proc).reduce(:>>),
22
- xyz: LabToXyz.to_proc
23
- },
24
- lch: {
25
- lab: LchToLab.to_proc,
26
- lch: NOOP,
27
- rgb: [LchToLab, LabToXyz, XyzToRgb].map(&:to_proc).reduce(:>>),
28
- xyz: [LchToLab, LabToXyz].map(&:to_proc).reduce(:>>)
29
- },
30
- rgb: {
31
- lab: [RgbToXyz, XyzToLab].map(&:to_proc).reduce(:>>),
32
- lch: [RgbToXyz, XyzToLab, LabToLch].map(&:to_proc).reduce(:>>),
33
- rgb: NOOP,
34
- xyz: RgbToXyz.to_proc
35
- },
36
- xyz: {
37
- lab: XyzToLab.to_proc,
38
- lch: [XyzToLab, LabToLch].map(&:to_proc).reduce(:>>),
39
- rgb: XyzToRgb.to_proc,
40
- xyz: NOOP
41
- }
42
- }
43
-
44
- def build(from, to)
45
- MAP[from][to]
46
- end
47
- module_function :build
48
- end
13
+ module Conversion; end
49
14
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lab_to_lch'
4
+ require_relative 'lab_to_xyz'
5
+ require_relative 'lch_to_lab'
6
+ require_relative 'rgb_to_lch'
7
+ require_relative 'rgb_to_xyz'
8
+ require_relative 'xyz_to_lab'
9
+ require_relative 'xyz_to_rgb'
10
+
11
+ module ColorCalculator
12
+ module Conversion
13
+ class Build
14
+ NOOP = -> (value) { value }
15
+
16
+ # Doesn't seem like it's worth it to build a proper graph for this yet.
17
+ # This map is fine, even if it is a bit repetitive.
18
+ MAP = {
19
+ lab: {
20
+ lab: NOOP,
21
+ lch: LabToLch.to_proc,
22
+ rgb: [LabToXyz, XyzToRgb].map(&:to_proc).reduce(:>>),
23
+ xyz: LabToXyz.to_proc
24
+ },
25
+ lch: {
26
+ lab: LchToLab.to_proc,
27
+ lch: NOOP,
28
+ rgb: [LchToLab, LabToXyz, XyzToRgb].map(&:to_proc).reduce(:>>),
29
+ xyz: [LchToLab, LabToXyz].map(&:to_proc).reduce(:>>)
30
+ },
31
+ rgb: {
32
+ lab: [RgbToXyz, XyzToLab].map(&:to_proc).reduce(:>>),
33
+ lch: [RgbToXyz, XyzToLab, LabToLch].map(&:to_proc).reduce(:>>),
34
+ rgb: NOOP,
35
+ xyz: RgbToXyz.to_proc
36
+ },
37
+ xyz: {
38
+ lab: XyzToLab.to_proc,
39
+ lch: [XyzToLab, LabToLch].map(&:to_proc).reduce(:>>),
40
+ rgb: XyzToRgb.to_proc,
41
+ xyz: NOOP
42
+ }
43
+ }
44
+
45
+ class << self
46
+ def call(from, to)
47
+ MAP[from][to]
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -3,5 +3,5 @@
3
3
  require_relative '../color_calculator'
4
4
 
5
5
  module ColorCalculator
6
- VERSION = '1.2.0'
6
+ VERSION = '2.0.0'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: color_calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Seither
@@ -29,6 +29,7 @@ files:
29
29
  - lib/color_calculator/clump/rgb.rb
30
30
  - lib/color_calculator/clump/xyz.rb
31
31
  - lib/color_calculator/conversion.rb
32
+ - lib/color_calculator/conversion/build.rb
32
33
  - lib/color_calculator/conversion/lab_to_lch.rb
33
34
  - lib/color_calculator/conversion/lab_to_xyz.rb
34
35
  - lib/color_calculator/conversion/lch_to_lab.rb