color_calculator 1.2.0 → 2.0.0
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.
- checksums.yaml +4 -4
- data/lib/color_calculator/conversion.rb +2 -37
- data/lib/color_calculator/conversion/build.rb +52 -0
- data/lib/color_calculator/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2f9eedde9d186b943d2d263bcb7b9cdca955aa1
|
4
|
+
data.tar.gz: 83aa5302132baffb9c67de6cce7c5d176e2a7a36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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:
|
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
|