r14319 by fschmid - Some fixes and corrections for gradients and gradient masks.

scribus-commit scribus-commit at lists.scribus.net
Fri Nov 20 22:35:26 CET 2009


Revision: 14319
Author: fschmid
Date: 2009-11-20T12:44:53.716602Z
Commit message: Some fixes and corrections for gradients and gradient masks.

Changeset: 
M  /trunk/Scribus/scribus/pdflib_core.cpp
M  /trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp

Diffs:
Index: scribus/pdflib_core.cpp
===================================================================
--- scribus/pdflib_core.cpp	(revision 14318)
+++ scribus/pdflib_core.cpp	(revision 14319)
@@ -5585,7 +5585,6 @@
 		TransVec.clear();
 		QTransform mpa;
 		mpa.rotate(-currItem->rotation());
-		QTransform qmatrix;
 		if (Gskew == 90)
 			Gskew = 1;
 		else if (Gskew == 180)
@@ -6117,7 +6116,6 @@
 	bool spotMode = false;
 	mpa.translate(currItem->xPos() - ActPageP->xOffset(), ActPageP->height() - (currItem->yPos() - ActPageP->yOffset()));
 	mpa.rotate(-currItem->rotation());
-	QTransform qmatrix;
 	if (Gskew == 90)
 		Gskew = 1;
 	else if (Gskew == 180)
@@ -6180,11 +6178,29 @@
 	QString TRes("");
 	if (((Options.Version >= PDFOptions::PDFVersion_14) || (Options.Version == PDFOptions::PDFVersion_X4)) && (transparencyFound))
 	{
+		QTransform mpM;
+		mpM.rotate(-currItem->rotation());
+		if (GType == 6)
+		{
+			mpM.translate(StartX, -StartY);
+			mpM.shear(Gskew, 0);
+			mpM.translate(-StartX, StartY);
+		}
+		else
+		{
+			double rotEnd = xy2Deg(EndX - StartX, EndY - StartY);
+			mpM.translate(StartX, -StartY);
+			mpM.rotate(-rotEnd);
+			mpM.shear(-Gskew, 0);
+			mpM.translate(0, -StartY * (1.0 - Gscale));
+			mpM.translate(-StartX, StartY);
+			mpM.scale(1, Gscale);
+		}
 		uint patObject = newObject();
 		StartObj(patObject);
 		PutDoc("<<\n/Type /Pattern\n");
 		PutDoc("/PatternType 2\n");
-		PutDoc("/Matrix ["+FToStr(mpa.m11())+" "+FToStr(mpa.m12())+" "+FToStr(mpa.m21())+" "+FToStr(mpa.m22())+" 0 0]\n");
+		PutDoc("/Matrix ["+FToStr(mpM.m11())+" "+FToStr(mpM.m12())+" "+FToStr(mpM.m21())+" "+FToStr(mpM.m22())+" "+FToStr(mpM.dx())+" "+FToStr(mpM.dy())+"]\n");
 		PutDoc("/Shading\n");
 		PutDoc("<<\n");
 		if (GType == 6)
Index: scribus/plugins/fileloader/scribus150format/scribus150format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(revision 14318)
+++ scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(revision 14319)
@@ -1954,6 +1954,14 @@
 		newItem->stroke_gradient.addStop(ScColorEngine::getRGBColor(col2, doc), 1.0, 0.5, 1.0, doc->itemToolPrefs.shapeLineColor, 100);
 	}
 
+	if (newItem->mask_gradient.Stops() == 0)
+	{
+		const ScColor& col1 = doc->PageColors[doc->itemToolPrefs.shapeFillColor];
+		const ScColor& col2 = doc->PageColors[doc->itemToolPrefs.shapeLineColor];
+		newItem->mask_gradient.addStop(ScColorEngine::getRGBColor(col1, doc), 0.0, 0.5, 1.0, doc->itemToolPrefs.shapeFillColor, 100);
+		newItem->mask_gradient.addStop(ScColorEngine::getRGBColor(col2, doc), 1.0, 0.5, 1.0, doc->itemToolPrefs.shapeLineColor, 100);
+	}
+
 	if (newItem->asPathText())
 	{
 		newItem->updatePolyClip();
@@ -2837,8 +2845,9 @@
 	bool mirrorX = attrs.valueAsBool("pMirrorXS", false);
 	bool mirrorY = attrs.valueAsBool("pMirrorYS", false);
 	currItem->setPatternFlip(mirrorX, mirrorY);
-	currItem->stroke_gradient.clearStops();
 	currItem->GrTypeStroke = attrs.valueAsInt("GRTYPS", 0);
+	if (((currItem->GrTypeStroke != 0) && (currItem->GrTypeStroke != 8)) && (currItem->strokeGradient().isEmpty()))
+		currItem->stroke_gradient.clearStops();
 	currItem->GrStrokeStartX = attrs.valueAsDouble("GRSTARTXS", 0.0);
 	currItem->GrStrokeStartY = attrs.valueAsDouble("GRSTARTYS", 0.0);
 	currItem->GrStrokeEndX   = attrs.valueAsDouble("GRENDXS", 0.0);
@@ -2865,12 +2874,15 @@
 	bool mirrorXm = attrs.valueAsBool("pMirrorXM", false);
 	bool mirrorYm = attrs.valueAsBool("pMirrorYM", false);
 	currItem->setMaskFlip(mirrorXm, mirrorYm);
+	QString GrNameM = "";
+	GrNameM = attrs.valueAsString("GRNAMEM","");
 	currItem->GrMask = attrs.valueAsInt("GRTYPM", 0);
 	if ((currItem->GrMask == 1) || (currItem->GrMask == 4))
 		currItem->mask_gradient = VGradient(VGradient::linear);
 	else if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
 		currItem->mask_gradient = VGradient(VGradient::radial);
-	currItem->mask_gradient.clearStops();
+	if (((currItem->GrMask == 1) || (currItem->GrMask == 2) || (currItem->GrMask == 4) || (currItem->GrMask == 5)) && (GrNameM.isEmpty()))
+		currItem->mask_gradient.clearStops();
 	currItem->GrMaskStartX = attrs.valueAsDouble("GRSTARTXM", 0.0);
 	currItem->GrMaskStartY = attrs.valueAsDouble("GRSTARTYM", 0.0);
 	currItem->GrMaskEndX   = attrs.valueAsDouble("GRENDXM", 0.0);
@@ -2879,8 +2891,6 @@
 	currItem->GrMaskFocalY = attrs.valueAsDouble("GRFOCALYM", 0.0);
 	currItem->GrMaskScale  = attrs.valueAsDouble("GRSCALEM", 1.0);
 	currItem->GrMaskSkew  = attrs.valueAsDouble("GRSKEWM", 0.0);
-	QString GrNameM = "";
-	GrNameM = attrs.valueAsString("GRNAMEM","");
 	if (!GrNameM.isEmpty())
 		currItem->setGradientMask(GrNameM);
 




More information about the scribus-commit mailing list