color_swatch_collection 0.1.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 +7 -0
- data/README.md +98 -0
- data/Rakefile +8 -0
- data/lib/color_swatch_collection/basic.rb +31 -0
- data/lib/color_swatch_collection/html.rb +157 -0
- data/lib/color_swatch_collection/ntc.rb +1576 -0
- data/lib/color_swatch_collection/pantone.rb +130 -0
- data/lib/color_swatch_collection/roygbiv.rb +17 -0
- data/lib/color_swatch_collection/version.rb +5 -0
- data/lib/color_swatch_collection/x11.rb +157 -0
- data/lib/color_swatch_collection.rb +86 -0
- metadata +69 -0
@@ -0,0 +1,130 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ColorSwatchCollection
|
4
|
+
class Pantone
|
5
|
+
def self.colours
|
6
|
+
[
|
7
|
+
{ name: 'mahogany', hex: '#CD4A4A' },
|
8
|
+
{ name: 'fuzzy wuzzy brown', hex: '#CC6666' },
|
9
|
+
{ name: 'chestnut', hex: '#BC5D58' },
|
10
|
+
{ name: 'red orange', hex: '#FF5349' },
|
11
|
+
{ name: 'sunset orange', hex: '#FD5E53' },
|
12
|
+
{ name: 'bittersweet', hex: '#FD7C6E' },
|
13
|
+
{ name: 'melon', hex: '#FDBCB4' },
|
14
|
+
{ name: 'outrageous orange', hex: '#FF6E4A' },
|
15
|
+
{ name: 'vivid tangerine', hex: '#FFA089' },
|
16
|
+
{ name: 'burnt sienna', hex: '#EA7E5D' },
|
17
|
+
{ name: 'brown', hex: '#B4674D' },
|
18
|
+
{ name: 'sepia', hex: '#A5694F' },
|
19
|
+
{ name: 'orange', hex: '#FF7538' },
|
20
|
+
{ name: 'burnt orange', hex: '#FF7F49' },
|
21
|
+
{ name: 'copper', hex: '#DD9475' },
|
22
|
+
{ name: 'mango tango', hex: '#FF8243' },
|
23
|
+
{ name: 'atomic tangerine', hex: '#FFA474' },
|
24
|
+
{ name: 'beaver', hex: '#9F8170' },
|
25
|
+
{ name: 'antique brass', hex: '#CD9575' },
|
26
|
+
{ name: 'desert sand', hex: '#EFCDB8' },
|
27
|
+
{ name: 'raw sienna', hex: '#D68A59' },
|
28
|
+
{ name: 'tumbleweed', hex: '#DEAA88' },
|
29
|
+
{ name: 'tan', hex: '#FAA76C' },
|
30
|
+
{ name: 'peach', hex: '#FFCFAB' },
|
31
|
+
{ name: 'macaroni and cheese', hex: '#FFBD88' },
|
32
|
+
{ name: 'apricot', hex: '#FDD9B5' },
|
33
|
+
{ name: 'neon carrot', hex: '#FFA343' },
|
34
|
+
{ name: 'almond', hex: '#EFDBC5' },
|
35
|
+
{ name: 'yellow orange', hex: '#FFB653' },
|
36
|
+
{ name: 'gold', hex: '#E7C697' },
|
37
|
+
{ name: 'shadow', hex: '#8A795D' },
|
38
|
+
{ name: 'banana mania', hex: '#FAE7B5' },
|
39
|
+
{ name: 'sunglow', hex: '#FFCF48' },
|
40
|
+
{ name: 'goldenrod', hex: '#FCD975' },
|
41
|
+
{ name: 'dandelion', hex: '#FDDB6D' },
|
42
|
+
{ name: 'yellow', hex: '#FCE883' },
|
43
|
+
{ name: 'green yellow', hex: '#F0E891' },
|
44
|
+
{ name: 'spring green', hex: '#ECEABE' },
|
45
|
+
{ name: 'olive green', hex: '#BAB86C' },
|
46
|
+
{ name: 'laser lemon', hex: '#FDFC74' },
|
47
|
+
{ name: 'unmellow yellow', hex: '#FDFC74' },
|
48
|
+
{ name: 'canary', hex: '#FFFF99' },
|
49
|
+
{ name: 'yellow green', hex: '#C5E384' },
|
50
|
+
{ name: 'inch worm', hex: '#B2EC5D' },
|
51
|
+
{ name: 'asparagus', hex: '#87A96B' },
|
52
|
+
{ name: 'granny smith apple', hex: '#A8E4A0' },
|
53
|
+
{ name: 'electric lime', hex: '#1DF914' },
|
54
|
+
{ name: 'screamin green', hex: '#76FF7A' },
|
55
|
+
{ name: 'fern', hex: '#71BC78' },
|
56
|
+
{ name: 'forest green', hex: '#6DAE81' },
|
57
|
+
{ name: 'sea green', hex: '#9FE2BF' },
|
58
|
+
{ name: 'green', hex: '#1CAC78' },
|
59
|
+
{ name: 'mountain meadow', hex: '#30BA8F' },
|
60
|
+
{ name: 'shamrock', hex: '#45CEA2' },
|
61
|
+
{ name: 'jungle green', hex: '#3BB08F' },
|
62
|
+
{ name: 'caribbean green', hex: '#1CD3A2' },
|
63
|
+
{ name: 'tropical rain forest', hex: '#17806D' },
|
64
|
+
{ name: 'pine green', hex: '#158078' },
|
65
|
+
{ name: 'robin egg blue', hex: '#1FCECB' },
|
66
|
+
{ name: 'aquamarine', hex: '#78DBE2' },
|
67
|
+
{ name: 'turquoise blue', hex: '#77DDE7' },
|
68
|
+
{ name: 'sky blue', hex: '#80DAEB' },
|
69
|
+
{ name: 'outer space', hex: '#414A4C' },
|
70
|
+
{ name: 'blue green', hex: '#199EBD' },
|
71
|
+
{ name: 'pacific blue', hex: '#1CA9C9' },
|
72
|
+
{ name: 'cerulean', hex: '#1DACD6' },
|
73
|
+
{ name: 'cornflower', hex: '#9ACEEB' },
|
74
|
+
{ name: 'midnight blue', hex: '#1A4876' },
|
75
|
+
{ name: 'navy blue', hex: '#1974D2' },
|
76
|
+
{ name: 'denim', hex: '#2B6CC4' },
|
77
|
+
{ name: 'blue', hex: '#1F75FE' },
|
78
|
+
{ name: 'periwinkle', hex: '#C5D0E6' },
|
79
|
+
{ name: 'cadet blue', hex: '#B0B7C6' },
|
80
|
+
{ name: 'indigo', hex: '#5D76CB' },
|
81
|
+
{ name: 'wild blue yonder', hex: '#A2ADD0' },
|
82
|
+
{ name: 'manatee', hex: '#979AAA' },
|
83
|
+
{ name: 'blue bell', hex: '#ADADD6' },
|
84
|
+
{ name: 'blue violet', hex: '#7366BD' },
|
85
|
+
{ name: 'purple heart', hex: '#7442C8' },
|
86
|
+
{ name: 'royal purple', hex: '#7851A9' },
|
87
|
+
{ name: 'purple mountains’ majesty', hex: '#9D81BA' },
|
88
|
+
{ name: 'violet (purple)', hex: '#926EAE' },
|
89
|
+
{ name: 'wisteria', hex: '#CDA4DE' },
|
90
|
+
{ name: 'vivid violet', hex: '#8F509D' },
|
91
|
+
{ name: 'fuchsia', hex: '#C364C5' },
|
92
|
+
{ name: 'shocking pink', hex: '#FB7EFD' },
|
93
|
+
{ name: 'pink flamingo', hex: '#FC74FD' },
|
94
|
+
{ name: 'plum', hex: '#8E4585' },
|
95
|
+
{ name: 'hot magenta', hex: '#FF1DCE' },
|
96
|
+
{ name: 'purple pizzazz', hex: '#FF1DCE' },
|
97
|
+
{ name: 'razzle dazzle rose', hex: '#FF48D0' },
|
98
|
+
{ name: 'orchid', hex: '#E6A8D7' },
|
99
|
+
{ name: 'red violet', hex: '#C0448F' },
|
100
|
+
{ name: 'eggplant', hex: '#6E5160' },
|
101
|
+
{ name: 'cerise', hex: '#DD4492' },
|
102
|
+
{ name: 'wild strawberry', hex: '#FF43A4' },
|
103
|
+
{ name: 'magenta', hex: '#F664AF' },
|
104
|
+
{ name: 'lavender', hex: '#FCB4D5' },
|
105
|
+
{ name: 'cotton candy', hex: '#FFBCD9' },
|
106
|
+
{ name: 'violet red', hex: '#F75394' },
|
107
|
+
{ name: 'carnation pink', hex: '#FFAACC' },
|
108
|
+
{ name: 'razzmatazz', hex: '#E3256B' },
|
109
|
+
{ name: 'piggy pink', hex: '#FDD7E4' },
|
110
|
+
{ name: 'jazzberry jam', hex: '#CA3767' },
|
111
|
+
{ name: 'blush', hex: '#DE5D83' },
|
112
|
+
{ name: 'tickle me pink', hex: '#FC89AC' },
|
113
|
+
{ name: 'pink sherbet', hex: '#F780A1' },
|
114
|
+
{ name: 'maroon', hex: '#C8385A' },
|
115
|
+
{ name: 'red', hex: '#EE204D' },
|
116
|
+
{ name: 'radical red', hex: '#FF496C' },
|
117
|
+
{ name: 'mauvelous', hex: '#EF98AA' },
|
118
|
+
{ name: 'wild watermelon', hex: '#FC6C85' },
|
119
|
+
{ name: 'scarlet', hex: '#FC2847' },
|
120
|
+
{ name: 'salmon', hex: '#FF9BAA' },
|
121
|
+
{ name: 'brick red', hex: '#CB4154' },
|
122
|
+
{ name: 'white', hex: '#EDEDED' },
|
123
|
+
{ name: 'timberwolf', hex: '#DBD7D2' },
|
124
|
+
{ name: 'silver', hex: '#CDC5C2' },
|
125
|
+
{ name: 'gray', hex: '#95918C' },
|
126
|
+
{ name: 'black', hex: '#232323' }
|
127
|
+
]
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ColorSwatchCollection
|
4
|
+
class Roygbiv
|
5
|
+
def self.colours
|
6
|
+
[
|
7
|
+
{ name: 'red', hex: '#FF0000' },
|
8
|
+
{ name: 'orange', hex: '#FFA500' },
|
9
|
+
{ name: 'yellow', hex: '#FFFF00' },
|
10
|
+
{ name: 'green', hex: '#008000' },
|
11
|
+
{ name: 'blue', hex: '#0000FF' },
|
12
|
+
{ name: 'indigo', hex: '#4B0082' },
|
13
|
+
{ name: 'violet', hex: '#EE82EE' }
|
14
|
+
]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ColorSwatchCollection
|
4
|
+
class X11
|
5
|
+
def self.colours
|
6
|
+
[
|
7
|
+
{ name: 'indigo', hex: '#4B0082' },
|
8
|
+
{ name: 'gold', hex: '#FFD700' },
|
9
|
+
{ name: 'hotpink', hex: '#FF69B4' },
|
10
|
+
{ name: 'firebrick', hex: '#B22222' },
|
11
|
+
{ name: 'indianred', hex: '#CD5C5C' },
|
12
|
+
{ name: 'yellow', hex: '#FFFF00' },
|
13
|
+
{ name: 'mistyrose', hex: '#FFE4E1' },
|
14
|
+
{ name: 'darkolivegreen', hex: '#556B2F' },
|
15
|
+
{ name: 'olive', hex: '#808000' },
|
16
|
+
{ name: 'darkseagreen', hex: '#8FBC8F' },
|
17
|
+
{ name: 'pink', hex: '#FFC0CB' },
|
18
|
+
{ name: 'tomato', hex: '#FF6347' },
|
19
|
+
{ name: 'lightcoral', hex: '#F08080' },
|
20
|
+
{ name: 'orangered', hex: '#FF4500' },
|
21
|
+
{ name: 'navajowhite', hex: '#FFDEAD' },
|
22
|
+
{ name: 'lime', hex: '#00FF00' },
|
23
|
+
{ name: 'palegreen', hex: '#98FB98' },
|
24
|
+
{ name: 'darkslategrey', hex: '#2F4F4F' },
|
25
|
+
{ name: 'greenyellow', hex: '#ADFF2F' },
|
26
|
+
{ name: 'burlywood', hex: '#DEB887' },
|
27
|
+
{ name: 'seashell', hex: '#FFF5EE' },
|
28
|
+
{ name: 'mediumspringgreen', hex: '#00FA9A' },
|
29
|
+
{ name: 'fuchsia', hex: '#FF00FF' },
|
30
|
+
{ name: 'papayawhip', hex: '#FFEFD5' },
|
31
|
+
{ name: 'blanchedalmond', hex: '#FFEBCD' },
|
32
|
+
{ name: 'chartreuse', hex: '#7FFF00' },
|
33
|
+
{ name: 'dimgray', hex: '#696969' },
|
34
|
+
{ name: 'black', hex: '#000000' },
|
35
|
+
{ name: 'peachpuff', hex: '#FFDAB9' },
|
36
|
+
{ name: 'springgreen', hex: '#00FF7F' },
|
37
|
+
{ name: 'aquamarine', hex: '#7FFFD4' },
|
38
|
+
{ name: 'white', hex: '#FFFFFF' },
|
39
|
+
{ name: 'orange', hex: '#FFA500' },
|
40
|
+
{ name: 'lightsalmon', hex: '#FFA07A' },
|
41
|
+
{ name: 'darkslategray', hex: '#2F4F4F' },
|
42
|
+
{ name: 'brown', hex: '#A52A2A' },
|
43
|
+
{ name: 'ivory', hex: '#FFFFF0' },
|
44
|
+
{ name: 'dodgerblue', hex: '#1E90FF' },
|
45
|
+
{ name: 'peru', hex: '#CD853F' },
|
46
|
+
{ name: 'lawngreen', hex: '#7CFC00' },
|
47
|
+
{ name: 'chocolate', hex: '#D2691E' },
|
48
|
+
{ name: 'crimson', hex: '#DC143C' },
|
49
|
+
{ name: 'forestgreen', hex: '#228B22' },
|
50
|
+
{ name: 'darkgrey', hex: '#A9A9A9' },
|
51
|
+
{ name: 'lightseagreen', hex: '#20B2AA' },
|
52
|
+
{ name: 'cyan', hex: '#00FFFF' },
|
53
|
+
{ name: 'mintcream', hex: '#F5FFFA' },
|
54
|
+
{ name: 'silver', hex: '#C0C0C0' },
|
55
|
+
{ name: 'antiquewhite', hex: '#FAEBD7' },
|
56
|
+
{ name: 'mediumorchid', hex: '#BA55D3' },
|
57
|
+
{ name: 'skyblue', hex: '#87CEEB' },
|
58
|
+
{ name: 'gray', hex: '#808080' },
|
59
|
+
{ name: 'darkturquoise', hex: '#00CED1' },
|
60
|
+
{ name: 'goldenrod', hex: '#DAA520' },
|
61
|
+
{ name: 'darkgreen', hex: '#006400' },
|
62
|
+
{ name: 'floralwhite', hex: '#FFFAF0' },
|
63
|
+
{ name: 'darkviolet', hex: '#9400D3' },
|
64
|
+
{ name: 'darkgray', hex: '#A9A9A9' },
|
65
|
+
{ name: 'moccasin', hex: '#FFE4B5' },
|
66
|
+
{ name: 'saddlebrown', hex: '#8B4513' },
|
67
|
+
{ name: 'grey', hex: '#808080' },
|
68
|
+
{ name: 'darkslateblue', hex: '#483D8B' },
|
69
|
+
{ name: 'lightskyblue', hex: '#87CEFA' },
|
70
|
+
{ name: 'lightpink', hex: '#FFB6C1' },
|
71
|
+
{ name: 'mediumvioletred', hex: '#C71585' },
|
72
|
+
{ name: 'slategrey', hex: '#708090' },
|
73
|
+
{ name: 'red', hex: '#FF0000' },
|
74
|
+
{ name: 'deeppink', hex: '#FF1493' },
|
75
|
+
{ name: 'limegreen', hex: '#32CD32' },
|
76
|
+
{ name: 'darkmagenta', hex: '#8B008B' },
|
77
|
+
{ name: 'palegoldenrod', hex: '#EEE8AA' },
|
78
|
+
{ name: 'plum', hex: '#DDA0DD' },
|
79
|
+
{ name: 'turquoise', hex: '#40E0D0' },
|
80
|
+
{ name: 'lightgrey', hex: '#D3D3D3' },
|
81
|
+
{ name: 'lightgoldenrodyellow', hex: '#FAFAD2' },
|
82
|
+
{ name: 'darkgoldenrod', hex: '#B8860B' },
|
83
|
+
{ name: 'lavender', hex: '#E6E6FA' },
|
84
|
+
{ name: 'maroon', hex: '#800000' },
|
85
|
+
{ name: 'yellowgreen', hex: '#9ACD32' },
|
86
|
+
{ name: 'sandybrown', hex: '#F4A460' },
|
87
|
+
{ name: 'thistle', hex: '#D8BFD8' },
|
88
|
+
{ name: 'violet', hex: '#EE82EE' },
|
89
|
+
{ name: 'navy', hex: '#000080' },
|
90
|
+
{ name: 'magenta', hex: '#FF00FF' },
|
91
|
+
{ name: 'dimgrey', hex: '#696969' },
|
92
|
+
{ name: 'tan', hex: '#D2B48C' },
|
93
|
+
{ name: 'rosybrown', hex: '#BC8F8F' },
|
94
|
+
{ name: 'olivedrab', hex: '#6B8E23' },
|
95
|
+
{ name: 'blue', hex: '#0000FF' },
|
96
|
+
{ name: 'lightblue', hex: '#ADD8E6' },
|
97
|
+
{ name: 'ghostwhite', hex: '#F8F8FF' },
|
98
|
+
{ name: 'honeydew', hex: '#F0FFF0' },
|
99
|
+
{ name: 'cornflowerblue', hex: '#6495ED' },
|
100
|
+
{ name: 'slateblue', hex: '#6A5ACD' },
|
101
|
+
{ name: 'linen', hex: '#FAF0E6' },
|
102
|
+
{ name: 'darkblue', hex: '#00008B' },
|
103
|
+
{ name: 'powderblue', hex: '#B0E0E6' },
|
104
|
+
{ name: 'seagreen', hex: '#2E8B57' },
|
105
|
+
{ name: 'darkkhaki', hex: '#BDB76B' },
|
106
|
+
{ name: 'snow', hex: '#FFFAFA' },
|
107
|
+
{ name: 'sienna', hex: '#A0522D' },
|
108
|
+
{ name: 'mediumblue', hex: '#0000CD' },
|
109
|
+
{ name: 'royalblue', hex: '#4169E1' },
|
110
|
+
{ name: 'lightcyan', hex: '#E0FFFF' },
|
111
|
+
{ name: 'green', hex: '#008000' },
|
112
|
+
{ name: 'mediumpurple', hex: '#9370DB' },
|
113
|
+
{ name: 'midnightblue', hex: '#191970' },
|
114
|
+
{ name: 'cornsilk', hex: '#FFF8DC' },
|
115
|
+
{ name: 'paleturquoise', hex: '#AFEEEE' },
|
116
|
+
{ name: 'bisque', hex: '#FFE4C4' },
|
117
|
+
{ name: 'slategray', hex: '#708090' },
|
118
|
+
{ name: 'darkcyan', hex: '#008B8B' },
|
119
|
+
{ name: 'khaki', hex: '#F0E68C' },
|
120
|
+
{ name: 'wheat', hex: '#F5DEB3' },
|
121
|
+
{ name: 'teal', hex: '#008080' },
|
122
|
+
{ name: 'darkorchid', hex: '#9932CC' },
|
123
|
+
{ name: 'deepskyblue', hex: '#00BFFF' },
|
124
|
+
{ name: 'salmon', hex: '#FA8072' },
|
125
|
+
{ name: 'darkred', hex: '#8B0000' },
|
126
|
+
{ name: 'steelblue', hex: '#4682B4' },
|
127
|
+
{ name: 'palevioletred', hex: '#DB7093' },
|
128
|
+
{ name: 'lightslategray', hex: '#778899' },
|
129
|
+
{ name: 'aliceblue', hex: '#F0F8FF' },
|
130
|
+
{ name: 'lightslategrey', hex: '#778899' },
|
131
|
+
{ name: 'lightgreen', hex: '#90EE90' },
|
132
|
+
{ name: 'orchid', hex: '#DA70D6' },
|
133
|
+
{ name: 'gainsboro', hex: '#DCDCDC' },
|
134
|
+
{ name: 'mediumseagreen', hex: '#3CB371' },
|
135
|
+
{ name: 'lightgray', hex: '#D3D3D3' },
|
136
|
+
{ name: 'mediumturquoise', hex: '#48D1CC' },
|
137
|
+
{ name: 'lemonchiffon', hex: '#FFFACD' },
|
138
|
+
{ name: 'cadetblue', hex: '#5F9EA0' },
|
139
|
+
{ name: 'lightyellow', hex: '#FFFFE0' },
|
140
|
+
{ name: 'lavenderblush', hex: '#FFF0F5' },
|
141
|
+
{ name: 'coral', hex: '#FF7F50' },
|
142
|
+
{ name: 'purple', hex: '#800080' },
|
143
|
+
{ name: 'aqua', hex: '#00FFFF' },
|
144
|
+
{ name: 'whitesmoke', hex: '#F5F5F5' },
|
145
|
+
{ name: 'mediumslateblue', hex: '#7B68EE' },
|
146
|
+
{ name: 'darkorange', hex: '#FF8C00' },
|
147
|
+
{ name: 'mediumaquamarine', hex: '#66CDAA' },
|
148
|
+
{ name: 'darksalmon', hex: '#E9967A' },
|
149
|
+
{ name: 'beige', hex: '#F5F5DC' },
|
150
|
+
{ name: 'blueviolet', hex: '#8A2BE2' },
|
151
|
+
{ name: 'azure', hex: '#F0FFFF' },
|
152
|
+
{ name: 'lightsteelblue', hex: '#B0C4DE' },
|
153
|
+
{ name: 'oldlace', hex: '#FDF5E6' }
|
154
|
+
]
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/object/blank'
|
4
|
+
|
5
|
+
require_relative 'color_swatch_collection/version'
|
6
|
+
|
7
|
+
require_relative 'color_swatch_collection/basic'
|
8
|
+
require_relative 'color_swatch_collection/html'
|
9
|
+
require_relative 'color_swatch_collection/ntc'
|
10
|
+
require_relative 'color_swatch_collection/pantone'
|
11
|
+
require_relative 'color_swatch_collection/roygbiv'
|
12
|
+
require_relative 'color_swatch_collection/x11'
|
13
|
+
|
14
|
+
module ColorSwatchCollection
|
15
|
+
class Error < StandardError; end
|
16
|
+
|
17
|
+
def self.list_collections
|
18
|
+
['basic', 'html', 'ntc', 'pantone', 'roygbiv', 'x11']
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.get_from_hex(colour_hex, pick: [], omit: [])
|
22
|
+
found_colour = nil
|
23
|
+
|
24
|
+
self.list_collections.each do |list_name|
|
25
|
+
next unless (pick.empty? || pick.include?(list_name)) && !omit.include?(list_name)
|
26
|
+
|
27
|
+
found_colour = self.get_item_from_collection(colour_hex, 'hex', list_name)
|
28
|
+
|
29
|
+
if found_colour.present?
|
30
|
+
found_colour[:collection] = list_name
|
31
|
+
break
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
found_colour || {}
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.get_from_name(colour_name, pick: [], omit: [])
|
39
|
+
found_colour = nil
|
40
|
+
|
41
|
+
self.list_collections.each do |list_name|
|
42
|
+
next unless (pick.empty? || pick.include?(list_name)) && !omit.include?(list_name)
|
43
|
+
|
44
|
+
found_colour = self.get_item_from_collection(colour_name, 'name', list_name)
|
45
|
+
|
46
|
+
if found_colour.present?
|
47
|
+
found_colour[:collection] = list_name
|
48
|
+
break
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
found_colour || {}
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.get_colours(pick: [], omit: [])
|
56
|
+
self.list_collections.collect do |list_name|
|
57
|
+
next unless (pick.empty? || pick.include?(list_name)) && !omit.include?(list_name)
|
58
|
+
|
59
|
+
Object.const_get("ColorSwatchCollection::#{list_name.capitalize}").colours.collect do |swatch_hash|
|
60
|
+
swatch_hash[:collection] = list_name
|
61
|
+
swatch_hash
|
62
|
+
end
|
63
|
+
end.compact.flatten
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def self.get_item_from_collection(colour_input, input_type, list_name)
|
69
|
+
return nil if colour_input.blank?
|
70
|
+
|
71
|
+
swatch_hash = nil
|
72
|
+
list_collection_object = Object.const_get("ColorSwatchCollection::#{list_name.capitalize}")
|
73
|
+
|
74
|
+
if input_type == 'hex'
|
75
|
+
swatch_hash = list_collection_object.colours.find { |swatch| swatch[:hex] == colour_input.upcase }
|
76
|
+
elsif input_type == 'name'
|
77
|
+
if ['ntc', 'pantone'].include?(list_name)
|
78
|
+
swatch_hash = list_collection_object.colours.find { |swatch| swatch[:name] == colour_input.downcase.strip }
|
79
|
+
else
|
80
|
+
swatch_hash = list_collection_object.colours.find { |swatch| swatch[:name] == colour_input.downcase.gsub(' ', '') }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
swatch_hash || {}
|
85
|
+
end
|
86
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: color_swatch_collection
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Louis Davis
|
8
|
+
bindir: bin
|
9
|
+
cert_chain: []
|
10
|
+
date: 2025-08-19 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
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
|
+
description: A collection of colour swatches from various palettes and their corresponding
|
27
|
+
hex value.
|
28
|
+
email:
|
29
|
+
- LouisWilliamDavis@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- README.md
|
35
|
+
- Rakefile
|
36
|
+
- lib/color_swatch_collection.rb
|
37
|
+
- lib/color_swatch_collection/basic.rb
|
38
|
+
- lib/color_swatch_collection/html.rb
|
39
|
+
- lib/color_swatch_collection/ntc.rb
|
40
|
+
- lib/color_swatch_collection/pantone.rb
|
41
|
+
- lib/color_swatch_collection/roygbiv.rb
|
42
|
+
- lib/color_swatch_collection/version.rb
|
43
|
+
- lib/color_swatch_collection/x11.rb
|
44
|
+
homepage: https://github.com/louiswdavis/color_swatch_collection
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata:
|
48
|
+
homepage_uri: https://github.com/louiswdavis/color_swatch_collection
|
49
|
+
source_code_uri: https://github.com/louiswdavis/color_swatch_collection
|
50
|
+
changelog_uri: https://github.com/louiswdavis/color_swatch_collection/blob/master/CHANGELOG.md
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: 1.9.3
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubygems_version: 3.6.3
|
66
|
+
specification_version: 4
|
67
|
+
summary: A collection of colour swatches from various palettes and their corresponding
|
68
|
+
hex value.
|
69
|
+
test_files: []
|