r18790 by fschmid - Better export of "Drop Shadows" to SVG, now done the same way as in Inkscape, thus fixed Bug #12026
scribus-commit
scribus-commit at lists.scribus.net
Thu Jan 30 21:14:03 UTC 2014
Author: fschmid
Date: Thu Jan 30 21:14:03 2014
New Revision: 18790
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18790
Log:
Better export of "Drop Shadows" to SVG, now done the same way as in Inkscape, thus fixed Bug #12026
Modified:
trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp
trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.h
Modified: trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18790&path=/trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp Thu Jan 30 21:14:03 2014
@@ -330,12 +330,12 @@
void SVGExPlug::ProcessItemOnPage(double xOffset, double yOffset, PageItem *Item, QDomElement *parentElem)
{
- processDropShadow(xOffset, yOffset, Item, parentElem);
QDomElement ob;
QString trans = "translate("+FToStr(xOffset)+", "+FToStr(yOffset)+")";
if (Item->rotation() != 0)
trans += " rotate("+FToStr(Item->rotation())+")";
QString fill = getFillStyle(Item);
+ fill += processDropShadow(Item);
QString stroke = "stroke:none";
stroke = getStrokeStyle(Item);
switch (Item->itemType())
@@ -664,104 +664,49 @@
}
}
-void SVGExPlug::processDropShadow(double xOffset, double yOffset, PageItem *Item, QDomElement *parentElem)
+QString SVGExPlug::processDropShadow(PageItem *Item)
{
if (!Item->hasSoftShadow())
- return;
- QDomElement ob;
- QString trans = "translate("+FToStr(xOffset + Item->softShadowXOffset())+", "+FToStr(yOffset + Item->softShadowYOffset())+")";
- if (Item->rotation() != 0)
- trans += " rotate("+FToStr(Item->rotation())+")";
- QString fill = "fill:none;";
- if (Item->fillColor() != CommonStrings::None)
- fill = "fill:"+SetColor(Item->softShadowColor(), Item->softShadowShade())+";";
- if (Item->softShadowOpacity() != 0)
- fill += " fill-opacity:"+FToStr(1.0 - Item->softShadowOpacity())+";";
- QString stroke = "";
- if (Item->lineColor() != CommonStrings::None)
- stroke += "stroke:"+SetColor(Item->softShadowColor(), Item->softShadowShade())+";";
- else
- stroke += "stroke:none;";
- if (Item->softShadowOpacity() != 0)
- stroke += "stroke-opacity:"+FToStr(1.0 - Item->softShadowOpacity())+";";
- if (Item->lineWidth() != 0.0)
- stroke = "stroke-width:"+FToStr(Item->lineWidth())+";";
- else
- stroke = "stroke-width:1px;";
- stroke += " stroke-linecap:";
- switch (Item->PLineEnd)
- {
- case Qt::FlatCap:
- stroke += "butt;";
- break;
- case Qt::SquareCap:
- stroke += "square;";
- break;
- case Qt::RoundCap:
- stroke += "round;";
- break;
- default:
- stroke += "butt;";
- break;
- }
- stroke += " stroke-linejoin:";
- switch (Item->PLineJoin)
- {
- case Qt::MiterJoin:
- stroke += "miter;";
- break;
- case Qt::BevelJoin:
- stroke += "bevel;";
- break;
- case Qt::RoundJoin:
- stroke += "round;";
- break;
- default:
- stroke += "miter;";
- break;
- }
- stroke += " stroke-dasharray:";
- if (Item->DashValues.count() != 0)
- {
- QVector<double>::iterator it;
- for ( it = Item->DashValues.begin(); it != Item->DashValues.end(); ++it )
- {
- stroke += IToStr(static_cast<int>(*it))+" ";
- }
- stroke += "; stroke-dashoffset:"+IToStr(static_cast<int>(Item->DashOffset))+";";
- }
- else
- {
- if (Item->PLineArt == Qt::SolidLine)
- stroke += "none;";
- else
- {
- QString Da = getDashString(Item->PLineArt, Item->lineWidth());
- if (Da.isEmpty())
- stroke += "none;";
- else
- stroke += Da.replace(" ", ", ")+";";
- }
- }
-
+ return "";
QString ID = "Filter"+IToStr(FilterCount);
QDomElement filter = docu.createElement("filter");
filter.setAttribute("id", ID);
- QDomElement ob2 = docu.createElement("feGaussianBlur");
- ob2.setAttribute("id", "feGaussianBlur"+IToStr(FilterCount));
- ob2.setAttribute("in", "SourceGraphic");
- ob2.setAttribute("stdDeviation", FToStr(Item->softShadowBlurRadius()));
- ob2.setAttribute("result", "blur");
+ filter.setAttribute("inkscape:label", "Drop shadow");
+ QDomElement ob = docu.createElement("feGaussianBlur");
+ ob.setAttribute("id", "feGaussianBlur"+IToStr(FilterCount));
+ ob.setAttribute("in", "SourceAlpha");
+ ob.setAttribute("stdDeviation", FToStr(Item->softShadowBlurRadius()));
+ ob.setAttribute("result", "blur");
+ filter.appendChild(ob);
+ QDomElement ob2 = docu.createElement("feColorMatrix");
+ ob2.setAttribute("id", "feColorMatrix"+IToStr(FilterCount));
+ const ScColor& col = m_Doc->PageColors[Item->softShadowColor()];
+ QColor color = ScColorEngine::getShadeColorProof(col, m_Doc, Item->softShadowShade());
+ ob2.setAttribute("type", "matrix");
+ ob2.setAttribute("values", QString("1 0 0 %1 0 0 1 0 %2 0 0 0 1 %3 0 0 0 0 %4 0").arg(color.redF()).arg(color.greenF()).arg(color.blueF()).arg(1.0 - Item->softShadowOpacity()));
+ ob2.setAttribute("result", "bluralpha");
filter.appendChild(ob2);
+ QDomElement ob3 = docu.createElement("feOffset");
+ ob3.setAttribute("id", "feOffset"+IToStr(FilterCount));
+ ob3.setAttribute("in", "bluralpha");
+ ob3.setAttribute("dx", FToStr(Item->softShadowXOffset()));
+ ob3.setAttribute("dy", FToStr(Item->softShadowYOffset()));
+ ob3.setAttribute("result", "offsetBlur");
+ filter.appendChild(ob3);
+ QDomElement ob4 = docu.createElement("feMerge");
+ ob4.setAttribute("id", "feMerge"+IToStr(FilterCount));
+ QDomElement ob5 = docu.createElement("feMergeNode");
+ ob5.setAttribute("id", "feMergeNode1"+IToStr(FilterCount));
+ ob5.setAttribute("in", "offsetBlur");
+ ob4.appendChild(ob5);
+ QDomElement ob6 = docu.createElement("feMergeNode");
+ ob6.setAttribute("id", "feMergeNode2"+IToStr(FilterCount));
+ ob6.setAttribute("in", "SourceGraphic");
+ ob4.appendChild(ob6);
+ filter.appendChild(ob4);
globalDefs.appendChild(filter);
FilterCount++;
-
- ob = docu.createElement("path");
- ob.setAttribute("d", SetClipPath(&Item->PoLine, true));
- ob.setAttribute("transform", trans);
- ob.setAttribute("style", fill + stroke + "filter:url(#"+ID+")");
- parentElem->appendChild(ob);
- return;
+ return "filter:url(#"+ID+");";
}
QDomElement SVGExPlug::processSymbolStroke(PageItem *Item, QString trans)
Modified: trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18790&path=/trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.h
==============================================================================
--- trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.h (original)
+++ trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.h Thu Jan 30 21:14:03 2014
@@ -82,7 +82,7 @@
void ProcessPageLayer(ScPage *page, ScLayer& layer);
void ProcessItemOnPage(double xOffset, double yOffset, PageItem *Item, QDomElement *parentElem);
void paintBorder(const TableBorder& border, const QPointF& start, const QPointF& end, const QPointF& startOffsetFactors, const QPointF& endOffsetFactors, QDomElement &ob);
- void processDropShadow(double xOffset, double yOffset, PageItem *Item, QDomElement *parentElem);
+ QString processDropShadow(PageItem *Item);
QDomElement processSymbolStroke(PageItem *Item, QString trans);
QDomElement processSymbolItem(PageItem *Item, QString trans);
QDomElement processPolyItem(PageItem *Item, QString trans, QString fill, QString stroke);
More information about the scribus-commit
mailing list