Skip to content

Commit 77a5430

Browse files
committed
add Color.getInt()
1 parent b95f7d5 commit 77a5430

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

csscolorparser.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,11 @@ void skip_whitespace(const std::string& text, size_t& pos, size_t end){
268268
}
269269
}
270270

271+
uint32_t CSSColorParser::Color::getInt() {
272+
uint32_t color = ((uint32_t)(255.0 * a) << 24) + ((uint32_t)b << 16) + ((uint32_t)g << 8) + ((uint32_t)r);
273+
return color;
274+
}
275+
271276
Color CSSColorParser::parse(const std::string& css_str) {
272277
bool valid;
273278
return parse(css_str, valid);

csscolorparser.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct Color {
3535
: r(r), g(g), b(b), a(a) {}
3636
unsigned char r = 0, g = 0, b = 0;
3737
float a = 1.0f;
38+
uint32_t getInt();
3839
};
3940

4041

0 commit comments

Comments
 (0)