Skip to content

Commit

Permalink
Fix color opacity and shape scale
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangfitus committed Nov 6, 2023
1 parent ebe956b commit 50b3706
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions src/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@ sf::Color Parser::parseColor(pugi::xml_node node, std::string name) {
for (auto& c : color) c = tolower(c);
if (color == "none")
return sf::Color::Transparent;
else if (color.find("rgb") == std::string::npos) {
auto color_code = color_map.find(color);
if (color_code == color_map.end()) exit(-1);
return color_code->second;
} else {
unsigned int r = 0, g = 0, b = 0, a;
sscanf(color.c_str(), "rgb(%u,%u,%u)", &r, &g, &b);
a = stof(getAttribute(node, name + "-opacity")) * 255;
return sf::Color(r, g, b, a);
else {
sf::Color result;
if (color.find("rgb") == std::string::npos) {
auto color_code = color_map.find(color);
if (color_code == color_map.end()) exit(-1);
result = color_code->second;
} else
sscanf(color.c_str(), "rgb(%u,%u,%u)", &result.r, &result.g,
&result.b);

result.a = stof(getAttribute(node, name + "-opacity")) * 255;
return result;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/graphics/Circle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define CIRCLE_HPP_

#include "Shape.hpp"
#define SCALE 1000000
#define SCALE 100000

class Circle : public Shape {
private:
Expand Down

0 comments on commit 50b3706

Please sign in to comment.