Skip to content

Commit b8236e7

Browse files
committed
Merge pull request #1345 from mgreter/feature/static-color-maps
Implement color maps as static object
2 parents 451980e + 26c0a58 commit b8236e7

File tree

12 files changed

+525
-378
lines changed

12 files changed

+525
-378
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ SOURCES = \
156156
ast.cpp \
157157
base64vlq.cpp \
158158
bind.cpp \
159+
color_maps.cpp \
159160
constants.cpp \
160161
context.cpp \
161162
cssize.cpp \

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ libsass_la_SOURCES = \
4444
ast.cpp ast.hpp \
4545
base64vlq.cpp base64vlq.hpp \
4646
bind.cpp bind.hpp \
47+
color_maps.cpp color_maps.hpp \
4748
constants.cpp constants.hpp \
4849
context.cpp context.hpp \
4950
environment.cpp environment.hpp \

color_maps.cpp

Lines changed: 326 additions & 0 deletions
Large diffs are not rendered by default.

color_maps.hpp

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
#ifndef SASS_COLOR_MAPS_H
2+
#define SASS_COLOR_MAPS_H
3+
4+
#include <map>
5+
#include "ast.hpp"
6+
7+
namespace Sass {
8+
9+
namespace Colors {
10+
static Color aliceblue(ParserState("[COLOR TABLE]"), 240, 248, 255, 1);
11+
static Color antiquewhite(ParserState("[COLOR TABLE]"), 250, 235, 215, 1);
12+
static Color cyan(ParserState("[COLOR TABLE]"), 0, 255, 255, 1);
13+
static Color aqua(ParserState("[COLOR TABLE]"), 0, 255, 255, 1);
14+
static Color aquamarine(ParserState("[COLOR TABLE]"), 127, 255, 212, 1);
15+
static Color azure(ParserState("[COLOR TABLE]"), 240, 255, 255, 1);
16+
static Color beige(ParserState("[COLOR TABLE]"), 245, 245, 220, 1);
17+
static Color bisque(ParserState("[COLOR TABLE]"), 255, 228, 196, 1);
18+
static Color black(ParserState("[COLOR TABLE]"), 0, 0, 0, 1);
19+
static Color blanchedalmond(ParserState("[COLOR TABLE]"), 255, 235, 205, 1);
20+
static Color blue(ParserState("[COLOR TABLE]"), 0, 0, 255, 1);
21+
static Color blueviolet(ParserState("[COLOR TABLE]"), 138, 43, 226, 1);
22+
static Color brown(ParserState("[COLOR TABLE]"), 165, 42, 42, 1);
23+
static Color burlywood(ParserState("[COLOR TABLE]"), 222, 184, 135, 1);
24+
static Color cadetblue(ParserState("[COLOR TABLE]"), 95, 158, 160, 1);
25+
static Color chartreuse(ParserState("[COLOR TABLE]"), 127, 255, 0, 1);
26+
static Color chocolate(ParserState("[COLOR TABLE]"), 210, 105, 30, 1);
27+
static Color coral(ParserState("[COLOR TABLE]"), 255, 127, 80, 1);
28+
static Color cornflowerblue(ParserState("[COLOR TABLE]"), 100, 149, 237, 1);
29+
static Color cornsilk(ParserState("[COLOR TABLE]"), 255, 248, 220, 1);
30+
static Color crimson(ParserState("[COLOR TABLE]"), 220, 20, 60, 1);
31+
static Color darkblue(ParserState("[COLOR TABLE]"), 0, 0, 139, 1);
32+
static Color darkcyan(ParserState("[COLOR TABLE]"), 0, 139, 139, 1);
33+
static Color darkgoldenrod(ParserState("[COLOR TABLE]"), 184, 134, 11, 1);
34+
static Color darkgray(ParserState("[COLOR TABLE]"), 169, 169, 169, 1);
35+
static Color darkgrey(ParserState("[COLOR TABLE]"), 169, 169, 169, 1);
36+
static Color darkgreen(ParserState("[COLOR TABLE]"), 0, 100, 0, 1);
37+
static Color darkkhaki(ParserState("[COLOR TABLE]"), 189, 183, 107, 1);
38+
static Color darkmagenta(ParserState("[COLOR TABLE]"), 139, 0, 139, 1);
39+
static Color darkolivegreen(ParserState("[COLOR TABLE]"), 85, 107, 47, 1);
40+
static Color darkorange(ParserState("[COLOR TABLE]"), 255, 140, 0, 1);
41+
static Color darkorchid(ParserState("[COLOR TABLE]"), 153, 50, 204, 1);
42+
static Color darkred(ParserState("[COLOR TABLE]"), 139, 0, 0, 1);
43+
static Color darksalmon(ParserState("[COLOR TABLE]"), 233, 150, 122, 1);
44+
static Color darkseagreen(ParserState("[COLOR TABLE]"), 143, 188, 143, 1);
45+
static Color darkslateblue(ParserState("[COLOR TABLE]"), 72, 61, 139, 1);
46+
static Color darkslategray(ParserState("[COLOR TABLE]"), 47, 79, 79, 1);
47+
static Color darkslategrey(ParserState("[COLOR TABLE]"), 47, 79, 79, 1);
48+
static Color darkturquoise(ParserState("[COLOR TABLE]"), 0, 206, 209, 1);
49+
static Color darkviolet(ParserState("[COLOR TABLE]"), 148, 0, 211, 1);
50+
static Color deeppink(ParserState("[COLOR TABLE]"), 255, 20, 147, 1);
51+
static Color deepskyblue(ParserState("[COLOR TABLE]"), 0, 191, 255, 1);
52+
static Color dimgray(ParserState("[COLOR TABLE]"), 105, 105, 105, 1);
53+
static Color dimgrey(ParserState("[COLOR TABLE]"), 105, 105, 105, 1);
54+
static Color dodgerblue(ParserState("[COLOR TABLE]"), 30, 144, 255, 1);
55+
static Color firebrick(ParserState("[COLOR TABLE]"), 178, 34, 34, 1);
56+
static Color floralwhite(ParserState("[COLOR TABLE]"), 255, 250, 240, 1);
57+
static Color forestgreen(ParserState("[COLOR TABLE]"), 34, 139, 34, 1);
58+
static Color magenta(ParserState("[COLOR TABLE]"), 255, 0, 255, 1);
59+
static Color fuchsia(ParserState("[COLOR TABLE]"), 255, 0, 255, 1);
60+
static Color gainsboro(ParserState("[COLOR TABLE]"), 220, 220, 220, 1);
61+
static Color ghostwhite(ParserState("[COLOR TABLE]"), 248, 248, 255, 1);
62+
static Color gold(ParserState("[COLOR TABLE]"), 255, 215, 0, 1);
63+
static Color goldenrod(ParserState("[COLOR TABLE]"), 218, 165, 32, 1);
64+
static Color gray(ParserState("[COLOR TABLE]"), 128, 128, 128, 1);
65+
static Color grey(ParserState("[COLOR TABLE]"), 128, 128, 128, 1);
66+
static Color green(ParserState("[COLOR TABLE]"), 0, 128, 0, 1);
67+
static Color greenyellow(ParserState("[COLOR TABLE]"), 173, 255, 47, 1);
68+
static Color honeydew(ParserState("[COLOR TABLE]"), 240, 255, 240, 1);
69+
static Color hotpink(ParserState("[COLOR TABLE]"), 255, 105, 180, 1);
70+
static Color indianred(ParserState("[COLOR TABLE]"), 205, 92, 92, 1);
71+
static Color indigo(ParserState("[COLOR TABLE]"), 75, 0, 130, 1);
72+
static Color ivory(ParserState("[COLOR TABLE]"), 255, 255, 240, 1);
73+
static Color khaki(ParserState("[COLOR TABLE]"), 240, 230, 140, 1);
74+
static Color lavender(ParserState("[COLOR TABLE]"), 230, 230, 250, 1);
75+
static Color lavenderblush(ParserState("[COLOR TABLE]"), 255, 240, 245, 1);
76+
static Color lawngreen(ParserState("[COLOR TABLE]"), 124, 252, 0, 1);
77+
static Color lemonchiffon(ParserState("[COLOR TABLE]"), 255, 250, 205, 1);
78+
static Color lightblue(ParserState("[COLOR TABLE]"), 173, 216, 230, 1);
79+
static Color lightcoral(ParserState("[COLOR TABLE]"), 240, 128, 128, 1);
80+
static Color lightcyan(ParserState("[COLOR TABLE]"), 224, 255, 255, 1);
81+
static Color lightgoldenrodyellow(ParserState("[COLOR TABLE]"), 250, 250, 210, 1);
82+
static Color lightgray(ParserState("[COLOR TABLE]"), 211, 211, 211, 1);
83+
static Color lightgrey(ParserState("[COLOR TABLE]"), 211, 211, 211, 1);
84+
static Color lightgreen(ParserState("[COLOR TABLE]"), 144, 238, 144, 1);
85+
static Color lightpink(ParserState("[COLOR TABLE]"), 255, 182, 193, 1);
86+
static Color lightsalmon(ParserState("[COLOR TABLE]"), 255, 160, 122, 1);
87+
static Color lightseagreen(ParserState("[COLOR TABLE]"), 32, 178, 170, 1);
88+
static Color lightskyblue(ParserState("[COLOR TABLE]"), 135, 206, 250, 1);
89+
static Color lightslategray(ParserState("[COLOR TABLE]"), 119, 136, 153, 1);
90+
static Color lightslategrey(ParserState("[COLOR TABLE]"), 119, 136, 153, 1);
91+
static Color lightsteelblue(ParserState("[COLOR TABLE]"), 176, 196, 222, 1);
92+
static Color lightyellow(ParserState("[COLOR TABLE]"), 255, 255, 224, 1);
93+
static Color lime(ParserState("[COLOR TABLE]"), 0, 255, 0, 1);
94+
static Color limegreen(ParserState("[COLOR TABLE]"), 50, 205, 50, 1);
95+
static Color linen(ParserState("[COLOR TABLE]"), 250, 240, 230, 1);
96+
static Color maroon(ParserState("[COLOR TABLE]"), 128, 0, 0, 1);
97+
static Color mediumaquamarine(ParserState("[COLOR TABLE]"), 102, 205, 170, 1);
98+
static Color mediumblue(ParserState("[COLOR TABLE]"), 0, 0, 205, 1);
99+
static Color mediumorchid(ParserState("[COLOR TABLE]"), 186, 85, 211, 1);
100+
static Color mediumpurple(ParserState("[COLOR TABLE]"), 147, 112, 219, 1);
101+
static Color mediumseagreen(ParserState("[COLOR TABLE]"), 60, 179, 113, 1);
102+
static Color mediumslateblue(ParserState("[COLOR TABLE]"), 123, 104, 238, 1);
103+
static Color mediumspringgreen(ParserState("[COLOR TABLE]"), 0, 250, 154, 1);
104+
static Color mediumturquoise(ParserState("[COLOR TABLE]"), 72, 209, 204, 1);
105+
static Color mediumvioletred(ParserState("[COLOR TABLE]"), 199, 21, 133, 1);
106+
static Color midnightblue(ParserState("[COLOR TABLE]"), 25, 25, 112, 1);
107+
static Color mintcream(ParserState("[COLOR TABLE]"), 245, 255, 250, 1);
108+
static Color mistyrose(ParserState("[COLOR TABLE]"), 255, 228, 225, 1);
109+
static Color moccasin(ParserState("[COLOR TABLE]"), 255, 228, 181, 1);
110+
static Color navajowhite(ParserState("[COLOR TABLE]"), 255, 222, 173, 1);
111+
static Color navy(ParserState("[COLOR TABLE]"), 0, 0, 128, 1);
112+
static Color oldlace(ParserState("[COLOR TABLE]"), 253, 245, 230, 1);
113+
static Color olive(ParserState("[COLOR TABLE]"), 128, 128, 0, 1);
114+
static Color olivedrab(ParserState("[COLOR TABLE]"), 107, 142, 35, 1);
115+
static Color orange(ParserState("[COLOR TABLE]"), 255, 165, 0, 1);
116+
static Color orangered(ParserState("[COLOR TABLE]"), 255, 69, 0, 1);
117+
static Color orchid(ParserState("[COLOR TABLE]"), 218, 112, 214, 1);
118+
static Color palegoldenrod(ParserState("[COLOR TABLE]"), 238, 232, 170, 1);
119+
static Color palegreen(ParserState("[COLOR TABLE]"), 152, 251, 152, 1);
120+
static Color paleturquoise(ParserState("[COLOR TABLE]"), 175, 238, 238, 1);
121+
static Color palevioletred(ParserState("[COLOR TABLE]"), 219, 112, 147, 1);
122+
static Color papayawhip(ParserState("[COLOR TABLE]"), 255, 239, 213, 1);
123+
static Color peachpuff(ParserState("[COLOR TABLE]"), 255, 218, 185, 1);
124+
static Color peru(ParserState("[COLOR TABLE]"), 205, 133, 63, 1);
125+
static Color pink(ParserState("[COLOR TABLE]"), 255, 192, 203, 1);
126+
static Color plum(ParserState("[COLOR TABLE]"), 221, 160, 221, 1);
127+
static Color powderblue(ParserState("[COLOR TABLE]"), 176, 224, 230, 1);
128+
static Color purple(ParserState("[COLOR TABLE]"), 128, 0, 128, 1);
129+
static Color red(ParserState("[COLOR TABLE]"), 255, 0, 0, 1);
130+
static Color rosybrown(ParserState("[COLOR TABLE]"), 188, 143, 143, 1);
131+
static Color royalblue(ParserState("[COLOR TABLE]"), 65, 105, 225, 1);
132+
static Color saddlebrown(ParserState("[COLOR TABLE]"), 139, 69, 19, 1);
133+
static Color salmon(ParserState("[COLOR TABLE]"), 250, 128, 114, 1);
134+
static Color sandybrown(ParserState("[COLOR TABLE]"), 244, 164, 96, 1);
135+
static Color seagreen(ParserState("[COLOR TABLE]"), 46, 139, 87, 1);
136+
static Color seashell(ParserState("[COLOR TABLE]"), 255, 245, 238, 1);
137+
static Color sienna(ParserState("[COLOR TABLE]"), 160, 82, 45, 1);
138+
static Color silver(ParserState("[COLOR TABLE]"), 192, 192, 192, 1);
139+
static Color skyblue(ParserState("[COLOR TABLE]"), 135, 206, 235, 1);
140+
static Color slateblue(ParserState("[COLOR TABLE]"), 106, 90, 205, 1);
141+
static Color slategray(ParserState("[COLOR TABLE]"), 112, 128, 144, 1);
142+
static Color slategrey(ParserState("[COLOR TABLE]"), 112, 128, 144, 1);
143+
static Color snow(ParserState("[COLOR TABLE]"), 255, 250, 250, 1);
144+
static Color springgreen(ParserState("[COLOR TABLE]"), 0, 255, 127, 1);
145+
static Color steelblue(ParserState("[COLOR TABLE]"), 70, 130, 180, 1);
146+
static Color tan(ParserState("[COLOR TABLE]"), 210, 180, 140, 1);
147+
static Color teal(ParserState("[COLOR TABLE]"), 0, 128, 128, 1);
148+
static Color thistle(ParserState("[COLOR TABLE]"), 216, 191, 216, 1);
149+
static Color tomato(ParserState("[COLOR TABLE]"), 255, 99, 71, 1);
150+
static Color turquoise(ParserState("[COLOR TABLE]"), 64, 224, 208, 1);
151+
static Color violet(ParserState("[COLOR TABLE]"), 238, 130, 238, 1);
152+
static Color wheat(ParserState("[COLOR TABLE]"), 245, 222, 179, 1);
153+
static Color white(ParserState("[COLOR TABLE]"), 255, 255, 255, 1);
154+
static Color whitesmoke(ParserState("[COLOR TABLE]"), 245, 245, 245, 1);
155+
static Color yellow(ParserState("[COLOR TABLE]"), 255, 255, 0, 1);
156+
static Color yellowgreen(ParserState("[COLOR TABLE]"), 154, 205, 50, 1);
157+
static Color rebeccapurple(ParserState("[COLOR TABLE]"), 102, 51, 153, 1);
158+
static Color transparent(ParserState("[COLOR TABLE]"), 0, 0, 0, 0);
159+
}
160+
161+
extern const std::map<const int, const std::string> colors_to_names;
162+
extern const std::map<const std::string, Color*> names_to_colors;
163+
164+
extern Color* name_to_color(const std::string);
165+
extern const char* color_to_name(int key);
166+
extern const char* color_to_name(const Color*);
167+
168+
}
169+
170+
#endif

0 commit comments

Comments
 (0)