r14220 by fschmid - Implemented gradient strokes in the svg exporter.
scribus-commit
scribus-commit at lists.scribus.net
Sat Oct 24 13:50:19 CEST 2009
Revision: 14220
Author: fschmid
Date: 2009-10-24T08:28:17.948500Z
Commit message: Implemented gradient strokes in the svg exporter.
Changeset:
M /trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp
Diffs:
Index: scribus/plugins/svgexplugin/svgexplugin.cpp
===================================================================
--- scribus/plugins/svgexplugin/svgexplugin.cpp (revision 14219)
+++ scribus/plugins/svgexplugin/svgexplugin.cpp (revision 14220)
@@ -1304,6 +1304,42 @@
globalDefs.appendChild(patt);
aFill += "fill:url(#"+pattID+");";
}
+ else if (Item->GrTypeStroke > 0)
+ {
+ QDomElement grad;
+ if (Item->GrTypeStroke == 7)
+ {
+ grad = docu.createElement("radialGradient");
+ grad.setAttribute("r", FToStr(sqrt(pow(Item->GrStrokeEndX - Item->GrStrokeStartX, 2) + pow(Item->GrStrokeEndY - Item->GrStrokeStartY,2))));
+ grad.setAttribute("cx", FToStr(Item->GrStrokeStartX));
+ grad.setAttribute("cy", FToStr(Item->GrStrokeStartY));
+ }
+ else
+ {
+ grad = docu.createElement("linearGradient");
+ grad.setAttribute("x1", FToStr(Item->GrStrokeStartX));
+ grad.setAttribute("y1", FToStr(Item->GrStrokeStartY));
+ grad.setAttribute("x2", FToStr(Item->GrStrokeEndX));
+ grad.setAttribute("y2", FToStr(Item->GrStrokeEndY));
+ }
+ QList<VColorStop*> cstops = Item->stroke_gradient.colorStops();
+ for (uint cst = 0; cst < Item->stroke_gradient.Stops(); ++cst)
+ {
+ QDomElement itcl = docu.createElement("stop");
+ itcl.setAttribute("offset", FToStr(cstops.at(cst)->rampPoint*100)+"%");
+ if (cstops.at(cst)->name == CommonStrings::None)
+ itcl.setAttribute("stop-opacity", FToStr(0));
+ else
+ itcl.setAttribute("stop-opacity", FToStr(cstops.at(cst)->opacity));
+ itcl.setAttribute("stop-color", SetColor(cstops.at(cst)->name, cstops.at(cst)->shade));
+ grad.appendChild(itcl);
+ }
+ grad.setAttribute("id", "Grad"+IToStr(GradCount));
+ grad.setAttribute("gradientUnits", "userSpaceOnUse");
+ globalDefs.appendChild(grad);
+ aFill = " fill:url(#Grad"+IToStr(GradCount)+");";
+ GradCount++;
+ }
else
aFill = "fill:"+SetColor(Item->lineColor(), Item->lineShade())+";";
if (Item->lineTransparency() != 0)
@@ -1416,6 +1452,42 @@
globalDefs.appendChild(patt);
aFill += "fill:url(#"+pattID+");";
}
+ else if (Item->GrTypeStroke > 0)
+ {
+ QDomElement grad;
+ if (Item->GrTypeStroke == 7)
+ {
+ grad = docu.createElement("radialGradient");
+ grad.setAttribute("r", FToStr(sqrt(pow(Item->GrStrokeEndX - Item->GrStrokeStartX, 2) + pow(Item->GrStrokeEndY - Item->GrStrokeStartY,2))));
+ grad.setAttribute("cx", FToStr(Item->GrStrokeStartX));
+ grad.setAttribute("cy", FToStr(Item->GrStrokeStartY));
+ }
+ else
+ {
+ grad = docu.createElement("linearGradient");
+ grad.setAttribute("x1", FToStr(Item->GrStrokeStartX));
+ grad.setAttribute("y1", FToStr(Item->GrStrokeStartY));
+ grad.setAttribute("x2", FToStr(Item->GrStrokeEndX));
+ grad.setAttribute("y2", FToStr(Item->GrStrokeEndY));
+ }
+ QList<VColorStop*> cstops = Item->stroke_gradient.colorStops();
+ for (uint cst = 0; cst < Item->stroke_gradient.Stops(); ++cst)
+ {
+ QDomElement itcl = docu.createElement("stop");
+ itcl.setAttribute("offset", FToStr(cstops.at(cst)->rampPoint*100)+"%");
+ if (cstops.at(cst)->name == CommonStrings::None)
+ itcl.setAttribute("stop-opacity", FToStr(0));
+ else
+ itcl.setAttribute("stop-opacity", FToStr(cstops.at(cst)->opacity));
+ itcl.setAttribute("stop-color", SetColor(cstops.at(cst)->name, cstops.at(cst)->shade));
+ grad.appendChild(itcl);
+ }
+ grad.setAttribute("id", "Grad"+IToStr(GradCount));
+ grad.setAttribute("gradientUnits", "userSpaceOnUse");
+ globalDefs.appendChild(grad);
+ aFill = " fill:url(#Grad"+IToStr(GradCount)+");";
+ GradCount++;
+ }
else
aFill = "fill:"+SetColor(Item->lineColor(), Item->lineShade())+";";
if (Item->lineTransparency() != 0)
@@ -1535,6 +1607,7 @@
grad.setAttribute("y2", FToStr(Item->GrEndY));
break;
case 7:
+ grad.setAttribute("r", FToStr(sqrt(pow(Item->GrEndX - Item->GrStartX, 2) + pow(Item->GrEndY - Item->GrStartY,2))));
grad.setAttribute("r", FToStr(qMax(Item->width() / 2.0, Item->height() / 2.0)));
grad.setAttribute("cx", FToStr(Item->GrStartX));
grad.setAttribute("cy", FToStr(Item->GrStartY));
@@ -1655,11 +1728,11 @@
{
QString stroke = "";
if (Item->lineTransparency() != 0)
- stroke += " stroke-opacity:"+FToStr(1.0 - Item->lineTransparency())+";";
+ stroke = "stroke-opacity:"+FToStr(1.0 - Item->lineTransparency())+";";
if (Item->lineWidth() != 0.0)
- stroke += " stroke-width:"+FToStr(Item->lineWidth())+";";
+ stroke = "stroke-width:"+FToStr(Item->lineWidth())+";";
else
- stroke += " stroke-width:1px;";
+ stroke = "stroke-width:1px;";
stroke += " stroke-linecap:";
switch (Item->PLineEnd)
{
@@ -1736,11 +1809,47 @@
patt.setAttribute("patternTransform", MatrixToStr(mpa));
patt.setAttribute("xlink:href", "#"+Item->strokePattern());
globalDefs.appendChild(patt);
- stroke += "stroke:url(#"+pattID+");";
+ stroke += " stroke:url(#"+pattID+");";
}
+ else if (Item->GrTypeStroke > 0)
+ {
+ QDomElement grad;
+ if (Item->GrTypeStroke == 7)
+ {
+ grad = docu.createElement("radialGradient");
+ grad.setAttribute("r", FToStr(sqrt(pow(Item->GrStrokeEndX - Item->GrStrokeStartX, 2) + pow(Item->GrStrokeEndY - Item->GrStrokeStartY,2))));
+ grad.setAttribute("cx", FToStr(Item->GrStrokeStartX));
+ grad.setAttribute("cy", FToStr(Item->GrStrokeStartY));
+ }
+ else
+ {
+ grad = docu.createElement("linearGradient");
+ grad.setAttribute("x1", FToStr(Item->GrStrokeStartX));
+ grad.setAttribute("y1", FToStr(Item->GrStrokeStartY));
+ grad.setAttribute("x2", FToStr(Item->GrStrokeEndX));
+ grad.setAttribute("y2", FToStr(Item->GrStrokeEndY));
+ }
+ QList<VColorStop*> cstops = Item->stroke_gradient.colorStops();
+ for (uint cst = 0; cst < Item->stroke_gradient.Stops(); ++cst)
+ {
+ QDomElement itcl = docu.createElement("stop");
+ itcl.setAttribute("offset", FToStr(cstops.at(cst)->rampPoint*100)+"%");
+ if (cstops.at(cst)->name == CommonStrings::None)
+ itcl.setAttribute("stop-opacity", FToStr(0));
+ else
+ itcl.setAttribute("stop-opacity", FToStr(cstops.at(cst)->opacity));
+ itcl.setAttribute("stop-color", SetColor(cstops.at(cst)->name, cstops.at(cst)->shade));
+ grad.appendChild(itcl);
+ }
+ grad.setAttribute("id", "Grad"+IToStr(GradCount));
+ grad.setAttribute("gradientUnits", "userSpaceOnUse");
+ globalDefs.appendChild(grad);
+ stroke += " stroke:url(#Grad"+IToStr(GradCount)+");";
+ GradCount++;
+ }
else if (Item->lineColor() != CommonStrings::None)
{
- stroke = "stroke:"+SetColor(Item->lineColor(), Item->lineShade())+";";
+ stroke += " stroke:"+SetColor(Item->lineColor(), Item->lineShade())+";";
}
else
stroke = "stroke:none;";
More information about the scribus-commit
mailing list