Skip to content

Commit

Permalink
SVG Export: support stroke-linecap/stroke-linejoin
Browse files Browse the repository at this point in the history
Ref: #223
  • Loading branch information
rodlie committed Aug 17, 2024
1 parent a844c39 commit 9e52b65
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/core/Animators/outlinesettingsanimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,43 @@ void OutlineSettingsAnimator::duplicateStrokeSettingsNotAnim(
void OutlineSettingsAnimator::saveSVG(SvgExporter& exp,
QDomElement& parent,
const FrameRange& visRange,
const bool asFill) const {
const bool asFill) const
{
PaintSettingsAnimator::saveSVG(exp, parent, visRange,
asFill ? "fill" : "stroke");
if(asFill) return;
if (asFill) { return; }

mLineWidth->saveQrealSVG(exp, parent, visRange, "stroke-width");
saveCapsSVG(parent);
}

void OutlineSettingsAnimator::saveCapsSVG(QDomElement &parent) const
{
QString linecap;
switch(mCapStyle) {
case SkPaint::kRound_Cap:
linecap = "round";
break;
case SkPaint::kSquare_Cap:
linecap = "square";
break;
default:
linecap = "butt";
}
parent.setAttribute("stroke-linecap", linecap);

QString linejoin;
switch(mJoinStyle) {
case SkPaint::kRound_Join:
linejoin = "round";
break;
case SkPaint::kBevel_Join:
linejoin = "bevel";
break;
default:
linejoin = "miter";
}
parent.setAttribute("stroke-linejoin", linejoin);
}

QDomElement OutlineSettingsAnimator::writeBrushPaint(const XevExporter& exp) const {
Expand Down
2 changes: 2 additions & 0 deletions src/core/Animators/outlinesettingsanimator.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class CORE_EXPORT OutlineSettingsAnimator : public PaintSettingsAnimator {
QDomElement& parent,
const FrameRange& visRange,
const bool asFill = false) const;
void saveCapsSVG(QDomElement& parent) const;

protected:
QDomElement writeBrushPaint(const XevExporter& exp) const;
void readBrushPaint(const QDomElement& ele,
Expand Down

0 comments on commit 9e52b65

Please sign in to comment.