r15201 by jghali - #9178: inconsistency between gradient display and pdf/svg export Align display and svg export to pdf export
scribus-commit
scribus-commit at lists.scribus.net
Wed Jun 16 23:50:28 CEST 2010
Revision: 15201
Author: jghali
Date: 2010-06-16T21:44:24.034362Z
Commit message: #9178: inconsistency between gradient display and pdf/svg export
Align display and svg export to pdf export
Changeset:
M /branches/Version135/Scribus/scribus/scpainter.cpp
M /branches/Version135/Scribus/scribus/scpainterex_cairo.cpp
M /branches/Version135/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp
Diffs:
Index: scribus/scpainterex_cairo.cpp
===================================================================
--- scribus/scpainterex_cairo.cpp (revision 15200)
+++ scribus/scpainterex_cairo.cpp (revision 15201)
@@ -457,12 +457,18 @@
FPoint p2( gradient.vector().x(), gradient.vector().y() );
cairo_pattern_t *pat = cairo_pattern_create_linear (p1.x(), p1.y(), p2.x(), p2.y());
+ bool isFirst = true;
+ double lastStop = 0.0;
for( uint index = 0 ; index < gradient.Stops(); index++)
{
stop = colorStops.at(index);
+ if ((lastStop == stop->rampPoint) && (!isFirst))
+ continue;
+ isFirst = false;
color = transformColor( ScColorShade(stop->color, stop->shade), 1.0 );
color.getRgbF(&r, &g, &b);
cairo_pattern_add_color_stop_rgba (pat, stop->rampPoint, r, g, b, stop->opacity);
+ lastStop = stop->rampPoint;
}
cairo_set_source (m_cr, pat);
@@ -486,12 +492,18 @@
cairo_pattern_t* pat = cairo_pattern_create_radial (pc.x(), pc.y(), 0.1, pc.x(), pc.y(), rad);
+ bool isFirst = true;
+ double lastStop = 0.0;
for( uint index = 0 ; index < gradient.Stops() ; index++)
{
stop = colorStops.at(index);
+ if ((lastStop == stop->rampPoint) && (!isFirst))
+ continue;
+ isFirst = false;
color = transformColor( ScColorShade(stop->color, stop->shade), 1.0 );
color.getRgbF(&r, &g, &b);
cairo_pattern_add_color_stop_rgba (pat, stop->rampPoint, r, g, b, stop->opacity);
+ lastStop = stop->rampPoint;
}
cairo_set_source (m_cr, pat);
Index: scribus/scpainter.cpp
===================================================================
--- scribus/scpainter.cpp (revision 15200)
+++ scribus/scpainter.cpp (revision 15201)
@@ -953,6 +953,8 @@
else if (fillMode == 2)
{
cairo_pattern_t *pat;
+ bool isFirst = true;
+ double rampPoint, lastPoint = 0.0;
double x1 = fill_gradient.origin().x();
double y1 = fill_gradient.origin().y();
double x2 = fill_gradient.vector().x();
@@ -966,6 +968,10 @@
for( int offset = 0 ; offset < colorStops.count() ; offset++ )
{
qStopColor = colorStops[ offset ]->color;
+ rampPoint = colorStops[ offset ]->rampPoint;
+ if ((lastPoint == rampPoint) && (!isFirst))
+ continue;
+ isFirst = false;
int h, s, v, sneu, vneu;
int shad = colorStops[offset]->shade;
qStopColor.getHsv(&h, &s, &v);
@@ -975,7 +981,8 @@
double a = colorStops[offset]->opacity;
double r, g, b;
qStopColor.getRgbF(&r, &g, &b);
- cairo_pattern_add_color_stop_rgba (pat, colorStops[ offset ]->rampPoint, r, g, b, a);
+ cairo_pattern_add_color_stop_rgba (pat, rampPoint, r, g, b, a);
+ lastPoint = rampPoint;
}
cairo_set_source (m_cr, pat);
cairo_clip_preserve (m_cr);
@@ -1061,6 +1068,8 @@
else if (fillMode == 2)
{
QGradient pat;
+ bool isFirst = true;
+ double rampPoint, lastPoint = 0.0;
double x1 = fill_gradient.origin().x();
double y1 = fill_gradient.origin().y();
double x2 = fill_gradient.vector().x();
@@ -1074,6 +1083,10 @@
for( int offset = 0 ; offset < colorStops.count() ; offset++ )
{
qStopColor = colorStops[ offset ]->color;
+ rampPoint = colorStops[ offset ]->rampPoint;
+ if ((lastPoint == rampPoint) && (!isFirst))
+ continue;
+ isFirst = false;
int h, s, v, sneu, vneu;
int shad = colorStops[offset]->shade;
qStopColor.getHsv(&h, &s, &v);
@@ -1082,6 +1095,7 @@
qStopColor.setHsv(h, sneu, vneu);
qStopColor.setAlphaF(colorStops[offset]->opacity);
pat.setColorAt(colorStops[ offset ]->rampPoint, qStopColor);
+ lastPoint = rampPoint;
}
painter.setOpacity(fill_trans);
painter.fillPath(m_path, pat);
Index: scribus/plugins/svgexplugin/svgexplugin.cpp
===================================================================
--- scribus/plugins/svgexplugin/svgexplugin.cpp (revision 15200)
+++ scribus/plugins/svgexplugin/svgexplugin.cpp (revision 15201)
@@ -1557,14 +1557,22 @@
grad.setAttribute("cy", FToStr(Item->GrStartY));
break;
}
+ bool isFirst = true;
+ double actualStop = 0.0, lastStop = 0.0;
QList<VColorStop*> cstops = Item->fill_gradient.colorStops();
for (uint cst = 0; cst < Item->fill_gradient.Stops(); ++cst)
{
- QDomElement itcl = docu.createElement("stop");
- itcl.setAttribute("offset", FToStr(cstops.at(cst)->rampPoint*100)+"%");
- 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);
+ actualStop = cstops.at(cst)->rampPoint;
+ if ((actualStop != lastStop) || (isFirst))
+ {
+ QDomElement itcl = docu.createElement("stop");
+ itcl.setAttribute("offset", FToStr(cstops.at(cst)->rampPoint*100)+"%");
+ 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);
+ lastStop = actualStop;
+ isFirst = false;
+ }
}
globalDefs.appendChild(grad);
fill = "fill:url(#Grad"+IToStr(GradCount)+");";
More information about the scribus-commit
mailing list