/*
    PIP - Platform Independent Primitives
    CSS colors
    Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "colors_p.h"

#define CSS_COLOR(n, v) \
	{ #n, v }

// clang-format off
struct CSSColor {
	const char * name;
	uint color;
} css_colors[] = {
	CSS_COLOR(aliceblue            ,0xf0f8ff),
	CSS_COLOR(antiquewhite         ,0xfaebd7),
	CSS_COLOR(aqua                 ,0x00ffff),
	CSS_COLOR(aquamarine           ,0x7fffd4),
	CSS_COLOR(azure                ,0xf0ffff),
	CSS_COLOR(beige                ,0xf5f5dc),
	CSS_COLOR(bisque               ,0xffe4c4),
	CSS_COLOR(black                ,0x000000),
	CSS_COLOR(blanchedalmond       ,0xffebcd),
	CSS_COLOR(blue                 ,0x0000ff),
	CSS_COLOR(blueviolet           ,0x8a2be2),
	CSS_COLOR(brown                ,0xa52a2a),
	CSS_COLOR(burlywood            ,0xdeb887),
	CSS_COLOR(cadetblue            ,0x5f9ea0),
	CSS_COLOR(chartreuse           ,0x7fff00),
	CSS_COLOR(chocolate            ,0xd2691e),
	CSS_COLOR(coral                ,0xff7f50),
	CSS_COLOR(cornflowerblue       ,0x6495ed),
	CSS_COLOR(cornsilk             ,0xfff8dc),
	CSS_COLOR(crimson              ,0xdc143c),
	CSS_COLOR(cyan                 ,0x00ffff),
	CSS_COLOR(darkblue             ,0x00008b),
	CSS_COLOR(darkcyan             ,0x008b8b),
	CSS_COLOR(darkgoldenrod        ,0xb8860b),
	CSS_COLOR(darkgray             ,0xa9a9a9),
	CSS_COLOR(darkgreen            ,0x006400),
	CSS_COLOR(darkgrey             ,0xa9a9a9),
	CSS_COLOR(darkkhaki            ,0xbdb76b),
	CSS_COLOR(darkmagenta          ,0x8b008b),
	CSS_COLOR(darkolivegreen       ,0x556b2f),
	CSS_COLOR(darkorange           ,0xff8c00),
	CSS_COLOR(darkorchid           ,0x9932cc),
	CSS_COLOR(darkred              ,0x8b0000),
	CSS_COLOR(darksalmon           ,0xe9967a),
	CSS_COLOR(darkseagreen         ,0x8fbc8f),
	CSS_COLOR(darkslateblue        ,0x483d8b),
	CSS_COLOR(darkslategray        ,0x2f4f4f),
	CSS_COLOR(darkslategrey        ,0x2f4f4f),
	CSS_COLOR(darkturquoise        ,0x00ced1),
	CSS_COLOR(darkviolet           ,0x9400d3),
	CSS_COLOR(deeppink             ,0xff1493),
	CSS_COLOR(deepskyblue          ,0x00bfff),
	CSS_COLOR(dimgray              ,0x696969),
	CSS_COLOR(dimgrey              ,0x696969),
	CSS_COLOR(dodgerblue           ,0x1e90ff),
	CSS_COLOR(firebrick            ,0xb22222),
	CSS_COLOR(floralwhite          ,0xfffaf0),
	CSS_COLOR(forestgreen          ,0x228b22),
	CSS_COLOR(fuchsia              ,0xff00ff),
	CSS_COLOR(gainsboro            ,0xdcdcdc),
	CSS_COLOR(ghostwhite           ,0xf8f8ff),
	CSS_COLOR(gold                 ,0xffd700),
	CSS_COLOR(goldenrod            ,0xdaa520),
	CSS_COLOR(gray                 ,0x808080),
	CSS_COLOR(green                ,0x008000),
	CSS_COLOR(greenyellow          ,0xadff2f),
	CSS_COLOR(grey                 ,0x808080),
	CSS_COLOR(honeydew             ,0xf0fff0),
	CSS_COLOR(hotpink              ,0xff69b4),
	CSS_COLOR(indianred            ,0xcd5c5c),
	CSS_COLOR(indigo               ,0x4b0082),
	CSS_COLOR(ivory                ,0xfffff0),
	CSS_COLOR(khaki                ,0xf0e68c),
	CSS_COLOR(lavender             ,0xe6e6fa),
	CSS_COLOR(lavenderblush        ,0xfff0f5),
	CSS_COLOR(lawngreen            ,0x7cfc00),
	CSS_COLOR(lemonchiffon         ,0xfffacd),
	CSS_COLOR(lightblue            ,0xadd8e6),
	CSS_COLOR(lightcoral           ,0xf08080),
	CSS_COLOR(lightcyan            ,0xe0ffff),
	CSS_COLOR(lightgoldenrodyellow ,0xfafad2),
	CSS_COLOR(lightgray            ,0xd3d3d3),
	CSS_COLOR(lightgreen           ,0x90ee90),
	CSS_COLOR(lightgrey            ,0xd3d3d3),
	CSS_COLOR(lightpink            ,0xffb6c1),
	CSS_COLOR(lightsalmon          ,0xffa07a),
	CSS_COLOR(lightseagreen        ,0x20b2aa),
	CSS_COLOR(lightskyblue         ,0x87cefa),
	CSS_COLOR(lightslategray       ,0x778899),
	CSS_COLOR(lightslategrey       ,0x778899),
	CSS_COLOR(lightsteelblue       ,0xb0c4de),
	CSS_COLOR(lightyellow          ,0xffffe0),
	CSS_COLOR(lime                 ,0x00ff00),
	CSS_COLOR(limegreen            ,0x32cd32),
	CSS_COLOR(linen                ,0xfaf0e6),
	CSS_COLOR(magenta              ,0xff00ff),
	CSS_COLOR(maroon               ,0x800000),
	CSS_COLOR(mediumaquamarine     ,0x66cdaa),
	CSS_COLOR(mediumblue           ,0x0000cd),
	CSS_COLOR(mediumorchid         ,0xba55d3),
	CSS_COLOR(mediumpurple         ,0x9370db),
	CSS_COLOR(mediumseagreen       ,0x3cb371),
	CSS_COLOR(mediumslateblue      ,0x7b68ee),
	CSS_COLOR(mediumspringgreen    ,0x00fa9a),
	CSS_COLOR(mediumturquoise      ,0x48d1cc),
	CSS_COLOR(mediumvioletred      ,0xc71585),
	CSS_COLOR(midnightblue         ,0x191970),
	CSS_COLOR(mintcream            ,0xf5fffa),
	CSS_COLOR(mistyrose            ,0xffe4e1),
	CSS_COLOR(moccasin             ,0xffe4b5),
	CSS_COLOR(navajowhite          ,0xffdead),
	CSS_COLOR(navy                 ,0x000080),
	CSS_COLOR(oldlace              ,0xfdf5e6),
	CSS_COLOR(olive                ,0x808000),
	CSS_COLOR(olivedrab            ,0x6b8e23),
	CSS_COLOR(orange               ,0xffa500),
	CSS_COLOR(orangered            ,0xff4500),
	CSS_COLOR(orchid               ,0xda70d6),
	CSS_COLOR(palegoldenrod        ,0xeee8aa),
	CSS_COLOR(palegreen            ,0x98fb98),
	CSS_COLOR(paleturquoise        ,0xafeeee),
	CSS_COLOR(palevioletred        ,0xdb7093),
	CSS_COLOR(papayawhip           ,0xffefd5),
	CSS_COLOR(peachpuff            ,0xffdab9),
	CSS_COLOR(peru                 ,0xcd853f),
	CSS_COLOR(pink                 ,0xffc0cb),
	CSS_COLOR(plum                 ,0xdda0dd),
	CSS_COLOR(powderblue           ,0xb0e0e6),
	CSS_COLOR(purple               ,0x800080),
	CSS_COLOR(red                  ,0xff0000),
	CSS_COLOR(rosybrown            ,0xbc8f8f),
	CSS_COLOR(royalblue            ,0x4169e1),
	CSS_COLOR(saddlebrown          ,0x8b4513),
	CSS_COLOR(salmon               ,0xfa8072),
	CSS_COLOR(sandybrown           ,0xf4a460),
	CSS_COLOR(seagreen             ,0x2e8b57),
	CSS_COLOR(seashell             ,0xfff5ee),
	CSS_COLOR(sienna               ,0xa0522d),
	CSS_COLOR(silver               ,0xc0c0c0),
	CSS_COLOR(skyblue              ,0x87ceeb),
	CSS_COLOR(slateblue            ,0x6a5acd),
	CSS_COLOR(slategray            ,0x708090),
	CSS_COLOR(slategrey            ,0x708090),
	CSS_COLOR(snow                 ,0xfffafa),
	CSS_COLOR(springgreen          ,0x00ff7f),
	CSS_COLOR(steelblue            ,0x4682b4),
	CSS_COLOR(tan                  ,0xd2b48c),
	CSS_COLOR(teal                 ,0x008080),
	CSS_COLOR(thistle              ,0xd8bfd8),
	CSS_COLOR(tomato               ,0xff6347),
	CSS_COLOR(turquoise            ,0x40e0d0),
	CSS_COLOR(violet               ,0xee82ee),
	CSS_COLOR(wheat                ,0xf5deb3),
	CSS_COLOR(white                ,0xffffff),
	CSS_COLOR(whitesmoke           ,0xf5f5f5),
	CSS_COLOR(yellow               ,0xffff00),
	CSS_COLOR(yellowgreen          ,0x9acd32),
	{nullptr, 0}
};
// clang-format on

#undef CSS_COLOR


PIColorCollection & PIColorCollection::instance() {
	static PIColorCollection ret;
	return ret;
}


PIColorCollection::PIColorCollection() {
	CSSColor * c = css_colors;
	while (c->name) {
		PIVariantTypes::Color col(c->color | 0xFF000000);
		css_color[c->name] = col;
		css_name[col]      = c->name;
		++c;
	}
}
