From 05563a188640e8ee0cc37c4de4805c00006340a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Sun, 26 May 2024 00:30:49 +0200 Subject: [PATCH] Update graphanimator.cpp Fix keyTimes and add missing "d" attribute for path when exporting SVG. Fix #165 --- src/core/Animators/graphanimator.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/Animators/graphanimator.cpp b/src/core/Animators/graphanimator.cpp index 00d597e04..c54dc0449 100644 --- a/src/core/Animators/graphanimator.cpp +++ b/src/core/Animators/graphanimator.cpp @@ -570,7 +570,7 @@ void GraphAnimator::graph_saveSVG(SvgExporter& exp, } const int prevRelFrame = prevKey->getRelFrame(); const qreal t = (prevRelFrame - relRange.fMin)/div; - keyTimes << QString::number(t); + keyTimes << QString::number(t).replace("-", ""); values << valueGetter(prevRelFrame); } const auto xSeg = getGraphXSegment(prevKey, nextKey); @@ -595,7 +595,7 @@ void GraphAnimator::graph_saveSVG(SvgExporter& exp, arg(xKeySplines.c2()).arg(yC2); const qreal relFrame = subSeg.first.p1(); const qreal t = (relFrame - relRange.fMin)/div; - keyTimes << QString::number(t); + keyTimes << QString::number(t).replace("-", ""); values << valueGetter(relFrame); } if(nextKeyRelFrame >= visRange.fMax) break; @@ -608,6 +608,11 @@ void GraphAnimator::graph_saveSVG(SvgExporter& exp, values << valueGetter(visRange.fMax); } + // https://github.com/friction2d/friction/issues/165 + if (parent.tagName() == "path" && !parent.hasAttribute("d")) { + parent.setAttribute("d", "M0 0"); + } + anim.setAttribute("calcMode", "spline"); anim.setAttribute("values", values.join(';')); anim.setAttribute("keyTimes", keyTimes.join(';'));