Skip to content
Open

fmt #141

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ set (trase_headers
src/util/Style.hpp
src/util/Vector.hpp
src/util/CSVDownloader.hpp
src/fmt/core.h
src/fmt/format.h
src/fmt/format-inl.h
)


Expand All @@ -152,6 +155,7 @@ set (trase_source
src/util/Colors.cpp
src/util/Style.cpp
src/util/CSVDownloader.cpp
src/fmt/format.cc
)

if (trase_BUILD_OPENGL)
Expand Down
16 changes: 10 additions & 6 deletions src/backend/BackendSVG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "backend/BackendSVG.hpp"

#include "fmt/format.h"

namespace trase {

BackendSVG::BackendSVG(std::ostream &out) : m_out(out) {
Expand All @@ -54,14 +56,16 @@ void BackendSVG::init(const vfloat2_t &pixels, const char *name,
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
)del";

m_out << "<svg width=\"" << pixels[0] << "px\" height=\"" << pixels[1]
<< "px\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n";
m_out << fmt::format(
R"(<svg width="{}px" height="{}px" version="1.1" xmlns="http://www.w3.org/2000/svg">)",
pixels[0], pixels[1]) << '\n';

m_out << "<desc>" << name << "</desc>\n";
m_out << fmt::format("<desc>{}</desc>\n", name);

if (!m_web_font.empty()) {
m_out << "<style type=\"text/css\">@import url('" + m_web_font +
"');</style>\n";

m_out << fmt::format(R"(<style type="text/css">@import url('{}');</style>)",
m_web_font);
}
m_out << R"del(<script>
function tooltip(x,y,string,size,face) {
Expand Down Expand Up @@ -381,7 +385,7 @@ void BackendSVG::add_animated_rect(const bfloat2_t &x, float time) {
if (m_animate_values.size() < 4) {
m_animate_values.resize(4);
}
m_animate_times = "keyTimes=\"" + std::to_string(time / m_time_span) + ';';
m_animate_times = fmt::format(R"(keyTimes="{:.3f};)", time / m_time_span);
m_animate_values[0] = "values=\"" + std::to_string(min[0]) + ';';
m_animate_values[1] = "values=\"" + std::to_string(min[1]) + ';';
m_animate_values[2] = "values=\"" + std::to_string(delta[0]) + ';';
Expand Down
Loading