human_colour 0.3.0 → 0.4.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/README.md +4 -2
- data/lib/human_colour/locales.rb +6 -0
- data/lib/human_colour/version.rb +1 -1
- data/lib/human_colour.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 35d42d47bf0db3146c6f60d76ac09cd2e077b6dbf90d32802d59b9af4b17eac5
|
|
4
|
+
data.tar.gz: 63a243961773667626d4da42d5a1c722235ae9be7ae27ac8e982af48308cd58e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8284993d26bef8beffa6bfb3ca15d12de68913b74bf39adb3c9b5ac011cf5e348a35e853cc2a61dfacb4869f76ec9745daf71600c1fc78d5478ecff2533a5255
|
|
7
|
+
data.tar.gz: d786c21653b76d156415e0e20106970995ebc2123b6a0452246042bc3630aebf7fc44670c99ec3a7b2ab8a3a5f173329ebba7da58615837adff4fe3feb2250ed
|
data/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# HumanColour
|
|
2
2
|
|
|
3
|
+
[](https://badge.fury.io/rb/human_colour)
|
|
4
|
+
|
|
3
5
|
Simple gem for taking an RGB colour string, and converting it into a human-friendly name.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
@@ -22,11 +24,11 @@ gem install human_colour
|
|
|
22
24
|
require "human_colour"
|
|
23
25
|
|
|
24
26
|
HumanColour.parse("rgb(128,64,0)")
|
|
25
|
-
#=> "
|
|
27
|
+
#=> "brown"
|
|
26
28
|
|
|
27
29
|
# Return a colour based on the provided locale (:de, :en, :es, :fr, :it, :pt)
|
|
28
30
|
HumanColour.parse("rgb(128,64,0)", locale: :es)
|
|
29
|
-
#=> "
|
|
31
|
+
#=> "marrón"
|
|
30
32
|
|
|
31
33
|
HumanColour.parse("rgb(255, 128, 255", locale: :de)
|
|
32
34
|
#=> "hell lila"
|
data/lib/human_colour/locales.rb
CHANGED
|
@@ -19,6 +19,7 @@ module HumanColour
|
|
|
19
19
|
pink: "pink",
|
|
20
20
|
grey: "grey",
|
|
21
21
|
black: "black",
|
|
22
|
+
near_black: "near black",
|
|
22
23
|
white: "white"
|
|
23
24
|
}
|
|
24
25
|
},
|
|
@@ -39,6 +40,7 @@ module HumanColour
|
|
|
39
40
|
pink: "rosa",
|
|
40
41
|
grey: "gris",
|
|
41
42
|
black: "negro",
|
|
43
|
+
near_black: "casi negro",
|
|
42
44
|
white: "blanco"
|
|
43
45
|
}
|
|
44
46
|
},
|
|
@@ -59,6 +61,7 @@ module HumanColour
|
|
|
59
61
|
pink: "rosa",
|
|
60
62
|
grey: "grigio",
|
|
61
63
|
black: "nero",
|
|
64
|
+
near_black: "quasi nero",
|
|
62
65
|
white: "bianco"
|
|
63
66
|
}
|
|
64
67
|
},
|
|
@@ -79,6 +82,7 @@ module HumanColour
|
|
|
79
82
|
pink: "rose",
|
|
80
83
|
grey: "gris",
|
|
81
84
|
black: "noir",
|
|
85
|
+
near_black: "presque noir",
|
|
82
86
|
white: "blanc"
|
|
83
87
|
}
|
|
84
88
|
},
|
|
@@ -99,6 +103,7 @@ module HumanColour
|
|
|
99
103
|
pink: "rosa",
|
|
100
104
|
grey: "grau",
|
|
101
105
|
black: "schwarz",
|
|
106
|
+
near_black: "fast schwarz",
|
|
102
107
|
white: "weiß"
|
|
103
108
|
}
|
|
104
109
|
},
|
|
@@ -119,6 +124,7 @@ module HumanColour
|
|
|
119
124
|
pink: "rosa",
|
|
120
125
|
grey: "cinza",
|
|
121
126
|
black: "preto",
|
|
127
|
+
near_black: "quase preto",
|
|
122
128
|
white: "branco"
|
|
123
129
|
}
|
|
124
130
|
}
|
data/lib/human_colour/version.rb
CHANGED
data/lib/human_colour.rb
CHANGED
|
@@ -18,6 +18,8 @@ module HumanColour
|
|
|
18
18
|
green = matches[2].to_i / 255.0
|
|
19
19
|
blue = matches[3].to_i / 255.0
|
|
20
20
|
|
|
21
|
+
return LOCALES[locale][:colour][:near_black] if [red, green, blue].all? { |v| v < 0.126 }
|
|
22
|
+
|
|
21
23
|
l = lightness(red: red, green: green, blue: blue)
|
|
22
24
|
d = delta(red: red, green: green, blue: blue)
|
|
23
25
|
s = saturation(delta: d, lightness: l)
|