pigment 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/colors.rb +754 -0
  2. data/lib/pigment.rb +264 -0
  3. metadata +50 -0
data/lib/colors.rb ADDED
@@ -0,0 +1,754 @@
1
+ module Pigment
2
+ class Color
3
+ self[:AirForceBlue, :Rackley] = '#5D8AA8'
4
+ self[:AliceBlue] = '#F0F8FF'
5
+ self[:AlizarinCrimson, :RoseMadder] = '#E32636'
6
+ self[:AlloyOrange] = '#C46210'
7
+ self[:Almond] = '#EFDECD'
8
+ self[:Aluminium, :Gray60] = '#999999'
9
+ self[:Amaranth] = '#E52B50'
10
+ self[:Amber, :FluorescentOrange] = '#FFBF00'
11
+ self[:AmberSAE_ECE] = '#FF7E00'
12
+ self[:AmericanRose] = '#FF033E'
13
+ self[:Amethyst] = '#9966CC'
14
+ self[:AndroidGreen] = '#A4C639'
15
+ self[:AntiFlashWhite, :Munsell] = '#F2F3F4'
16
+ self[:AntiqueBrass] = '#CD9575'
17
+ self[:AntiqueFuchsia] = '#915C83'
18
+ self[:AntiqueWhite, :Moccasin] = '#FAEBD7'
19
+ self[:AoEnglish, :GreenWeb, :OfficeGreen] = '#008000'
20
+ self[:AppleGreen] = '#8DB600'
21
+ self[:Apricot] = '#FBCEB1'
22
+ self[:Aqua, :Cyan, :ElectricCyan] = '#00FFFF'
23
+ self[:Aquamarine] = '#7FFFD4'
24
+ self[:ArmyGreen] = '#4B5320'
25
+ self[:Arsenic] = '#3B444B'
26
+ self[:ArylideYellow, :HansaYellow] = '#E9D66B'
27
+ self[:AshGrey] = '#B2BEB5'
28
+ self[:Asparagus] = '#87A96B'
29
+ self[:AtomicTangerine, :PinkOrange] = '#FF9966'
30
+ self[:Auburn, :Brown, :BrownWeb, :RedBrown] = '#A52A2A'
31
+ self[:Aureolin] = '#FDEE00'
32
+ self[:AuroMetalSaurus] = '#6E7F80'
33
+ self[:Azure] = '#007FFF'
34
+ self[:AzureMist] = '#F0FFFF'
35
+ self[:BabyBlue] = '#89CFF0'
36
+ self[:BabyBlueEyes] = '#A1CAF1'
37
+ self[:BabyPink, :TeaRoseRose] = '#F4C2C2'
38
+ self[:BallBlue] = '#21ABCD'
39
+ self[:BananaMania] = '#FAE7B5'
40
+ self[:BananaYellow] = '#FFE135'
41
+ self[:BarnRed] = '#7C0A02'
42
+ self[:BattleshipGrey] = '#848482'
43
+ self[:Bazaar] = '#98777B'
44
+ self[:BeauBlue, :PaleAqua] = '#BCD4E6'
45
+ self[:Beaver] = '#9F8170'
46
+ self[:Beige] = '#F5F5DC'
47
+ self[:Bisque] = '#FFE4C4'
48
+ self[:Bistre] = '#3D2B1F'
49
+ self[:Bittersweet] = '#FE6F5E'
50
+ self[:BittersweetShimmer] = '#BF4F51'
51
+ self[:Black] = '#000000'
52
+ self[:BlanchedAlmond] = '#FFEBCD'
53
+ self[:BlastOffBronze] = '#A57164'
54
+ self[:BlazeOrange, :SafetyOrange] = '#FF6700'
55
+ self[:BleuDeFrance] = '#318CE7'
56
+ self[:BlizzardBlue] = '#ACE5EE'
57
+ self[:Blond] = '#FAF0BE'
58
+ self[:Blue] = '#0000FF'
59
+ self[:BlueBell] = '#A2A2D0'
60
+ self[:BlueCrayola] = '#1F75FE'
61
+ self[:BlueGray] = '#6699CC'
62
+ self[:BlueGreen] = '#0D98BA'
63
+ self[:BlueMunsell] = '#0093AF'
64
+ self[:BlueNCS] = '#0087BD'
65
+ self[:BluePigment] = '#333399'
66
+ self[:BlueRYB] = '#0247FE'
67
+ self[:BlueViolet] = '#8A2BE2'
68
+ self[:Blush] = '#DE5D83'
69
+ self[:Bole] = '#79443B'
70
+ self[:BondiBlue] = '#0095B6'
71
+ self[:Bone] = '#E3DAC9'
72
+ self[:BostonUniversityRed] = '#CC0000'
73
+ self[:BottleGreen] = '#006A4E'
74
+ self[:Boysenberry] = '#873260'
75
+ self[:BrandeisBlue] = '#0070FF'
76
+ self[:Brass] = '#B5A642'
77
+ self[:BrickRed] = '#CB4154'
78
+ self[:BrightCerulean] = '#1DACD6'
79
+ self[:BrightGreen] = '#66FF00'
80
+ self[:BrightLavender] = '#BF94E4'
81
+ self[:BrightMaroon, :MaroonCrayola] = '#C32148'
82
+ self[:BrightPink, :Rose] = '#FF007F'
83
+ self[:BrightTurquoise] = '#08E8DE'
84
+ self[:BrightUbe] = '#D19FE8'
85
+ self[:BrilliantLavender, :ElectricLavender] = '#F4BBFF'
86
+ self[:BrilliantRose] = '#FF55A3'
87
+ self[:BrinkPink] = '#FB607F'
88
+ self[:BritishRacingGreen] = '#004225'
89
+ self[:Bronze] = '#CD7F32'
90
+ self[:BrownTraditional] = '#964B00'
91
+ self[:BubbleGum] = '#FFC1CC'
92
+ self[:Bubbles] = '#E7FEFF'
93
+ self[:Buff] = '#F0DC82'
94
+ self[:BulgarianRose] = '#480607'
95
+ self[:Burgundy] = '#800020'
96
+ self[:BurlyWood] = '#DEB887'
97
+ self[:BurntOrange] = '#CC5500'
98
+ self[:BurntUmber] = '#8A3324'
99
+ self[:Byzantine] = '#BD33A4'
100
+ self[:Byzantium] = '#702963'
101
+ self[:Cadet] = '#536872'
102
+ self[:CadetBlue] = '#5F9EA0'
103
+ self[:CadetGrey] = '#91A3B0'
104
+ self[:CadmiumGreen] = '#006B3C'
105
+ self[:CadmiumOrange] = '#ED872D'
106
+ self[:CadmiumRed] = '#E30022'
107
+ self[:CadmiumYellow] = '#FFF600'
108
+ self[:CafeAuLait, :FrenchBeige] = '#A67B5B'
109
+ self[:CafeNoir] = '#4B3621'
110
+ self[:CalPolyGreen] = '#1E4D2B'
111
+ self[:CambridgeBlue] = '#A3C1AD'
112
+ self[:Camel, :Desert, :Fallow, :Lion] = '#C19A6B'
113
+ self[:CameoPink] = '#EFBBCC'
114
+ self[:CamouflageGreen] = '#78866B'
115
+ self[:CanaryYellow, :YellowProcess] = '#FFEF00'
116
+ self[:CandyAppleRed] = '#FF0800'
117
+ self[:CandyPink, :TangoPink] = '#E4717A'
118
+ self[:Capri, :DeepSkyBlue] = '#00BFFF'
119
+ self[:CaputMortuum] = '#592720'
120
+ self[:Cardinal] = '#C41E3A'
121
+ self[:CaribbeanGreen] = '#00CC99'
122
+ self[:Carmine] = '#960018'
123
+ self[:CarminePink] = '#EB4C42'
124
+ self[:CarmineRed] = '#FF0038'
125
+ self[:Carnation] = '#FF5ED0'
126
+ self[:CarnationPink] = '#FFA6C9'
127
+ self[:Carnelian, :CornellRed] = '#B31B1B'
128
+ self[:CarolinaBlue] = '#99BADD'
129
+ self[:CarrotOrange] = '#ED9121'
130
+ self[:Cayenne] = '#8D0000'
131
+ self[:Ceil] = '#92A1CF'
132
+ self[:Celadon] = '#ACE1AF'
133
+ self[:CeladonBlue, :Cerulean] = '#007BA7'
134
+ self[:CelesteColour] = '#B2FFFF'
135
+ self[:CelestialBlue] = '#4997D0'
136
+ self[:Cerise] = '#D83387'
137
+ self[:CerisePink] = '#EC3B83'
138
+ self[:CeriseRed, :Cherry] = '#DE3163'
139
+ self[:CeruleanBlue] = '#2A52BE'
140
+ self[:CeruleanFrost] = '#6D9BC3'
141
+ self[:CGBlue] = '#007AA5'
142
+ self[:CGRed] = '#E03C31'
143
+ self[:Chamoisee] = '#A0785A'
144
+ self[:Champagne, :DeepChampagne, :Sunset] = '#FAD6A5'
145
+ self[:Charcoal] = '#36454F'
146
+ self[:CharmPink, :LightThulianPink] = '#E68FAC'
147
+ self[:Chartreuse] = '#7FFF00'
148
+ self[:ChartreuseYellow] = '#DFFF00'
149
+ self[:CherryBlossomPink] = '#FFB7C5'
150
+ self[:Chestnut, :IndianRed] = '#CD5C5C'
151
+ self[:ChinaPink, :ThulianPink] = '#DE6FA1'
152
+ self[:ChinaRose] = '#A8516E'
153
+ self[:Chocolate, :ChocolateWeb, :Cinnamon, :CocoaBrown] = '#D2691E'
154
+ self[:ChocolateTraditional] = '#7B3F00'
155
+ self[:ChromeYellow] = '#FFA700'
156
+ self[:Cinereous] = '#98817B'
157
+ self[:Cinnabar, :Vermilion] = '#E34234'
158
+ self[:Citrine] = '#E4D00A'
159
+ self[:ClassicRose] = '#FBCCE7'
160
+ self[:Cobalt] = '#0047AB'
161
+ self[:Coffee] = '#6F4E37'
162
+ self[:ColumbiaBlue] = '#9BDDFF'
163
+ self[:CongoPink, :CoralPink, :TeaRoseOrange] = '#F88379'
164
+ self[:CoolBlack] = '#002E63'
165
+ self[:CoolCopper] = '#D98719'
166
+ self[:CoolGrey] = '#8C92AC'
167
+ self[:Copper] = '#B87333'
168
+ self[:CopperRose] = '#996666'
169
+ self[:Coquelicot] = '#FF3800'
170
+ self[:Coral] = '#FF7F50'
171
+ self[:CoralRed] = '#FF4040'
172
+ self[:Cordovan] = '#893F45'
173
+ self[:Corn, :Maize] = '#FBEC5D'
174
+ self[:CornflowerBlue] = '#6495ED'
175
+ self[:Cornsilk] = '#FFF8DC'
176
+ self[:CosmicLatte] = '#FFF8E7'
177
+ self[:CottonCandy] = '#FFBCD9'
178
+ self[:Cream] = '#FFFDD0'
179
+ self[:Crimson] = '#DC143C'
180
+ self[:CrimsonGlory] = '#BE0032'
181
+ self[:CyanProcess] = '#00B7EB'
182
+ self[:Daffodil] = '#FFFF31'
183
+ self[:Dandelion] = '#F0E130'
184
+ self[:DarkBlue] = '#00008B'
185
+ self[:DarkBrown, :OtterBrown] = '#654321'
186
+ self[:DarkByzantium] = '#5D3954'
187
+ self[:DarkCandyAppleRed] = '#A40000'
188
+ self[:DarkCerulean] = '#08457E'
189
+ self[:DarkChestnut] = '#986960'
190
+ self[:DarkCoral] = '#CD5B45'
191
+ self[:DarkCyan] = '#008B8B'
192
+ self[:DarkElectricBlue, :PaynesGrey] = '#536878'
193
+ self[:DarkGoldenRod] = '#B8860B'
194
+ self[:DarkGray] = '#A9A9A9'
195
+ self[:DarkGreen] = '#013220'
196
+ self[:DarkImperialBlue, :IndigoDye] = '#00416A'
197
+ self[:DarkJungleGreen] = '#1A2421'
198
+ self[:DarkKhaki] = '#BDB76B'
199
+ self[:DarkLava, :DarkTaupe, :Taupe] = '#483C32'
200
+ self[:DarkLavender] = '#734F96'
201
+ self[:DarkMagenta] = '#8B008B'
202
+ self[:DarkMidnightBlue] = '#003366'
203
+ self[:DarkOliveGreen] = '#556B2F'
204
+ self[:DarkOrange] = '#FF8C00'
205
+ self[:DarkOrchid] = '#9932CC'
206
+ self[:DarkPastelBlue] = '#779ECB'
207
+ self[:DarkPastelGreen] = '#03C03C'
208
+ self[:DarkPastelPurple] = '#966FD6'
209
+ self[:DarkPastelRed] = '#C23B22'
210
+ self[:DarkPink] = '#E75480'
211
+ self[:DarkPowderBlue, :Smalt] = '#003399'
212
+ self[:DarkRaspberry] = '#872657'
213
+ self[:DarkRed] = '#8B0000'
214
+ self[:DarkSalmon] = '#E9967A'
215
+ self[:DarkScarlet] = '#560319'
216
+ self[:DarkSeaGreen] = '#8FBC8F'
217
+ self[:DarkSienna] = '#3C1414'
218
+ self[:DarkSlateBlue] = '#483D8B'
219
+ self[:DarkSlateGray] = '#2F4F4F'
220
+ self[:DarkSpringGreen] = '#177245'
221
+ self[:DarkTan] = '#918151'
222
+ self[:DarkTangerine] = '#FFA812'
223
+ self[:DarkTerraCotta] = '#CC4E5C'
224
+ self[:DarkTurquoise] = '#00CED1'
225
+ self[:DarkViolet] = '#9400D3'
226
+ self[:DarkYellow] = '#9B870C'
227
+ self[:DartmouthGreen] = '#00703C'
228
+ self[:DavysGrey] = '#555555'
229
+ self[:DebianRed] = '#D70A53'
230
+ self[:DeepCarmine] = '#A9203E'
231
+ self[:DeepCarminePink] = '#EF3038'
232
+ self[:DeepCarrotOrange] = '#E9692C'
233
+ self[:DeepCerise] = '#DA3287'
234
+ self[:DeepChestnut] = '#B94E48'
235
+ self[:DeepCoffee] = '#704241'
236
+ self[:DeepFuchsia] = '#C154C1'
237
+ self[:DeepJungleGreen] = '#004B49'
238
+ self[:DeepLilac] = '#9955BB'
239
+ self[:DeepMagenta] = '#CC00CC'
240
+ self[:DeepPeach, :PeachCrayola] = '#FFCBA4'
241
+ self[:DeepPink, :FluorescentPink] = '#FF1493'
242
+ self[:DeepSaffron] = '#FF9933'
243
+ self[:Denim] = '#1560BD'
244
+ self[:DesertSand] = '#EDC9AF'
245
+ self[:DimGray] = '#696969'
246
+ self[:DodgerBlue] = '#1E90FF'
247
+ self[:DogwoodRose] = '#D71868'
248
+ self[:DollarBill] = '#85BB65'
249
+ self[:Drab, :ModeBeige, :SandDune, :SandyTaupe] = '#967117'
250
+ self[:DukeBlue] = '#00009C'
251
+ self[:EagleGreen, :MidnightGreen] = '#004953'
252
+ self[:EarthYellow] = '#E1A95F'
253
+ self[:Ecru, :Sand] = '#C2B280'
254
+ self[:Eggplant] = '#614051'
255
+ self[:Eggshell] = '#F0EAD6'
256
+ self[:EgyptianBlue] = '#1034A6'
257
+ self[:ElectricBlue] = '#7DF9FF'
258
+ self[:ElectricCrimson] = '#FF003F'
259
+ self[:ElectricGreen, :GreenX11, :Lime, :LimeWeb] = '#00FF00'
260
+ self[:ElectricIndigo] = '#6F00FF'
261
+ self[:ElectricLime, :FluorescentYellow, :FrenchLime] = '#CCFF00'
262
+ self[:ElectricPurple] = '#BF00FF'
263
+ self[:ElectricUltramarine] = '#3F00FF'
264
+ self[:ElectricViolet] = '#8F00FF'
265
+ self[:ElectricYellow, :Yellow] = '#FFFF00'
266
+ self[:Emerald, :ParisGreen] = '#50C878'
267
+ self[:EtonBlue] = '#96C8A2'
268
+ self[:FaluRed] = '#801818'
269
+ self[:Fandango] = '#B53389'
270
+ self[:FashionFuchsia, :HollywoodCerise] = '#F400A1'
271
+ self[:Fawn] = '#E5AA70'
272
+ self[:Feldgrau] = '#4D5D53'
273
+ self[:Feldspar] = '#D19275'
274
+ self[:FernGreen] = '#4F7942'
275
+ self[:FerrariRed] = '#FF2800'
276
+ self[:FieldDrab] = '#6C541E'
277
+ self[:Firebrick] = '#B22222'
278
+ self[:FireEngineRed] = '#CE2029'
279
+ self[:Flame] = '#E25822'
280
+ self[:FlamingoPink] = '#FC8EAC'
281
+ self[:Flavescent] = '#F7E98E'
282
+ self[:Flax] = '#EEDC82'
283
+ self[:FloralWhite] = '#FFFAF0'
284
+ self[:Folly] = '#FF004F'
285
+ self[:ForestGreenTraditional, :UPForestGreen] = '#014421'
286
+ self[:ForestGreenWeb] = '#228B22'
287
+ self[:FrenchBlue] = '#0072BB'
288
+ self[:FrenchLilac] = '#86608E'
289
+ self[:FrenchRaspberry] = '#C72C48'
290
+ self[:FrenchRose] = '#F64A8A'
291
+ self[:Fuchsia, :Magenta] = '#FF00FF'
292
+ self[:FuchsiaPink] = '#FF77FF'
293
+ self[:FuchsiaRose] = '#C74375'
294
+ self[:Fulvous] = '#E48400'
295
+ self[:FuzzyWuzzy] = '#CC6666'
296
+ self[:Gainsboro] = '#DCDCDC'
297
+ self[:Gamboge] = '#E49B0F'
298
+ self[:GhostWhite] = '#F8F8FF'
299
+ self[:Ginger] = '#B06500'
300
+ self[:Glaucous] = '#6082B6'
301
+ self[:Glitter] = '#E6E8FA'
302
+ self[:Gold, :GoldWebGolden] = '#FFD700'
303
+ self[:GoldenBrown] = '#996515'
304
+ self[:GoldenPoppy] = '#FCC200'
305
+ self[:Goldenrod] = '#DAA520'
306
+ self[:GoldenYellow] = '#FFDF00'
307
+ self[:GoldMetallic] = '#D4AF37'
308
+ self[:GrannySmithApple] = '#A8E4A0'
309
+ self[:Gray, :Gray50, :Nickel, :TrolleyGrey] = '#808080'
310
+ self[:Gray10, :Lead] = '#191919'
311
+ self[:Gray20] = '#373737'
312
+ self[:Gray30, :Iron] = '#4C4C4C'
313
+ self[:Gray40, :Steel] = '#666666'
314
+ self[:Gray70, :Magnesium] = '#B3B3B3'
315
+ self[:Gray80, :Silver2] = '#CCCCCC'
316
+ self[:Gray90, :Mercury] = '#E6E6E6'
317
+ self[:GrayAsparagus] = '#465945'
318
+ self[:GrayWeb, :Tin] = '#7F7F7F'
319
+ self[:GrayX11] = '#BEBEBE'
320
+ self[:GreenCrayola] = '#1CAC78'
321
+ self[:GreenMunsell] = '#00A877'
322
+ self[:GreenNCS] = '#009F6B'
323
+ self[:GreenPigment] = '#00A550'
324
+ self[:GreenRYB] = '#66B032'
325
+ self[:GreenYellow] = '#ADFF2F'
326
+ self[:Grullo] = '#A99A86'
327
+ self[:GuppieGreen, :SpringGreen] = '#00FF7F'
328
+ self[:HalayaUbe] = '#663854'
329
+ self[:HanBlue] = '#446CCF'
330
+ self[:HanPurple] = '#5218FA'
331
+ self[:Harlequin] = '#3FFF00'
332
+ self[:HarvardCrimson] = '#C90016'
333
+ self[:HarvestGold] = '#DA9100'
334
+ self[:HeartGold, :Olive] = '#808000'
335
+ self[:Heliotrope] = '#DF73FF'
336
+ self[:Honeydew] = '#F0FFF0'
337
+ self[:HonoluluBlue] = '#007FBF'
338
+ self[:HookersGreen] = '#49796B'
339
+ self[:HotMagenta] = '#FF1DCE'
340
+ self[:HotPink] = '#FF69B4'
341
+ self[:HunterGreen] = '#355E3B'
342
+ self[:Iceberg] = '#71A6D2'
343
+ self[:Icterine] = '#FCF75E'
344
+ self[:ImperialBlue] = '#002395'
345
+ self[:Inchworm] = '#B2EC5D'
346
+ self[:IndiaGreen] = '#138808'
347
+ self[:IndianYellow] = '#E3A857'
348
+ self[:Indigo] = '#4F69C6'
349
+ self[:IndigoWeb] = '#4B0082'
350
+ self[:InternationalKleinBlue] = '#002FA7'
351
+ self[:InternationalOrangeAerospace] = '#FF4F00'
352
+ self[:InternationalOrangeEngineering] = '#BA160C'
353
+ self[:Iris] = '#5A4FCF'
354
+ self[:Isabelline] = '#F4F0EC'
355
+ self[:IslamicGreen] = '#009000'
356
+ self[:Ivory] = '#FFFFF0'
357
+ self[:Jade] = '#00A86B'
358
+ self[:Jasmine, :MellowYellow] = '#F8DE7E'
359
+ self[:Jasper] = '#D73B3E'
360
+ self[:JazzberryJam] = '#A50B5E'
361
+ self[:Jonquil, :NaplesYellow, :RoyalYellow, :StilDeGrainYellow] = '#FADA5E'
362
+ self[:JuneBud] = '#BDDA57'
363
+ self[:JungleGreen] = '#29AB87'
364
+ self[:KellyGreen] = '#4CBB17'
365
+ self[:Khaki, :KhakiX11, :LightKhaki] = '#F0E68C'
366
+ self[:KhakiWeb] = '#C3B091'
367
+ self[:KUCrimson] = '#E8000D'
368
+ self[:LanguidLavender] = '#D6CADD'
369
+ self[:LapisLazuli] = '#26619C'
370
+ self[:LaSalleGreen] = '#087830'
371
+ self[:LaserLemon] = '#FEFE22'
372
+ self[:LaurelGreen] = '#A9BA9D'
373
+ self[:Lava] = '#CF1020'
374
+ self[:LavenderBlue, :Periwinkle] = '#CCCCFF'
375
+ self[:LavenderBlush] = '#FFF0F5'
376
+ self[:LavenderFloral] = '#B57EDC'
377
+ self[:LavenderGray] = '#C4C3D0'
378
+ self[:LavenderIndigo] = '#9457EB'
379
+ self[:LavenderMagenta, :Violet, :VioletWeb] = '#EE82EE'
380
+ self[:LavenderMist, :LavenderWeb] = '#E6E6FA'
381
+ self[:LavenderPink] = '#FBAED2'
382
+ self[:LavenderPurple] = '#967BB6'
383
+ self[:LavenderRose] = '#FBA0E3'
384
+ self[:LawnGreen] = '#7CFC00'
385
+ self[:Lemon] = '#FFF700'
386
+ self[:LemonChiffon] = '#FFFACD'
387
+ self[:LemonLime] = '#E3FF00'
388
+ self[:LightApricot] = '#FDD5B1'
389
+ self[:LightBlue] = '#ADD8E6'
390
+ self[:LightBrown] = '#B5651D'
391
+ self[:LightCarminePink] = '#E66771'
392
+ self[:LightCoral] = '#F08080'
393
+ self[:LightCornflowerBlue] = '#93CCEA'
394
+ self[:LightCrimson] = '#F56991'
395
+ self[:LightCyan] = '#E0FFFF'
396
+ self[:LightFuchsiaPink] = '#F984EF'
397
+ self[:LightGoldenrodYellow] = '#FAFAD2'
398
+ self[:LightGray] = '#D3D3D3'
399
+ self[:LightGreen] = '#90EE90'
400
+ self[:LightPastelPurple] = '#B19CD9'
401
+ self[:LightPink] = '#FFB6C1'
402
+ self[:LightRedOchre] = '#E97451'
403
+ self[:LightSalmon] = '#FFA07A'
404
+ self[:LightSalmonPink] = '#FF9999'
405
+ self[:LightSeaGreen] = '#20B2AA'
406
+ self[:LightSkyBlue] = '#87CEFA'
407
+ self[:LightSlateBlue] = '#8470FF'
408
+ self[:LightSlateGray] = '#778899'
409
+ self[:LightSteelBlue] = '#B0C4DE'
410
+ self[:LightTaupe] = '#B38B6D'
411
+ self[:LightYellow] = '#FFFFED'
412
+ self[:Lilac] = '#C8A2C8'
413
+ self[:LimeCW] = '#BFFF00'
414
+ self[:LimeGreen] = '#32CD32'
415
+ self[:LincolnGreen] = '#195905'
416
+ self[:Linen] = '#FAF0E6'
417
+ self[:Liver] = '#534B4F'
418
+ self[:Lust] = '#E62020'
419
+ self[:MagentaDye] = '#CA1F7B'
420
+ self[:MagentaProcess] = '#FF0090'
421
+ self[:MagicMint] = '#AAF0D1'
422
+ self[:Magnolia] = '#F8F4FF'
423
+ self[:Mahogany] = '#C04000'
424
+ self[:MajorelleBlue] = '#6050DC'
425
+ self[:Malachite] = '#0BDA51'
426
+ self[:Manatee] = '#979AAA'
427
+ self[:MangoTango] = '#FF8243'
428
+ self[:Mantis] = '#74C365'
429
+ self[:Maroon, :MaroonWeb] = '#800000'
430
+ self[:MaroonX11, :RichMaroon] = '#B03060'
431
+ self[:Mauve] = '#E0B0FF'
432
+ self[:Mauvelous] = '#EF98AA'
433
+ self[:MauveTaupe, :RaspberryGlace] = '#915F6D'
434
+ self[:MayaBlue] = '#73C2FB'
435
+ self[:MeatBrown] = '#E5B73B'
436
+ self[:MediumAquamarine] = '#66DDAA'
437
+ self[:MediumBlue] = '#0000CD'
438
+ self[:MediumCandyAppleRed] = '#E2062C'
439
+ self[:MediumCarmine, :PaleCarmine] = '#AF4035'
440
+ self[:MediumChampagne, :Vanilla] = '#F3E5AB'
441
+ self[:MediumElectricBlue] = '#035096'
442
+ self[:MediumJungleGreen] = '#1C352D'
443
+ self[:MediumLavenderMagenta, :PalePlum, :Plum, :PlumWeb] = '#DDA0DD'
444
+ self[:MediumOrchid] = '#BA55D3'
445
+ self[:MediumPersianBlue] = '#0067A5'
446
+ self[:MediumPurple] = '#9370DB'
447
+ self[:MediumRedViolet] = '#BB3385'
448
+ self[:MediumSeaGreen] = '#3CB371'
449
+ self[:MediumSlateBlue] = '#7B68EE'
450
+ self[:MediumSpringBud] = '#C9DC87'
451
+ self[:MediumSpringGreen] = '#00FA9A'
452
+ self[:MediumTaupe] = '#674C47'
453
+ self[:MediumTealBlue] = '#0054B4'
454
+ self[:MediumTurquoise] = '#48D1CC'
455
+ self[:MediumVioletRed, :RedViolet] = '#C71585'
456
+ self[:Melon] = '#FDBCB4'
457
+ self[:MidnightBlue] = '#191970'
458
+ self[:MikadoYellow] = '#FFC40C'
459
+ self[:Mint] = '#3EB489'
460
+ self[:MintCream] = '#F5FFFA'
461
+ self[:MintGreen] = '#98FF98'
462
+ self[:MistyRose] = '#FFE4E1'
463
+ self[:Moccasin2] = '#FFE4B5'
464
+ self[:MoonstoneBlue] = '#73A9C2'
465
+ self[:MordantRed19] = '#AE0C00'
466
+ self[:MossGreen] = '#ADDFAD'
467
+ self[:MountainMeadow] = '#30BA8F'
468
+ self[:MountbattenPink] = '#997A8D'
469
+ self[:MSUGreen] = '#18453B'
470
+ self[:Mulberry] = '#C54B8C'
471
+ self[:Mustard] = '#FFDB58'
472
+ self[:Myrtle] = '#21421E'
473
+ self[:NadeshikoPink] = '#F6ADC6'
474
+ self[:NapierGreen] = '#2A8000'
475
+ self[:NavajoWhite] = '#FFDEAD'
476
+ self[:Navy, :NavyBlue] = '#000080'
477
+ self[:NeonCarrot] = '#FFA343'
478
+ self[:NeonFuchsia] = '#FE4164'
479
+ self[:NeonGreen] = '#39FF14'
480
+ self[:NewYorkPink] = '#D7837F'
481
+ self[:NonPhotoBlue] = '#A4DDED'
482
+ self[:NorthTexasGreen] = '#059033'
483
+ self[:OceanBoatBlue] = '#0077BE'
484
+ self[:Ochre] = '#CC7722'
485
+ self[:OldGold] = '#CFB53B'
486
+ self[:OldLace] = '#FDF5E6'
487
+ self[:OldLavender] = '#796878'
488
+ self[:OldMauve] = '#673147'
489
+ self[:OldRose] = '#C08081'
490
+ self[:OliveDrab, :OliveDrabWeb] = '#6B8E23'
491
+ self[:OliveDrab7] = '#3C341F'
492
+ self[:Olivine] = '#9AB973'
493
+ self[:Onyx] = '#0F0F0F'
494
+ self[:OperaMauve] = '#B784A7'
495
+ self[:Orange, :OrangeWeb] = '#FFA500'
496
+ self[:OrangeCW] = '#FF7F00'
497
+ self[:OrangePeel] = '#FF9F00'
498
+ self[:OrangeRed, :RedOrange] = '#FF4500'
499
+ self[:OrangeRYB] = '#FB9902'
500
+ self[:Orchid] = '#DA70D6'
501
+ self[:OUCrimsonRed, :Stizza, :USCCardinal] = '#990000'
502
+ self[:OuterSpace] = '#414A4C'
503
+ self[:OutrageousOrange] = '#FF6E4A'
504
+ self[:OxfordBlue] = '#002147'
505
+ self[:PakistanGreen] = '#006600'
506
+ self[:PalatinateBlue] = '#273BE2'
507
+ self[:PalatinatePurple] = '#682860'
508
+ self[:PaleBlue, :PaleTurquoise] = '#AFEEEE'
509
+ self[:PaleBrown] = '#987654'
510
+ self[:PaleCerulean] = '#9BC4E2'
511
+ self[:PaleChestnut] = '#DDADAF'
512
+ self[:PaleCopper] = '#DA8A67'
513
+ self[:PaleCornflowerBlue] = '#ABCDEF'
514
+ self[:PaleGold] = '#E6BE8A'
515
+ self[:PaleGoldenrod] = '#EEE8AA'
516
+ self[:PaleGreen] = '#98FB98'
517
+ self[:PaleLavender] = '#DCD0FF'
518
+ self[:PaleMagenta] = '#F984E5'
519
+ self[:PalePink] = '#FADADD'
520
+ self[:PaleRedViolet, :PaleVioletRed] = '#DB7093'
521
+ self[:PaleRobinEggBlue] = '#96DED1'
522
+ self[:PaleSilver] = '#C9C0BB'
523
+ self[:PaleSpringBud] = '#ECEBBD'
524
+ self[:PaleTaupe] = '#BC987E'
525
+ self[:PansyPurple] = '#78184A'
526
+ self[:PapayaWhip] = '#FFEFD5'
527
+ self[:Paradiso] = '#2F847C'
528
+ self[:PastelBlue] = '#AEC6CF'
529
+ self[:PastelBrown] = '#836953'
530
+ self[:PastelGray] = '#CFCFC4'
531
+ self[:PastelGreen] = '#77DD77'
532
+ self[:PastelMagenta] = '#F49AC2'
533
+ self[:PastelOrange] = '#FFB347'
534
+ self[:PastelPink] = '#DEA5A4'
535
+ self[:PastelPurple] = '#B39EB5'
536
+ self[:PastelRed] = '#FF6961'
537
+ self[:PastelViolet] = '#CB99C9'
538
+ self[:PastelYellow] = '#FDFD96'
539
+ self[:Patriarch, :Purple, :PurpleWeb] = '#800080'
540
+ self[:Peach] = '#FFE5B4'
541
+ self[:PeachOrange] = '#FFCC99'
542
+ self[:PeachPuff] = '#FFDAB9'
543
+ self[:PeachYellow] = '#FADFAD'
544
+ self[:Pear] = '#D1E231'
545
+ self[:Pearl] = '#EAE0C8'
546
+ self[:PearlAqua] = '#88D8C0'
547
+ self[:PearlyPurple] = '#B768A2'
548
+ self[:Peridot] = '#E6E200'
549
+ self[:PersianBlue] = '#1C39BB'
550
+ self[:PersianGreen] = '#00A693'
551
+ self[:PersianIndigo] = '#32127A'
552
+ self[:PersianOrange] = '#D99058'
553
+ self[:PersianPink] = '#F77FBE'
554
+ self[:PersianPlum, :Prune] = '#701C1C'
555
+ self[:PersianRed] = '#CC3333'
556
+ self[:PersianRose] = '#FE28A2'
557
+ self[:Persimmon] = '#EC5800'
558
+ self[:Peru] = '#CD853F'
559
+ self[:Phlox, :PsychedelicPurple] = '#DF00FF'
560
+ self[:PhthaloBlue] = '#000F89'
561
+ self[:PhthaloGreen] = '#123524'
562
+ self[:PiggyPink] = '#FDDDE6'
563
+ self[:PineGreen] = '#01796F'
564
+ self[:Pink] = '#FFC0CB'
565
+ self[:PinkLace] = '#FFDDF4'
566
+ self[:PinkPearl] = '#E7ACCF'
567
+ self[:PinkSherbet] = '#F78FA7'
568
+ self[:Pistachio] = '#93C572'
569
+ self[:Platinum] = '#E5E4E2'
570
+ self[:PlumTraditional] = '#8E4585'
571
+ self[:Poly, :PolySilicon] = '#600000'
572
+ self[:PortlandOrange] = '#FF5A36'
573
+ self[:PowderBlue, :PowderBlueWeb] = '#B0E0E6'
574
+ self[:PrincetonOrange] = '#FF8F00'
575
+ self[:PrussianBlue] = '#003153'
576
+ self[:Puce] = '#CC8899'
577
+ self[:Pumpkin] = '#FF7518'
578
+ self[:PurpleHeart] = '#69359C'
579
+ self[:PurpleMountainMajesty] = '#9678B6'
580
+ self[:PurpleMunsell] = '#9F00C5'
581
+ self[:PurplePizzazz] = '#FE4EDA'
582
+ self[:PurpleTaupe] = '#50404D'
583
+ self[:PurpleX11, :Veronica] = '#A020F0'
584
+ self[:Quartz] = '#51484F'
585
+ self[:RadicalRed] = '#FF355E'
586
+ self[:Raspberry] = '#E30B5D'
587
+ self[:RaspberryPink] = '#E25098'
588
+ self[:RaspberryRose] = '#B3446C'
589
+ self[:RawUmber] = '#826644'
590
+ self[:RazzleDazzleRose] = '#FF33CC'
591
+ self[:Razzmatazz] = '#E3256B'
592
+ self[:Red] = '#FF0000'
593
+ self[:RedMunsell] = '#F2003C'
594
+ self[:RedNCS] = '#C40233'
595
+ self[:RedPigment] = '#ED1C24'
596
+ self[:RedRYB] = '#FE2712'
597
+ self[:Redwood, :RoseVale] = '#AB4E52'
598
+ self[:Regalia] = '#522D80'
599
+ self[:RichBlack] = '#004040'
600
+ self[:RichBrilliantLavender] = '#F1A7FE'
601
+ self[:RichCarmine] = '#D70040'
602
+ self[:RichElectricBlue] = '#0892D0'
603
+ self[:RichLavender] = '#A76BCF'
604
+ self[:RichLilac] = '#B666D2'
605
+ self[:RifleGreen] = '#414833'
606
+ self[:RobinEggBlue] = '#00CCCC'
607
+ self[:RoseBonbon] = '#F9429E'
608
+ self[:RoseEbony] = '#674846'
609
+ self[:RoseGold] = '#B76E79'
610
+ self[:RosePink] = '#FF66CC'
611
+ self[:RoseQuartz] = '#AA98A9'
612
+ self[:RoseTaupe] = '#905D5D'
613
+ self[:Rosewood] = '#65000B'
614
+ self[:RossoCorsa] = '#D40000'
615
+ self[:RosyBrown] = '#BC8F8F'
616
+ self[:RoyalAzure] = '#0038A8'
617
+ self[:RoyalBlue, :RoyalBlueWeb] = '#4169E1'
618
+ self[:RoyalBlueTraditional] = '#002366'
619
+ self[:RoyalFuchsia] = '#CA2C92'
620
+ self[:RoyalPurple] = '#7851A9'
621
+ self[:Ruby] = '#E0115F'
622
+ self[:Ruddy] = '#FF0028'
623
+ self[:RuddyBrown] = '#BB6528'
624
+ self[:RuddyPink] = '#E18E96'
625
+ self[:Rufous] = '#A81C07'
626
+ self[:Russet] = '#80461B'
627
+ self[:Rust] = '#B7410E'
628
+ self[:SacramentoStateGreen] = '#00563F'
629
+ self[:SaddleBrown] = '#8B4513'
630
+ self[:Saffron] = '#F4C430'
631
+ self[:Salmon] = '#FF8C69'
632
+ self[:Salmon2] = '#FA8072'
633
+ self[:SalmonPink] = '#FF91A4'
634
+ self[:Sandstorm] = '#ECD540'
635
+ self[:SandyBrown] = '#F4A460'
636
+ self[:Sangria] = '#92000A'
637
+ self[:SapGreen] = '#507D2A'
638
+ self[:Sapphire] = '#0F52BA'
639
+ self[:SatinSheenGold] = '#CBA135'
640
+ self[:Scarlet] = '#FF2400'
641
+ self[:ScarletCrayola, :TractorRed] = '#FD0E35'
642
+ self[:SchoolBusYellow] = '#FFD800'
643
+ self[:ScreaminGreen] = '#76FF7A'
644
+ self[:SeaBlue] = '#006994'
645
+ self[:SeaGreen] = '#2E8B57'
646
+ self[:SealBrown] = '#321414'
647
+ self[:Seashell] = '#FFF5EE'
648
+ self[:SelectiveYellow] = '#FFBA00'
649
+ self[:Sepia] = '#704214'
650
+ self[:Shadow] = '#8A795D'
651
+ self[:ShamrockGreen] = '#009E60'
652
+ self[:ShockingPink] = '#FC0FC0'
653
+ self[:ShockingPinkCrayola, :UltraPink] = '#FF6FFF'
654
+ self[:Sienna] = '#A0522D'
655
+ self[:Silver] = '#C0C0C0'
656
+ self[:Sinopia] = '#CB410B'
657
+ self[:Skobeloff] = '#007474'
658
+ self[:SkyBlue] = '#87CEEB'
659
+ self[:SkyMagenta] = '#CF71AF'
660
+ self[:SlateBlue] = '#6A5ACD'
661
+ self[:SlateGray] = '#708090'
662
+ self[:SmokeyTopaz] = '#933D41'
663
+ self[:SmokyBlack] = '#100C08'
664
+ self[:Snow] = '#FFFAFA'
665
+ self[:SpiroDiscoBall] = '#0FC0FC'
666
+ self[:SpringBud] = '#A7FC00'
667
+ self[:SteelBlue] = '#4682B4'
668
+ self[:Stormcloud] = '#4F666A'
669
+ self[:StPatricksBlue] = '#23297A'
670
+ self[:Straw] = '#E4D96F'
671
+ self[:Sunglow] = '#FFCC33'
672
+ self[:Tan] = '#D2B48C'
673
+ self[:Tangelo] = '#F94D00'
674
+ self[:Tangerine] = '#F28500'
675
+ self[:TangerineYellow, :USCGold] = '#FFCC00'
676
+ self[:TaupeGray] = '#8B8589'
677
+ self[:TeaGreen] = '#D0F0C0'
678
+ self[:Teal] = '#008080'
679
+ self[:TealBlue] = '#367588'
680
+ self[:TealGreen] = '#00827F'
681
+ self[:Telemagenta] = '#CF3476'
682
+ self[:TenneTawny] = '#CD5700'
683
+ self[:TerraCotta] = '#E2725B'
684
+ self[:Thistle] = '#D8BFD8'
685
+ self[:TickleMePink] = '#FC89AC'
686
+ self[:TiffanyBlue] = '#0ABAB5'
687
+ self[:TigersEye] = '#E08D3C'
688
+ self[:Timberwolf] = '#DBD7D2'
689
+ self[:TitaniumYellow] = '#EEE600'
690
+ self[:Tomato] = '#FF6347'
691
+ self[:Toolbox] = '#746CC0'
692
+ self[:Topaz] = '#FFC87C'
693
+ self[:TropicalRainForest] = '#00755E'
694
+ self[:TrueBlue] = '#0073CF'
695
+ self[:TuftsBlue] = '#417DC1'
696
+ self[:Tumbleweed] = '#DEAA88'
697
+ self[:Tungsten] = '#333333'
698
+ self[:TurkishRose] = '#B57281'
699
+ self[:Turquoise] = '#40E0D0'
700
+ self[:TurquoiseBlue] = '#00FFEF'
701
+ self[:TurquoiseGreen] = '#A0D6B4'
702
+ self[:TuscanRed] = '#66424D'
703
+ self[:TwilightLavender] = '#8A496B'
704
+ self[:TyrianPurple] = '#66023C'
705
+ self[:UABlue] = '#0033AA'
706
+ self[:UARed] = '#D9004C'
707
+ self[:Ube] = '#8878C3'
708
+ self[:UCLABlue] = '#536895'
709
+ self[:UCLAGold] = '#FFB300'
710
+ self[:UFOGreen] = '#3CD070'
711
+ self[:Ultramarine] = '#120A8F'
712
+ self[:UltramarineBlue] = '#4166F5'
713
+ self[:Umber] = '#635147'
714
+ self[:UnitedNationsBlue] = '#5B92E5'
715
+ self[:UniversityOfCaliforniaGold] = '#B78727'
716
+ self[:UnmellowYellow] = '#FFFF66'
717
+ self[:UPMaroon] = '#7B1113'
718
+ self[:UpsdellRed] = '#AE2029'
719
+ self[:Urobilin] = '#E1AD21'
720
+ self[:UtahCrimson] = '#D3003F'
721
+ self[:VegasGold] = '#C5B358'
722
+ self[:VenetianRed] = '#C80815'
723
+ self[:Verdigris] = '#43B3AE'
724
+ self[:VioletCW] = '#7F00FF'
725
+ self[:VioletRed] = '#D02090'
726
+ self[:VioletRYB] = '#8601AF'
727
+ self[:Viridian] = '#40826D'
728
+ self[:VividAuburn] = '#922724'
729
+ self[:VividBurgundy] = '#9F1D35'
730
+ self[:VividCerise] = '#DA1D81'
731
+ self[:VividTangerine] = '#FFA089'
732
+ self[:VividViolet] = '#9F00FF'
733
+ self[:WarmBlack] = '#004242'
734
+ self[:Waterspout] = '#A4F4F9'
735
+ self[:Wenge] = '#645452'
736
+ self[:Wheat] = '#F5DEB3'
737
+ self[:White] = '#FFFFFF'
738
+ self[:WhiteSmoke] = '#F5F5F5'
739
+ self[:WildBlueYonder] = '#A2ADD0'
740
+ self[:WildStrawberry] = '#FF43A4'
741
+ self[:WildWatermelon] = '#FC6C85'
742
+ self[:Wine] = '#722F37'
743
+ self[:Wisteria] = '#C9A0DC'
744
+ self[:Xanadu] = '#738678'
745
+ self[:YaleBlue] = '#0F4D92'
746
+ self[:YellowGreen] = '#9ACD32'
747
+ self[:YellowMunsell] = '#EFCC00'
748
+ self[:YellowNCS] = '#FFD300'
749
+ self[:YellowOrange] = '#FFAE42'
750
+ self[:YellowRYB] = '#FEFE33'
751
+ self[:Zaffre] = '#0014A8'
752
+ self[:ZinnwalditeBrown] = '#2C1608'
753
+ end
754
+ end
data/lib/pigment.rb ADDED
@@ -0,0 +1,264 @@
1
+ module Pigment
2
+ VERSION = '0.1.0'
3
+
4
+ class Color
5
+
6
+ @named_colors = {}
7
+ attr_reader :color, :hsl
8
+
9
+ # Pigment uses sRGB or sRGBA as the default color system
10
+ # color can be a hexadecimal code preceded by a '#' like '#FF4CB2' or a array of floats (1.0, 0.3, 0.7)
11
+ # or an array of integers between 0 and 255 ()
12
+ # @param [String, Array] color
13
+ def initialize(*color)
14
+ @color = case
15
+ when color[0] =~ /^#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})?$/
16
+ [$1, $2, $3, $4 || 'ff'].map { |v| v.to_i(16) / 255.0 }
17
+ when color.is_a?(Array) && (color.all? { |c| (0.0..1.0).include? c }) && color.length == 3
18
+ [color, 1.0].flatten!
19
+ when color.is_a?(Array) && (color.all? { |c| (0..255).include? c && c.is_a?(Integer) } ) && color.length == 3
20
+ [color.map { |c| c / 255.0 }, 1.0].flatten!
21
+ when color.is_a?(Array) && (color.all? { |c| (0.0..1.0).include? c }) && color.length == 4
22
+ color
23
+ when color.is_a?(Array) && (color.all? { |c| (0..255).include? c && c.is_a?(Integer) } ) && color.length == 4
24
+ color.map { |c| c / 255.0 }
25
+ else
26
+ raise ArgumentError, "Expected String or Array with length 3 or 4. Given #{color.class} with length = #{color.length}"
27
+ end
28
+ end
29
+
30
+ # Selectors.
31
+ %w'r g b a'.each_with_index do |m, i|
32
+ define_method("#{m}", ->() { color[i] })
33
+ end
34
+
35
+ %w'h s l'.each_with_index do |m, i|
36
+ define_method("#{m}", ->() { hsl[i] })
37
+ end
38
+
39
+ # Return specified color by its name from the named_colors hash.
40
+ # @param [Symbol] name
41
+ # @return [Color]
42
+ def self.[](name)
43
+ @named_colors[name]
44
+ end
45
+
46
+ # Add name to a color , add it to the named_colors hash and defines a constant.
47
+ # @param [Array of Strings] names
48
+ # @param [Color] color
49
+ def self.[]=(*names, color)
50
+ color = new(color) unless color.is_a? Color
51
+ names.each do |name|
52
+ @named_colors[name.downcase] = color
53
+ const_set("#{name}".to_sym, color)
54
+ end
55
+ end
56
+
57
+ # Return all the named_colors as an array.
58
+ def self.named_colors
59
+ @named_colors.keys
60
+ end
61
+
62
+ # Return all the named_colors as a sorted array.
63
+ def self.named_colors_sorted
64
+ named_colors.sort
65
+ end
66
+
67
+
68
+ # Supress an array of floats by dividing by the greatest color component.
69
+ # @param [Array] color
70
+ # @return [Array]
71
+ def self.supress(color)
72
+ unless (0.0..1.0).include?(color.max)
73
+ color.map! { |c| c / color.max }
74
+ end
75
+ color
76
+ end
77
+
78
+ # Creates a Color form the HSL color System. It's mostly used to calculate harmonic colors.
79
+ # @param [Float] h
80
+ # @param [Float] s
81
+ # @param [Float] l
82
+ # @return [Color]
83
+ def self.from_hsl(h, s, l)
84
+ return new(l, l, l) if s == 0
85
+ v2 = l < 0.5 ? l * (1 + s) : (l + s) - (s * l)
86
+ v1 = 2 * l - v2
87
+ color = [h + (1 / 3.0), h, h - (1 / 3.0)].map do |hv|
88
+ case
89
+ when hv < 0 then hv += 1
90
+ when hv > 1 then hv -= 1
91
+ when 6 * hv < 1 then v1 +(v2 - v1) * 6 * hv
92
+ when 2 * hv < 1 then v2
93
+ when 3 * hv < 2 then v1 + (v2 - v1) * ((2 / 3.0)- hv) * 6
94
+ else v1
95
+ end
96
+ end
97
+ new(*color)
98
+ end
99
+
100
+ # Same as inverse.
101
+ def -@
102
+ inv
103
+ end
104
+
105
+ # Sums all the two colors components. If any component gets out of the 0 to 1.0 range its supressed.
106
+ # @param [Numeric] color
107
+ # @return [Color]
108
+ def +(color)
109
+ case color
110
+ when Color
111
+ self.class.new(*supress([color.color, @color].transpose.map! { |c, d| c + d }))
112
+ else
113
+ raise ArgumentError, "Expecting Color. Given #{color.class}"
114
+ end
115
+ end
116
+
117
+ # Subtracts all the two color components. If any component gets out of the 0 to 1.0 range its supressed.
118
+ # @param [Numeric] color
119
+ # @return [Color]
120
+ def -(color)
121
+ case color
122
+ when Color
123
+ self.class.new(*supress([color.color, @color].transpose.map! { |c, d| c - d }))
124
+ else
125
+ raise ArgumentError, "Expecting color. Given #{color.class}"
126
+ end
127
+ end
128
+
129
+ # Multiplies all the color components by n. If any component gets out of the 0 to 1.0 range its supressed.
130
+ # @param [Numeric] n
131
+ # @return [Color]
132
+ def *(n)
133
+ case n
134
+ when Numeric
135
+ n = @color[0, 3].map { |c| c * n.to_f }
136
+ self.class.new(*self.class.supress(n))
137
+ else
138
+ raise ArgumentError, "Expecting Numeric. Given #{n.class}"
139
+ end
140
+ end
141
+
142
+ # Divides all the color components by n. If any component gets out of the 0 to 1.0 range its supressed.
143
+ # @param [Numeric] n
144
+ # @return [Color]
145
+ def /(n)
146
+ case n
147
+ when Numeric
148
+ n = @color[0, 3].map { |c| c * n.to_f }
149
+ self.class.new(*self.class.supress(n))
150
+ else
151
+ raise ArgumentError, "Expecting Numeric. Given #{n.class}"
152
+ end
153
+ end
154
+
155
+ # Test if two colors are equal
156
+ # @param [Color] color
157
+ # @return [Boolean]
158
+ def ==(color)
159
+ color.is_a? Color && color.color[0, 3] == @color[0, 3]
160
+ end
161
+
162
+
163
+ # Calculates the harmonic colors. Type can be :triadic, :split, :analogous, :complement or :complementary
164
+ # @param [Symbol] type
165
+ # @return [Color, Array of Colors]
166
+ def harmonize(type = :triadic)
167
+ color.to_hsl unless @hsl
168
+ case type
169
+ when :triadic
170
+ [self.class.from_hsl(h - 5 / 12.0, s, l), self.class.from_hsl(h + 1 / 3.0, s, l)]
171
+ when :split
172
+ [self.class.from_hsl(h - 5 / 12.0, s, l), self.class.from_hsl(h + 5 / 12.0, s, l)]
173
+ when :analogous
174
+ [self.class.from_hsl(h - 1 / 12.0, s, l), self.class.from_hsl(h + 1 / 12.0, s, l)]
175
+ when :complement, :complementary
176
+ inv
177
+ else
178
+ raise ArgumentError, "Expected :triadic, :split, :analogous, :complement or :complementary. Given #{type}"
179
+ end
180
+ end
181
+
182
+ # Interpolates two colors. Amount must be an float between -1.0 and 1.0
183
+ # @param [Color] color
184
+ # @param [Float] amount
185
+ def interpolate(color, amount = 0.5)
186
+ if color.is_a? Color && (-1.0..1.0).include?(amount)
187
+ n = [@color, color.color].transpose.map! { |c, d| c + amount * (d - c) }
188
+ self.class.new(*self.class.supress(n))
189
+ else
190
+ raise ArgumentError
191
+ end
192
+ end
193
+
194
+ # Returns the Invert color
195
+ # @return [Color]
196
+ def inverse
197
+ self.class.new(*@color.map { |c| 1.0 - c })
198
+ end
199
+
200
+ # Creates an instance variable to keep the HSL values of a RGB color.
201
+ # @return [Array]
202
+ def to_hsl
203
+ min = @color[0, 3].min
204
+ max = @color[0, 3].max
205
+ delta = (max - min)
206
+ l = (max + min) / 2.0
207
+
208
+ s = if delta == 0.0 # close to 0.0, so it's a grey
209
+ h = 0
210
+ 0
211
+ elsif l < 0.5
212
+ delta / (max + min)
213
+ else
214
+ delta / (2.0 - max - min)
215
+ end
216
+
217
+ h = if r == max
218
+ h = ((g - b) / delta) / 6.0
219
+ h += 1.0 if g < b
220
+ elsif g == max
221
+ ((b - r) / delta) / 6.0 + (1.0 / 3.0)
222
+ elsif b == max
223
+ ((r - g) / delta) / 6.0 + (2.0 / 3.0)
224
+ end
225
+
226
+ h += 1 if h < 0
227
+ h -= 1 if h > 1
228
+ @hsl = [h, s, l]
229
+ end
230
+
231
+ # Returns an array of the color components. Alpha value is passed as well if with_alpha is set to true.
232
+ # @param [Boolean] with_alpha
233
+ # @return [Array]
234
+ def to_floats(with_alpha = false)
235
+ with_alpha ? @color : @color[0, 3]
236
+ end
237
+
238
+ # Returns an array of the color components. Alpha value is passed as well if with_alpha is set to true.
239
+ # @param [Boolean] with_alpha
240
+ # @return [Array]
241
+ def to_ints(with_alpha = false)
242
+ to_floats(with_alpha).map { |v| Integer(v * 255) }
243
+ end
244
+
245
+ # Returns an array of the color components. Alpha value is passed as well if with_alpha is set to true.
246
+ # @param [Boolean] with_alpha
247
+ # @return [Array]
248
+ def to_hex(with_alpha = false)
249
+ to_ints(with_alpha).map { |v| '%02x' % v }.join
250
+ end
251
+
252
+ alias_method :inv, :inverse
253
+ alias_method :invert, :inverse
254
+ alias_method :complementary, :inverse
255
+ alias_method :mix, :interpolate
256
+ alias_method :red, :r
257
+ alias_method :green, :g
258
+ alias_method :blue, :b
259
+ alias_method :alpha, :a
260
+ alias_method :to_f, :to_floats
261
+ end
262
+ end
263
+
264
+ require_relative 'colors.rb'
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pigment
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - P3t3rU5
9
+ - SilverPhoenix99
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-11-13 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: A rgb color gem, with a list of 750 diferent colors defined within 869
16
+ names
17
+ email:
18
+ - pedro.megastore@gmail.com
19
+ - silver.phoenix99@gmail.com
20
+ executables: []
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - lib/colors.rb
25
+ - lib/pigment.rb
26
+ homepage: https://github.com/P3t3rU5/pigment
27
+ licenses: []
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 1.8.24
47
+ signing_key:
48
+ specification_version: 3
49
+ summary: A RGB color gem
50
+ test_files: []