diff --git a/src/spline.cpp b/src/spline.cpp index 395bac084..ed7353f1c 100644 --- a/src/spline.cpp +++ b/src/spline.cpp @@ -71,7 +71,7 @@ std::string Spline::EncodeToAss() const { result += "m "; last = 'm'; } - result += ToScript(pt.p1).DStr(' '); + result += ToScript(pt.p1).Str(' '); break; case SplineCurve::LINE: @@ -79,7 +79,7 @@ std::string Spline::EncodeToAss() const { result += "l "; last = 'l'; } - result += ToScript(pt.p2).DStr(' '); + result += ToScript(pt.p2).Str(' '); break; case SplineCurve::BICUBIC: @@ -87,9 +87,9 @@ std::string Spline::EncodeToAss() const { result += "b "; last = 'b'; } - result += ToScript(pt.p2).DStr(' ') + " "; - result += ToScript(pt.p3).DStr(' ') + " "; - result += ToScript(pt.p4).DStr(' '); + result += ToScript(pt.p2).Str(' ') + " "; + result += ToScript(pt.p3).Str(' ') + " "; + result += ToScript(pt.p4).Str(' '); break; default: break; diff --git a/src/utils.cpp b/src/utils.cpp index a014b0a29..f6a705fa7 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -76,8 +76,9 @@ wxString PrettySize(int bytes) { return agi::wxformat(fmt, size) + " " + suffix[i]; } -std::string float_to_string(double val) { - std::string s = agi::format("%.3f", val); +std::string float_to_string(double val, int precision) { + std::string fmt = "%." + std::to_string(precision) + "f"; + std::string s = agi::format(fmt, val); size_t pos = s.find_last_not_of("0"); if (pos != s.find(".")) ++pos; s.erase(begin(s) + pos, end(s)); diff --git a/src/utils.h b/src/utils.h index 02ef78aac..bb82570d6 100644 --- a/src/utils.h +++ b/src/utils.h @@ -44,7 +44,7 @@ class wxWindow; wxString PrettySize(int bytes); -std::string float_to_string(double val); +std::string float_to_string(double val, int precision = 3); /// @brief Get the smallest power of two that is greater or equal to x /// diff --git a/src/vector2d.cpp b/src/vector2d.cpp index 8bb81de3c..92dca1fd8 100644 --- a/src/vector2d.cpp +++ b/src/vector2d.cpp @@ -88,5 +88,5 @@ std::string Vector2D::DStr(char sep) const { } std::string Vector2D::Str(char sep) const { - return float_to_string(x) + sep + float_to_string(y); + return float_to_string(x,2) + sep + float_to_string(y,2); } diff --git a/src/visual_tool.cpp b/src/visual_tool.cpp index 61d320722..965c2956a 100644 --- a/src/visual_tool.cpp +++ b/src/visual_tool.cpp @@ -504,11 +504,11 @@ std::string VisualToolBase::GetLineVectorClip(AssDialogue *diag, int &scale, boo tag = find_tag(blocks, "\\clip"); if (tag && tag->size() == 4) { - return agi::format("m %d %d l %d %d %d %d %d %d" - , (*tag)[0].Get(), (*tag)[1].Get() - , (*tag)[2].Get(), (*tag)[1].Get() - , (*tag)[2].Get(), (*tag)[3].Get() - , (*tag)[0].Get(), (*tag)[3].Get()); + return agi::format("m %.2f %.2f l %.2f %.2f %.2f %.2f %.2f %.2f" + , (*tag)[0].Get(), (*tag)[1].Get() + , (*tag)[2].Get(), (*tag)[1].Get() + , (*tag)[2].Get(), (*tag)[3].Get() + , (*tag)[0].Get(), (*tag)[3].Get()); } if (tag) { scale = std::max((*tag)[0].Get(scale), 1);