redgreenblue 0.9.0 → 0.14.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.
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redgreenblue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - lllist.eu
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-02 00:00:00.000000000 Z
11
+ date: 2021-05-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
14
- email:
13
+ description:
14
+ email:
15
15
  executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
@@ -21,30 +21,45 @@ files:
21
21
  - lib/redgreenblue/48bit.rb
22
22
  - lib/redgreenblue/base.rb
23
23
  - lib/redgreenblue/bgr24bit.rb
24
- - lib/redgreenblue/cie.rb
24
+ - lib/redgreenblue/cie_1931.rb
25
+ - lib/redgreenblue/cie_1976.rb
25
26
  - lib/redgreenblue/gamma.rb
26
27
  - lib/redgreenblue/gif.rb
28
+ - lib/redgreenblue/gpl.rb
27
29
  - lib/redgreenblue/hex.rb
28
- - lib/redgreenblue/hsl_hsv.rb
30
+ - lib/redgreenblue/hsb.rb
31
+ - lib/redgreenblue/hsl.rb
32
+ - lib/redgreenblue/hsv.rb
33
+ - lib/redgreenblue/hsx_shared.rb
34
+ - lib/redgreenblue/hwb.rb
29
35
  - lib/redgreenblue/inspect.rb
30
36
  - lib/redgreenblue/int.rb
31
37
  - lib/redgreenblue/lazy.rb
38
+ - lib/redgreenblue/mac.rb
39
+ - lib/redgreenblue/match.rb
40
+ - lib/redgreenblue/math.rb
32
41
  - lib/redgreenblue/misc.rb
33
42
  - lib/redgreenblue/mix.rb
43
+ - lib/redgreenblue/name.rb
34
44
  - lib/redgreenblue/opt/philipshue.rb
35
45
  - lib/redgreenblue/os.rb
36
46
  - lib/redgreenblue/os/mac.rb
47
+ - lib/redgreenblue/ostwald.rb
48
+ - lib/redgreenblue/palettes/css.gpl
37
49
  - lib/redgreenblue/random.rb
38
50
  - lib/redgreenblue/rgb565.rb
39
51
  - lib/redgreenblue/terminal.rb
40
52
  - lib/redgreenblue/version.rb
53
+ - lib/redgreenblue/view.rb
41
54
  - lib/redgreenblue/web.rb
42
55
  homepage: https://github.com/lllisteu/redgreenblue
43
56
  licenses:
44
57
  - MIT
45
58
  metadata:
59
+ homepage_uri: https://github.com/lllisteu/redgreenblue
46
60
  changelog_uri: https://github.com/lllisteu/redgreenblue/blob/master/History.md
47
- post_install_message:
61
+ documentation_uri: https://www.rubydoc.info/gems/redgreenblue/RGB
62
+ post_install_message:
48
63
  rdoc_options: []
49
64
  require_paths:
50
65
  - lib
@@ -59,8 +74,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
74
  - !ruby/object:Gem::Version
60
75
  version: '0'
61
76
  requirements: []
62
- rubygems_version: 3.0.6
63
- signing_key:
77
+ rubygems_version: 3.1.4
78
+ signing_key:
64
79
  specification_version: 4
65
80
  summary: A simple Ruby library for handling RGB colors.
66
81
  test_files: []
@@ -1,59 +0,0 @@
1
- class RGB
2
-
3
- # Returns color as HSL:
4
- # hue (0..360), saturation (0..1), lightness (0..1).
5
- # When saturation is 0, hue is nil.
6
- def hsl
7
- hsl_hsv_c[0]
8
- end
9
-
10
- # Returns color as HSV:
11
- # hue (0..360), saturation (0..1), value (0..1).
12
- # When saturation is 0, hue is nil.
13
- #
14
- # #hsb is an alias for #hsv.
15
- def hsv
16
- hsl_hsv_c[1]
17
- end
18
-
19
- alias hsb hsv
20
-
21
- private
22
-
23
- # Compute HSL, HSV, and chroma.
24
- # With help from:
25
- # - https://en.wikipedia.org/wiki/HSL_and_HSV
26
- def hsl_hsv_c
27
- sorted_hash = to_h
28
- min, max = sorted_hash.values.values_at(2,0)
29
-
30
- chroma = max - min
31
-
32
- hue =
33
- if chroma == 0
34
- nil
35
- else
36
- case sorted_hash.keys.first
37
- when :red
38
- 60 * ( ( ( green - blue ) / chroma ).modulo 6 )
39
- when :green
40
- 60 * ( ( blue - red ) / chroma + 2 )
41
- when :blue
42
- 60 * ( ( red - green ) / chroma + 4 )
43
- end
44
- end
45
-
46
- lightness = ( min + max ) / 2.0
47
-
48
- saturation_hsl =
49
- chroma == 0 ? 0.0 : ( chroma / ( 1 - (2 * lightness - 1).abs ) ).round(9)
50
-
51
- value = max
52
-
53
- saturation_hsv =
54
- value == 0 ? 0.0 : chroma / value
55
-
56
- [ [hue, saturation_hsl, lightness], [hue, saturation_hsv, value], chroma ]
57
- end
58
-
59
- end