Skip to content

Commit

Permalink
Update graphanimator.cpp
Browse files Browse the repository at this point in the history
Fix keyTimes and add missing "d" attribute for path when exporting SVG.

Fix #165
  • Loading branch information
rodlie committed May 25, 2024
1 parent bbe85ee commit 05563a1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/core/Animators/graphanimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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(';'));
Expand Down

0 comments on commit 05563a1

Please sign in to comment.