A Wiki in the Desert
Log in

Module:Color

From A Wiki in the Desert
Revision as of 06:54, 3 November 2018 by Brad (talk | contribs) (Creating Color module)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Color/doc

local p = {}

function p.style( frame )
	local background = background(frame.args[1])
	local foreground = foreground(frame.args[1])
	
	return 'style="background-color: #' .. background .. '; color: ' .. foreground .. ';"'
end

function background( color )
	local color_table =
	{
		['Alice Blue'] = 'f0f8ff',
		['Amethyst'] = '9966cc',
		['Antique White'] = 'faebd7',
		['Aqua'] = '00ffff',
		['Aquamarine'] = '7fffd4',
		['Azure'] = 'f0ffff',
		['Baker Miller Pink'] = 'ff91af',
		['Banana'] = 'e3cf57',
		['Barn Red'] = '7c0a02',
		['Beet'] = '8e388e',
		['Beige'] = 'f5f5dc',
		['Bisque'] = 'ffe4c4',
		['Black'] = '010101',
		['Blanched Almond'] = 'ffebcd',
		['Blaze Orange'] = 'ff6700',
		['Blue'] = '0000ff',
		['Blue Violet'] = '8a2be2',
		['Boysenberry'] = '873260',
		['Bright Pink'] = 'ff007f',
		['Brown'] = 'a52a2a',
		['Burgundy Red'] = '800020',
		['Burly Wood'] = 'deb887',
		['Burnt Sienna'] = '8a360f',
		['Burnt Umber'] = '8a3324',
		['Cadet Blue'] = '5f9ea0',
		['Cadmium Orange'] = 'ff6103',
		['Cadmium Yellow'] = 'ff9912',
		['Carrot'] = 'e07020',
		['Chartreuse'] = '7fff00',
		['Chocolate'] = 'd2691e',
		['Cobalt Blue'] = '3d59ab',
		['Cobalt Green'] = '3d9140',
		['Coral'] = 'ff7f50',
		['Cornflower Blue'] = '6495ed',
		['Cornsilk'] = 'fff8dc',
		['Crimson'] = 'dc143c',
		['Dark Blue'] = '00008b',
		['Dark Cyan'] = '008b8b',
		['Dark Golden Rod'] = 'b8860b',
		['Dark Green'] = '006400',
		['Dark Grey'] = 'a9a9a9',
		['Dark Jungle Green'] = '1a2421',
		['Dark Khaki'] = 'bdb76b',
		['Dark Magenta'] = '8b008b',
		['Dark Olive Green'] = '556b2f',
		['Dark Orange'] = 'ff8c00',
		['Dark Orchid'] = '9932cc',
		['Dark Red'] = '8b0000',
		['Dark Salmon'] = 'e9967a',
		['Dark Scarlet'] = '560319',
		['Dark Sea Green'] = '8fbc8f',
		['Dark Sienna'] = '3c1414',
		['Dark Slate Blue'] = '483d8b',
		['Dark Slate Grey'] = '2f4f4f',
		['Dark Turquoise'] = '00ced1',
		['Dark Violet'] = '9400d3',
		['Deep Pink'] = 'ff1493',
		['Deep Sky Blue'] = '00bfff',
		['Dim Grey'] = '696969',
		['Dodger Blue'] = '1e90ff',
		['Duke Blue'] = '00009c',
		['Eggshell White'] = 'fce6c9',
		['Emerald Green'] = '00c957',
		['Feldspar'] = 'd19275',
		['Fire Brick'] = 'b22222',
		['Floral White'] = 'fffaf0',
		['Forest Green'] = '228b22',
		['Fuchsia'] = 'ff00ff',
		['Gainsboro'] = 'dcdcdc',
		['Ghost White'] = 'f8f8ff',
		['Gold'] = 'ffd700',
		['Golden Rod'] = 'daa520',
		['Green'] = '008000',
		['Green Yellow'] = 'adff2f',
		['Grey'] = '808080',
		['Honey Dew'] = 'f0fff0',
		['Hot Pink'] = 'ff69b4',
		['Imperial Blue'] = '002395',
		['Indian Red'] = 'cd5c5c',
		['Indigo'] = '4b0082',
		['Ivory'] = 'fffff0',
		['Khaki'] = 'f0e68c',
		['Lavender'] = 'e6e6fa',
		['Lavender Blush'] = 'fff0f5',
		['Lawn Green'] = '7cfc00',
		['Lemon Chiffon'] = 'fffacd',
		['Licorice'] = '1a1110',
		['Light Blue'] = 'add8e6',
		['Light Coral'] = 'f08080',
		['Light Cyan'] = 'e0ffff',
		['Light Golden Rod Yellow'] = 'fafad2',
		['Light Green'] = '90ee90',
		['Light Grey'] = 'd3d3d3',
		['Light Pink'] = 'ffb6c1',
		['Light Salmon'] = 'ffa07a',
		['Light Sea Green'] = '20b2aa',
		['Light Sky Blue'] = '87cefa',
		['Light Slate Blue'] = '8470ff',
		['Light Slate Grey'] = '778899',
		['Light Steel Blue'] = 'b0c4de',
		['Light Yellow'] = 'ffffe0',
		['Lime'] = '00ff00',
		['Lime Green'] = '32cd32',
		['Linen'] = 'faf0e6',
		['Maroon'] = '800000',
		['Medium Aqua Marine'] = '66cdaa',
		['Medium Blue'] = '0000cd',
		['Medium Orchid'] = 'ba55d3',
		['Medium Purple'] = '9370db',
		['Medium Sea Green'] = '3cb371',
		['Medium Slate Blue'] = '7b68ee',
		['Medium Spring Green'] = '00fa9a',
		['Medium Turquoise'] = '48d1cc',
		['Medium Violet Red'] = 'c71585',
		['Melon'] = 'e3a869',
		['Midnight Blue'] = '191970',
		['Mint Cream'] = 'f5fffa',
		['Misty Rose'] = 'ffe4e1',
		['Moccasin'] = 'ffe4b5',
		['Navaho White'] = 'ffdead',
		['Navy'] = '000080',
		['Old Lace'] = 'fdf5e6',
		['Olive'] = '808000',
		['Olive Drab'] = '6b8e23',
		['Orange'] = 'ffa500',
		['Orange Red'] = 'ff4500',
		['Orchid'] = 'da70d6',
		['Oxford Blue'] = '002147',
		['Pale Golden Rod'] = 'eee8aa',
		['Pale Green'] = '98fb98',
		['Pale Turquoise'] = 'afeeee',
		['Pale Violet Red'] = 'db7093',
		['Papaya Whip'] = 'ffefd5',
		['Peach Puff'] = 'ffdab9',
		['Peacock'] = '33a1c9',
		['Persian Indigo'] = '32127a',
		['Persian Pink'] = 'f77fbe',
		['Peru'] = 'cd853f',
		['Pink'] = 'ffc0cb',
		['Plum'] = 'dda0dd',
		['Powder Blue'] = 'b0e0e6',
		['Prussian Blue'] = '003153',
		['Purple'] = '800080',
		['Raw Sienna'] = 'c76114',
		['Red'] = 'ff0000',
		['Red Devil'] = '860111',
		['Rich Black'] = '004040',
		['Rosy Brown'] = 'bc8f8f',
		['Royal Blue'] = '4169e1',
		['Ruby Red'] = '9b111e',
		['Saddle Brown'] = '8b4513',
		['Salmon'] = 'fa8072',
		['Sandy Brown'] = 'f4a460',
		['Sangria'] = '92000a',
		['Sap Green'] = '308014',
		['Sea Green'] = '2e8b57',
		['Sea Shell'] = 'fff5ee',
		['Seal Brown'] = '321414',
		['Sienna'] = 'a0522d',
		['Silver'] = 'c0c0c0',
		['Sky Blue'] = '87ceeb',
		['Slate Blue'] = '6a5acd',
		['Slate Grey'] = '708090',
		['Smokey Black'] = '100c08',
		['Snow'] = 'fffafa',
		['Spring Green'] = '00ff7f',
		['Steel Blue'] = '4682b4',
		['Steel Pink'] = 'cc3366',
		['Tan'] = 'd2b48c',
		['Teal'] = '008080',
		['Thistle'] = 'd8bfd8',
		['Tomato'] = 'ff6347',
		['Turquoise'] = '40e0d0',
		['Tyrian Purple'] = '660023',
		['Violet'] = 'ee82ee',
		['Violet Red'] = 'd02090',
		['Wheat'] = 'f5deb3',
		['White'] = 'ffffff',
		['White Smoke'] = 'f5f5f5',
		['Yellow'] = 'ffff00',
		['Yellow Green'] = '9acd32',
		['Zaffre'] = '0014a8'
	}
	
	return color_table[color]
end

function foreground( color )
	local color_table =
	{
		['Alice Blue'] = 'black',
		['Amethyst'] = 'black',
		['Antique White'] = 'black',
		['Aqua'] = 'black',
		['Aquamarine'] = 'black',
		['Azure'] = 'black',
		['Baker Miller Pink'] = 'black',
		['Banana'] = 'black',
		['Barn Red'] = 'white',
		['Beet'] = 'white',
		['Beige'] = 'black',
		['Bisque'] = 'black',
		['Black'] = 'white',
		['Blanched Almond'] = 'black',
		['Blaze Orange'] = 'black',
		['Blue'] = 'white',
		['Blue Violet'] = 'white',
		['Boysenberry'] = 'white',
		['Bright Pink'] = 'black',
		['Brown'] = 'white',
		['Burgundy Red'] = 'white',
		['Burly Wood'] = 'black',
		['Burnt Sienna'] = 'white',
		['Burnt Umber'] = 'white',
		['Cadet Blue'] = 'black',
		['Cadmium Orange'] = 'black',
		['Cadmium Yellow'] = 'black',
		['Carrot'] = 'black',
		['Chartreuse'] = 'black',
		['Chocolate'] = 'black',
		['Cobalt Blue'] = 'white',
		['Cobalt Green'] = 'black',
		['Coral'] = 'black',
		['Cornflower Blue'] = 'black',
		['Cornsilk'] = 'black',
		['Crimson'] = 'white',
		['Dark Blue'] = 'white',
		['Dark Cyan'] = 'black',
		['Dark Golden Rod'] = 'black',
		['Dark Green'] = 'white',
		['Dark Grey'] = 'black',
		['Dark Jungle Green'] = 'white',
		['Dark Khaki'] = 'black',
		['Dark Magenta'] = 'white',
		['Dark Olive Green'] = 'white',
		['Dark Orange'] = 'black',
		['Dark Orchid'] = 'white',
		['Dark Red'] = 'white',
		['Dark Salmon'] = 'black',
		['Dark Scarlet'] = 'white',
		['Dark Sea Green'] = 'black',
		['Dark Sienna'] = 'white',
		['Dark Slate Blue'] = 'white',
		['Dark Slate Grey'] = 'white',
		['Dark Turquoise'] = 'black',
		['Dark Violet'] = 'white',
		['Deep Pink'] = 'black',
		['Deep Sky Blue'] = 'black',
		['Dim Grey'] = 'white',
		['Dodger Blue'] = 'black',
		['Duke Blue'] = 'white',
		['Eggshell White'] = 'black',
		['Emerald Green'] = 'black',
		['Feldspar'] = 'black',
		['Fire Brick'] = 'white',
		['Floral White'] = 'black',
		['Forest Green'] = 'black',
		['Fuchsia'] = 'black',
		['Gainsboro'] = 'black',
		['Ghost White'] = 'black',
		['Gold'] = 'black',
		['Golden Rod'] = 'black',
		['Green'] = 'white',
		['Green Yellow'] = 'black',
		['Grey'] = 'black',
		['Honey Dew'] = 'black',
		['Hot Pink'] = 'black',
		['Imperial Blue'] = 'white',
		['Indian Red'] = 'black',
		['Indigo'] = 'white',
		['Ivory'] = 'black',
		['Khaki'] = 'black',
		['Lavender'] = 'black',
		['Lavender Blush'] = 'black',
		['Lawn Green'] = 'black',
		['Lemon Chiffon'] = 'black',
		['Licorice'] = 'white',
		['Light Blue'] = 'black',
		['Light Coral'] = 'black',
		['Light Cyan'] = 'black',
		['Light Golden Rod Yellow'] = 'black',
		['Light Green'] = 'black',
		['Light Grey'] = 'black',
		['Light Pink'] = 'black',
		['Light Salmon'] = 'black',
		['Light Sea Green'] = 'black',
		['Light Sky Blue'] = 'black',
		['Light Slate Blue'] = 'black',
		['Light Slate Grey'] = 'black',
		['Light Steel Blue'] = 'black',
		['Light Yellow'] = 'black',
		['Lime'] = 'black',
		['Lime Green'] = 'black',
		['Linen'] = 'black',
		['Maroon'] = 'white',
		['Medium Aqua Marine'] = 'black',
		['Medium Blue'] = 'white',
		['Medium Orchid'] = 'black',
		['Medium Purple'] = 'black',
		['Medium Sea Green'] = 'black',
		['Medium Slate Blue'] = 'black',
		['Medium Spring Green'] = 'black',
		['Medium Turquoise'] = 'black',
		['Medium Violet Red'] = 'white',
		['Melon'] = 'black',
		['Midnight Blue'] = 'white',
		['Mint Cream'] = 'black',
		['Misty Rose'] = 'black',
		['Moccasin'] = 'black',
		['Navaho White'] = 'black',
		['Navy'] = 'white',
		['Old Lace'] = 'black',
		['Olive'] = 'black',
		['Olive Drab'] = 'black',
		['Orange'] = 'black',
		['Orange Red'] = 'black',
		['Orchid'] = 'black',
		['Oxford Blue'] = 'white',
		['Pale Golden Rod'] = 'black',
		['Pale Green'] = 'black',
		['Pale Turquoise'] = 'black',
		['Pale Violet Red'] = 'black',
		['Papaya Whip'] = 'black',
		['Peach Puff'] = 'black',
		['Peacock'] = 'black',
		['Persian Indigo'] = 'white',
		['Persian Pink'] = 'black',
		['Peru'] = 'black',
		['Pink'] = 'black',
		['Plum'] = 'black',
		['Powder Blue'] = 'black',
		['Prussian Blue'] = 'white',
		['Purple'] = 'white',
		['Raw Sienna'] = 'black',
		['Red'] = 'black',
		['Red Devil'] = 'white',
		['Rich Black'] = 'white',
		['Rosy Brown'] = 'black',
		['Royal Blue'] = 'white',
		['Ruby Red'] = 'white',
		['Saddle Brown'] = 'white',
		['Salmon'] = 'black',
		['Sandy Brown'] = 'black',
		['Sangria'] = 'white',
		['Sap Green'] = 'white',
		['Sea Green'] = 'black',
		['Sea Shell'] = 'black',
		['Seal Brown'] = 'white',
		['Sienna'] = 'white',
		['Silver'] = 'black',
		['Sky Blue'] = 'black',
		['Slate Blue'] = 'white',
		['Slate Grey'] = 'black',
		['Smokey Black'] = 'white',
		['Snow'] = 'black',
		['Spring Green'] = 'black',
		['Steel Blue'] = 'black',
		['Steel Pink'] = 'white',
		['Tan'] = 'black',
		['Teal'] = 'white',
		['Thistle'] = 'black',
		['Tomato'] = 'black',
		['Turquoise'] = 'black',
		['Tyrian Purple'] = 'white',
		['Violet'] = 'black',
		['Violet Red'] = 'white',
		['Wheat'] = 'black',
		['White'] = 'black',
		['White Smoke'] = 'black',
		['Yellow'] = 'black',
		['Yellow Green'] = 'black',
		['Zaffre'] = 'white'
	}
	
	return color_table[color]
end

return p