Compare commits
No commits in common. "4570c93837136bafe499b6dcf5bab0c9371afa13" and "99ba5b4fd9d709481f2f5a0b97e0b62a6863d703" have entirely different histories.
4570c93837
...
99ba5b4fd9
4 changed files with 28 additions and 35 deletions
|
@ -1,13 +1,11 @@
|
||||||
if(NOT TARGET pugixml)
|
include(FetchContent)
|
||||||
include(FetchContent)
|
|
||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
ctre
|
ctre
|
||||||
GIT_REPOSITORY https://code.3011.io/Mirrors/compile-time-regular-expressions
|
GIT_REPOSITORY https://code.3011.io/Mirrors/compile-time-regular-expressions
|
||||||
GIT_TAG v3.10.0
|
GIT_TAG v3.10.0
|
||||||
)
|
)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(
|
FetchContent_MakeAvailable(
|
||||||
ctre
|
ctre
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
if(NOT TARGET pugixml)
|
include(FetchContent)
|
||||||
include(FetchContent)
|
|
||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
pugixml
|
pugixml
|
||||||
GIT_REPOSITORY https://code.3011.io/Mirrors/pugixml
|
GIT_REPOSITORY https://code.3011.io/Mirrors/pugixml
|
||||||
GIT_TAG v1.15
|
GIT_TAG v1.15
|
||||||
)
|
)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(
|
FetchContent_MakeAvailable(
|
||||||
pugixml
|
pugixml
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
|
|
|
@ -103,14 +103,12 @@ namespace Kanimaji
|
||||||
return std::string_view(node.attribute("id").as_string()).contains("StrokeNumbers");
|
return std::string_view(node.attribute("id").as_string()).contains("StrokeNumbers");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
pugi::xml_node pathsGroup = svg.find_child([](pugi::xml_node& node) {
|
pugi::xml_node pathsContainer = svg.find_child([](pugi::xml_node& node) {
|
||||||
return std::string_view(node.attribute("id").as_string()).contains("StrokePaths");
|
return std::string_view(node.attribute("id").as_string()).contains("StrokePaths");
|
||||||
});
|
});
|
||||||
pathsGroup.attribute("style") = "fill:none;visibility:hidden;";
|
pathsContainer.attribute("style") = "fill:none;visibility:hidden;";
|
||||||
std::string baseId = pathsGroup.attribute("id").as_string();
|
std::string baseId = pathsContainer.attribute("id").as_string();
|
||||||
if (auto pos = baseId.find('_'); pos != baseId.npos) {
|
baseId.erase(0, baseId.find('_') + 1);
|
||||||
baseId.erase(0, pos + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1st pass for getting information
|
// 1st pass for getting information
|
||||||
double totalLength = 0.0;
|
double totalLength = 0.0;
|
||||||
|
@ -126,9 +124,9 @@ namespace Kanimaji
|
||||||
std::string brushKeyframes;
|
std::string brushKeyframes;
|
||||||
std::string brushProgress;
|
std::string brushProgress;
|
||||||
|
|
||||||
auto background = AppendGroup(svg, "kvg:Kanimaji_StrokeBackground_" + baseId,
|
auto background = AppendGroup(svg, "kvg:Kanimaji_Stroke_Background_" + baseId,
|
||||||
settings.UnfilledStroke);
|
settings.UnfilledStroke);
|
||||||
auto brushBorder = AppendGroup(svg, "kvg:Kanimaji_BrushBorder_" + baseId,
|
auto brushBorder = AppendGroup(svg, "kvg:Kanimaji_Brush_Border_" + baseId,
|
||||||
settings.BrushBorder);
|
settings.BrushBorder);
|
||||||
auto animation = AppendGroup(svg, "kvg:Kanimaji_Animation_" + baseId,
|
auto animation = AppendGroup(svg, "kvg:Kanimaji_Animation_" + baseId,
|
||||||
settings.FilledStroke);
|
settings.FilledStroke);
|
||||||
|
@ -140,7 +138,6 @@ namespace Kanimaji
|
||||||
- AsSeconds(settings.DelayBetweenStrokes);
|
- AsSeconds(settings.DelayBetweenStrokes);
|
||||||
double previousLength = 0.0;
|
double previousLength = 0.0;
|
||||||
double currentLength = 0.0;
|
double currentLength = 0.0;
|
||||||
|
|
||||||
// 2nd pass to prepare the CSS
|
// 2nd pass to prepare the CSS
|
||||||
for (const auto& path : paths) {
|
for (const auto& path : paths) {
|
||||||
std::string_view d = path.node().attribute("d").as_string();
|
std::string_view d = path.node().attribute("d").as_string();
|
||||||
|
@ -161,8 +158,8 @@ namespace Kanimaji
|
||||||
|
|
||||||
std::string id = idAttr.as_string();
|
std::string id = idAttr.as_string();
|
||||||
std::string css = id;
|
std::string css = id;
|
||||||
if (auto pos = css.find(':'); pos != css.npos) {
|
if (auto colonPos = css.find(':'); colonPos != css.npos) {
|
||||||
css.replace(pos, 1, "\\:");
|
css.replace(css.find(":"), 1, "\\:");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string pathId = id;
|
std::string pathId = id;
|
||||||
|
@ -220,7 +217,7 @@ namespace Kanimaji
|
||||||
styles.append(brushProgress);
|
styles.append(brushProgress);
|
||||||
styles.append(" ");
|
styles.append(" ");
|
||||||
pugi::xml_node style = svg.prepend_child("style");
|
pugi::xml_node style = svg.prepend_child("style");
|
||||||
style.append_attribute("id") = "kvg:Kanimaji_Styles_" + baseId;
|
style.append_attribute("id") = "kvg:Kanimaji_Style";
|
||||||
style.append_child(pugi::node_pcdata).set_value(styles);
|
style.append_child(pugi::node_pcdata).set_value(styles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ int main(const int argc, const char *argv[])
|
||||||
Kanimaji::AnimateFile(argv[1], argv[2]);
|
Kanimaji::AnimateFile(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
std::println("Could not animate {}: {}", argv[1], e.what());
|
std::println("Could not animate {}: {}", argv[1], argv[2]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue