Skip to content

Commit

Permalink
Fix parse points, and color range
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangfitus committed Dec 6, 2023
1 parent 30e1b7f commit 0b41a46
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
9 changes: 3 additions & 6 deletions src/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,10 @@ std::vector< Vector2Df > Parser::parsePoints(xml_node<> *node) {

std::stringstream ss(points_string);
float x, y;
char comma;

while (ss >> x >> comma >> y) {
if (comma != ',') {
std::string y_str = comma + std::to_string(y);
y = std::stof(y_str);
}
while (ss >> x) {
if (ss.peek() == ',') ss.ignore();
ss >> y;
points.push_back(Vector2Df(x, y));
}

Expand Down
8 changes: 7 additions & 1 deletion src/graphics/Color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ const mColor mColor::Transparent(0, 0, 0, 0);
mColor::mColor() : r(0), g(0), b(0), a(255) {}

mColor::mColor(int red, int green, int blue, int alpha)
: r(red), g(green), b(blue), a(alpha) {}
: r(red), g(green), b(blue), a(alpha) {
if (r < 0) {
r = 0;
} else if (r > 255) {
r = 255;
}
}

mColor::mColor(int color)
: r(static_cast< int >((color & 0xff000000) >> 24)),
Expand Down
1 change: 0 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ void OnPaint(HDC hdc, const std::string& filePath, Viewer& viewer) {
graphics.ScaleTransform(viewer.zoomFactor, viewer.zoomFactor);
graphics.TranslateTransform(viewer.offsetX, viewer.offsetY);
graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
graphics.SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias);
graphics.SetTextContrast(100);
graphics.SetCompositingMode(Gdiplus::CompositingModeSourceOver);
graphics.SetPixelOffsetMode(Gdiplus::PixelOffsetModeHighQuality);
Expand Down

0 comments on commit 0b41a46

Please sign in to comment.