Skip to content

Commit

Permalink
TransformEffects: support SVG #173
Browse files Browse the repository at this point in the history
Only 'follow path' is supported.
  • Loading branch information
rodlie committed Aug 27, 2024
1 parent d5d82b5 commit 2f21897
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/core/TransformEffects/followpatheffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "Boxes/pathbox.h"
#include "Animators/qrealanimator.h"
#include "Animators/transformanimator.h"
#include "svgexporter.h"

FollowPathEffect::FollowPathEffect() :
TargetTransformEffect("follow path", TransformEffectType::followPath) {
Expand Down Expand Up @@ -181,3 +182,30 @@ void FollowPathEffect::applyEffect(const qreal relFrame,
posX += posXChange; //p1.x()*infl;
posY += posYChange; //p1.y()*infl;
}

QDomElement FollowPathEffect::saveFollowPathSVG(SvgExporter &exp,
const FrameRange &visRange,
QDomElement &childElement,
QDomElement &parentElement) const
{
const auto target = targetProperty()->getTarget();
if (!target) { return parentElement; }
mComplete->saveQrealSVG(exp,
childElement,
visRange,
"transform",
1.,
false,
"",
"%1",
"",
"",
true,
mRotate->getValue(),
target->prp_getName());
const auto transform = target->getBoxTransformAnimator();
const auto transformed = transform->saveSVG(exp,
visRange,
parentElement);
return transformed;
}
6 changes: 6 additions & 0 deletions src/core/TransformEffects/followpatheffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class FollowPathEffect : public TargetTransformEffect {
qreal &shearX, qreal &shearY,
QMatrix& postTransform,
BoundingBox* const parent) override;

QDomElement saveFollowPathSVG(SvgExporter& exp,
const FrameRange& visRange,
QDomElement &childElement,
QDomElement &parentElement) const;

private:
void setRotScaleAfterTargetChange(
BoundingBox* const oldTarget,
Expand Down
29 changes: 29 additions & 0 deletions src/core/TransformEffects/transformeffectcollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,35 @@ void TransformEffectCollection::prp_readProperty_impl(eReadStream &src) {
}
}

bool TransformEffectCollection::hasEffectsSVG()
{
const auto& children = ca_getChildren();
for (const auto& effect : children) {
if (const auto followPath = enve_cast<FollowPathEffect*>(effect.get())) {
return true;
}
}
return false;
}

QDomElement TransformEffectCollection::saveEffectsSVG(SvgExporter &exp,
const FrameRange &visRange,
QDomElement &childElement,
const QDomElement &parentElement) const
{
QDomElement result = parentElement;
const auto& children = ca_getChildren();
for (const auto& effect : children) {
if (const auto path = enve_cast<FollowPathEffect*>(effect.get())) {
result = path->saveFollowPathSVG(exp,
visRange,
childElement,
result);
}
}
return result;
}

void TransformEffectCollection::applyEffects(
const qreal relFrame,
qreal& pivotX, qreal& pivotY,
Expand Down
7 changes: 7 additions & 0 deletions src/core/TransformEffects/transformeffectcollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,15 @@ class CORE_EXPORT TransformEffectCollection :
void prp_readProperty_impl(eReadStream &src);

bool hasEffects();
bool hasEffectsSVG();

void readTransformEffect(eReadStream &target);

QDomElement saveEffectsSVG(SvgExporter& exp,
const FrameRange& visRange,
QDomElement &childElement,
const QDomElement &parentElement) const;

void applyEffects(const qreal relFrame,
qreal& pivotX, qreal& pivotY,
qreal& posX, qreal& posY,
Expand Down

0 comments on commit 2f21897

Please sign in to comment.