From 2c0bb5ae709b6d063d880f739a129f6a159d5b51 Mon Sep 17 00:00:00 2001 From: AndreaGuarracino Date: Wed, 7 Feb 2024 11:19:40 +0100 Subject: [PATCH 1/3] default line width to avoid invisible lines in the SVG --- src/subcommand/draw_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/subcommand/draw_main.cpp b/src/subcommand/draw_main.cpp index 620e69d2..4c5f6ff2 100644 --- a/src/subcommand/draw_main.cpp +++ b/src/subcommand/draw_main.cpp @@ -43,7 +43,7 @@ int main_draw(int argc, char **argv) { args::Flag color_paths(visualizations_opts, "color-paths", "Color paths (in PNG output).", {'C', "color-paths"}); args::ValueFlag render_scale(visualizations_opts, "N", "Image scaling (default 0.001).", {'R', "scale"}); args::ValueFlag render_border(visualizations_opts, "N", "Image border (in approximate bp) (default 100.0).", {'B', "border"}); - args::ValueFlag png_line_width(visualizations_opts, "N", "Line width (in approximate bp) (default 0.0).", {'w', "line-width"}); + args::ValueFlag png_line_width(visualizations_opts, "N", "Line width (in approximate bp) (default 20.0).", {'w', "line-width"}); //args::ValueFlag png_line_overlay(parser, "N", "line width (in approximate bp) (default 10.0)", {'O', "line-overlay"}); args::ValueFlag png_path_line_spacing(visualizations_opts, "N", "Spacing between path lines in PNG layout (in approximate bp) (default 0.0).", {'S', "path-line-spacing"}); args::ValueFlag _path_bed_file(visualizations_opts, "FILE", @@ -171,7 +171,7 @@ int main_draw(int argc, char **argv) { } const uint64_t _png_height = png_height ? args::get(png_height) : 1000; - const double _png_line_width = png_line_width ? args::get(png_line_width) : 0; + const double _png_line_width = png_line_width ? args::get(png_line_width) : 20.0; const bool _color_paths = args::get(color_paths); const double _png_path_line_spacing = png_path_line_spacing ? args::get(png_path_line_spacing) : 0.0; const double svg_scale = !render_scale ? 0.01 : args::get(render_scale); From eb4389fb22802127109c357e33a2169d42dda93e Mon Sep 17 00:00:00 2001 From: AndreaGuarracino Date: Wed, 7 Feb 2024 11:28:29 +0100 Subject: [PATCH 2/3] manage SVG stroke with #RRGGBB to avoid issues with InkScape --- src/algorithms/atomic_image.cpp | 12 +++++++++++- src/algorithms/atomic_image.hpp | 1 + src/algorithms/draw.cpp | 2 +- src/subcommand/draw_main.cpp | 4 ++-- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/algorithms/atomic_image.cpp b/src/algorithms/atomic_image.cpp index 870e2759..255185e1 100644 --- a/src/algorithms/atomic_image.cpp +++ b/src/algorithms/atomic_image.cpp @@ -99,10 +99,20 @@ std::string to_rgba(const color_t& c) { ss << (int)c.c.r << ","; ss << (int)c.c.g << ","; ss << (int)c.c.b << ","; - ss << (int)c.c.a << ")"; + ss << (int)1 << ")"; return ss.str(); } +std::string to_hexrgb(const color_t& c) { + std::stringstream ss; + ss << "#"; + ss << std::hex << std::uppercase; // Use hexadecimal format + ss << std::setfill('0') << std::setw(2) << (int)c.c.r; + ss << std::setfill('0') << std::setw(2) << (int)c.c.g; + ss << std::setfill('0') << std::setw(2) << (int)c.c.b; + return ss.str(); +} + // helpers double u_ipart(double x) { return std::floor(x); } diff --git a/src/algorithms/atomic_image.hpp b/src/algorithms/atomic_image.hpp index 05472902..8a6399ed 100644 --- a/src/algorithms/atomic_image.hpp +++ b/src/algorithms/atomic_image.hpp @@ -95,6 +95,7 @@ color_t mix(const color_t& a, const color_t& b, const double& f); std::string to_hex(const color_t& c); std::string to_rgba(const color_t& c); +std::string to_hexrgb(const color_t& c); const color_t COLOR_BLACK = { 0xff000000 }; const color_t COLOR_LIGHTGRAY = { 0xffD3D3D3 }; diff --git a/src/algorithms/draw.cpp b/src/algorithms/draw.cpp index 7d606c8f..4baed774 100644 --- a/src/algorithms/draw.cpp +++ b/src/algorithms/draw.cpp @@ -149,7 +149,7 @@ void draw_svg(std::ostream &out, << (Y[a] * scale) + y_off << "\" y2=\"" << (Y[a + 1] * scale) + y_off - << "\" stroke=\"" << to_rgba(color) + << "\" stroke=\"" << to_hexrgb(color) //to_rgba(color) // with rgb, nodes are invisible with InkScape << "\" stroke-width=\"" << line_width << "\"/>" << std::endl; diff --git a/src/subcommand/draw_main.cpp b/src/subcommand/draw_main.cpp index 4c5f6ff2..a42e18d6 100644 --- a/src/subcommand/draw_main.cpp +++ b/src/subcommand/draw_main.cpp @@ -43,7 +43,7 @@ int main_draw(int argc, char **argv) { args::Flag color_paths(visualizations_opts, "color-paths", "Color paths (in PNG output).", {'C', "color-paths"}); args::ValueFlag render_scale(visualizations_opts, "N", "Image scaling (default 0.001).", {'R', "scale"}); args::ValueFlag render_border(visualizations_opts, "N", "Image border (in approximate bp) (default 100.0).", {'B', "border"}); - args::ValueFlag png_line_width(visualizations_opts, "N", "Line width (in approximate bp) (default 20.0).", {'w', "line-width"}); + args::ValueFlag png_line_width(visualizations_opts, "N", "Line width (in approximate bp) (default 10.0).", {'w', "line-width"}); //args::ValueFlag png_line_overlay(parser, "N", "line width (in approximate bp) (default 10.0)", {'O', "line-overlay"}); args::ValueFlag png_path_line_spacing(visualizations_opts, "N", "Spacing between path lines in PNG layout (in approximate bp) (default 0.0).", {'S', "path-line-spacing"}); args::ValueFlag _path_bed_file(visualizations_opts, "FILE", @@ -171,7 +171,7 @@ int main_draw(int argc, char **argv) { } const uint64_t _png_height = png_height ? args::get(png_height) : 1000; - const double _png_line_width = png_line_width ? args::get(png_line_width) : 20.0; + const double _png_line_width = png_line_width ? args::get(png_line_width) : 10.0; const bool _color_paths = args::get(color_paths); const double _png_path_line_spacing = png_path_line_spacing ? args::get(png_path_line_spacing) : 0.0; const double svg_scale = !render_scale ? 0.01 : args::get(render_scale); From d46016f4d94b5c7ac4322c82f5e4329f961d85f7 Mon Sep 17 00:00:00 2001 From: AndreaGuarracino Date: Wed, 7 Feb 2024 11:30:03 +0100 Subject: [PATCH 3/3] revert instruction in `to_rgba` --- src/algorithms/atomic_image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/atomic_image.cpp b/src/algorithms/atomic_image.cpp index 255185e1..d7272552 100644 --- a/src/algorithms/atomic_image.cpp +++ b/src/algorithms/atomic_image.cpp @@ -99,7 +99,7 @@ std::string to_rgba(const color_t& c) { ss << (int)c.c.r << ","; ss << (int)c.c.g << ","; ss << (int)c.c.b << ","; - ss << (int)1 << ")"; + ss << (int)c.c.a << ")"; return ss.str(); }