From 3807e438c5da9c30a20811d323d31041caf0e177 Mon Sep 17 00:00:00 2001 From: TennesseeTrash Date: Sun, 8 Jun 2025 16:47:41 +0200 Subject: [PATCH 1/4] Small improvements in group naming --- Libraries/Kanimaji/Source/Kanimaji.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Libraries/Kanimaji/Source/Kanimaji.cpp b/Libraries/Kanimaji/Source/Kanimaji.cpp index 7869e94..fb9d476 100644 --- a/Libraries/Kanimaji/Source/Kanimaji.cpp +++ b/Libraries/Kanimaji/Source/Kanimaji.cpp @@ -124,9 +124,9 @@ namespace Kanimaji std::string brushKeyframes; std::string brushProgress; - auto background = AppendGroup(svg, "kvg:Kanimaji_Stroke_Background_" + baseId, + auto background = AppendGroup(svg, "kvg:Kanimaji_StrokeBackground_" + baseId, settings.UnfilledStroke); - auto brushBorder = AppendGroup(svg, "kvg:Kanimaji_Brush_Border_" + baseId, + auto brushBorder = AppendGroup(svg, "kvg:Kanimaji_BrushBorder_" + baseId, settings.BrushBorder); auto animation = AppendGroup(svg, "kvg:Kanimaji_Animation_" + baseId, settings.FilledStroke); @@ -138,6 +138,7 @@ namespace Kanimaji - AsSeconds(settings.DelayBetweenStrokes); double previousLength = 0.0; double currentLength = 0.0; + // 2nd pass to prepare the CSS for (const auto& path : paths) { std::string_view d = path.node().attribute("d").as_string(); @@ -217,7 +218,7 @@ namespace Kanimaji styles.append(brushProgress); styles.append(" "); pugi::xml_node style = svg.prepend_child("style"); - style.append_attribute("id") = "kvg:Kanimaji_Style"; + style.append_attribute("id") = "kvg:Kanimaji_Styles_" + baseId; style.append_child(pugi::node_pcdata).set_value(styles); } } From 6c784abd5de0a470fa3b05f9e7596b05c6ae1dcb Mon Sep 17 00:00:00 2001 From: TennesseeTrash Date: Sun, 8 Jun 2025 18:29:41 +0200 Subject: [PATCH 2/4] Make sure FetchContent targets are replaceable --- CMake/ctre.cmake | 20 +++++++++++--------- CMake/pugixml.cmake | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CMake/ctre.cmake b/CMake/ctre.cmake index 8cc43ce..6706f42 100644 --- a/CMake/ctre.cmake +++ b/CMake/ctre.cmake @@ -1,11 +1,13 @@ -include(FetchContent) +if(NOT TARGET pugixml) + include(FetchContent) -FetchContent_Declare( - ctre - GIT_REPOSITORY https://code.3011.io/Mirrors/compile-time-regular-expressions - GIT_TAG v3.10.0 -) + FetchContent_Declare( + ctre + GIT_REPOSITORY https://code.3011.io/Mirrors/compile-time-regular-expressions + GIT_TAG v3.10.0 + ) -FetchContent_MakeAvailable( - ctre -) + FetchContent_MakeAvailable( + ctre + ) +endif() diff --git a/CMake/pugixml.cmake b/CMake/pugixml.cmake index f7df319..fd5f750 100644 --- a/CMake/pugixml.cmake +++ b/CMake/pugixml.cmake @@ -1,11 +1,13 @@ -include(FetchContent) +if(NOT TARGET pugixml) + include(FetchContent) -FetchContent_Declare( - pugixml - GIT_REPOSITORY https://code.3011.io/Mirrors/pugixml - GIT_TAG v1.15 -) + FetchContent_Declare( + pugixml + GIT_REPOSITORY https://code.3011.io/Mirrors/pugixml + GIT_TAG v1.15 + ) -FetchContent_MakeAvailable( - pugixml -) + FetchContent_MakeAvailable( + pugixml + ) +endif() From 0fcb1d62df6005a2d933fd373b955c542311cef7 Mon Sep 17 00:00:00 2001 From: TennesseeTrash Date: Sun, 8 Jun 2025 18:36:49 +0200 Subject: [PATCH 3/4] Report the actual error --- Tools/KanimajiTool/Main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/KanimajiTool/Main.cpp b/Tools/KanimajiTool/Main.cpp index ca7cb91..383d717 100644 --- a/Tools/KanimajiTool/Main.cpp +++ b/Tools/KanimajiTool/Main.cpp @@ -16,7 +16,7 @@ int main(const int argc, const char *argv[]) Kanimaji::AnimateFile(argv[1], argv[2]); } catch (const std::exception& e) { - std::println("Could not animate {}: {}", argv[1], argv[2]); + std::println("Could not animate {}: {}", argv[1], e.what()); return 1; } From 4570c93837136bafe499b6dcf5bab0c9371afa13 Mon Sep 17 00:00:00 2001 From: TennesseeTrash Date: Sun, 8 Jun 2025 18:37:09 +0200 Subject: [PATCH 4/4] Add check when removing the baseId prefix --- Libraries/Kanimaji/Source/Kanimaji.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Libraries/Kanimaji/Source/Kanimaji.cpp b/Libraries/Kanimaji/Source/Kanimaji.cpp index fb9d476..27cdadd 100644 --- a/Libraries/Kanimaji/Source/Kanimaji.cpp +++ b/Libraries/Kanimaji/Source/Kanimaji.cpp @@ -103,12 +103,14 @@ namespace Kanimaji return std::string_view(node.attribute("id").as_string()).contains("StrokeNumbers"); })); - pugi::xml_node pathsContainer = svg.find_child([](pugi::xml_node& node) { + pugi::xml_node pathsGroup = svg.find_child([](pugi::xml_node& node) { return std::string_view(node.attribute("id").as_string()).contains("StrokePaths"); }); - pathsContainer.attribute("style") = "fill:none;visibility:hidden;"; - std::string baseId = pathsContainer.attribute("id").as_string(); - baseId.erase(0, baseId.find('_') + 1); + pathsGroup.attribute("style") = "fill:none;visibility:hidden;"; + std::string baseId = pathsGroup.attribute("id").as_string(); + if (auto pos = baseId.find('_'); pos != baseId.npos) { + baseId.erase(0, pos + 1); + } // 1st pass for getting information double totalLength = 0.0; @@ -159,8 +161,8 @@ namespace Kanimaji std::string id = idAttr.as_string(); std::string css = id; - if (auto colonPos = css.find(':'); colonPos != css.npos) { - css.replace(css.find(":"), 1, "\\:"); + if (auto pos = css.find(':'); pos != css.npos) { + css.replace(pos, 1, "\\:"); } std::string pathId = id;