Skip to content

Commit 5e87724

Browse files
committed
1 parent 7bdb3eb commit 5e87724

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

csscolorparser.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <cmath>
3131
#include <algorithm>
3232

33-
using namespace CSSColorParser;
33+
namespace CSSColorParser {
3434

3535
// http://www.w3.org/TR/css3-color/
3636
struct NamedColor { const char *const name; const Color color; };
@@ -116,7 +116,7 @@ const size_t namedColorCount = sizeof (namedColors) / sizeof (NamedColor);
116116

117117
template <typename T>
118118
uint8_t clamp_css_byte(T i) { // Clamp to integer 0 .. 255.
119-
i = std::round(i); // Seems to be what Chrome does (vs truncation).
119+
i = ::round(i); // Seems to be what Chrome does (vs truncation).
120120
return i < 0 ? 0 : i > 255 ? 255 : i;
121121
}
122122

@@ -180,7 +180,7 @@ std::vector<std::string> split(const std::string& s, char delim) {
180180
return elems;
181181
}
182182

183-
Color CSSColorParser::parse(const std::string& css_str) {
183+
Color parse(const std::string& css_str) {
184184
std::string str = css_str;
185185

186186
// Remove all whitespace, not compliant, but should just be more accepting.
@@ -288,3 +288,5 @@ Color CSSColorParser::parse(const std::string& css_str) {
288288

289289
return {};
290290
}
291+
292+
} // namespace CSSColorParser

csscolorparser.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ namespace CSSColorParser {
3131

3232
struct Color {
3333
inline Color() {}
34-
inline Color(unsigned char r, unsigned char g, unsigned char b, float a)
35-
: r(r), g(g), b(b), a(a) {}
34+
inline Color(unsigned char r_, unsigned char g_, unsigned char b_, float a_)
35+
: r(r_), g(g_), b(b_), a(a_) {}
3636
unsigned char r = 0, g = 0, b = 0;
3737
float a = 1.0f;
3838
};

0 commit comments

Comments
 (0)