r14318 by fschmid - Gradient and Pattern Masks: implemented the ability too choose whether the transparency is calculated from the alpha or the luminosity component of the gradient or pattern.
scribus-commit
scribus-commit at lists.scribus.net
Fri Nov 20 20:51:08 CET 2009
Revision: 14318
Author: fschmid
Date: 2009-11-20T11:00:44.535882Z
Commit message: Gradient and Pattern Masks: implemented the ability too choose whether the transparency is calculated from the alpha or the luminosity component of the gradient or pattern.
Changeset:
M /trunk/Scribus/scribus/pdflib_core.cpp
M /trunk/Scribus/scribus/scpainter.cpp
M /trunk/Scribus/scribus/ui/propertiespalette.cpp
M /trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
M /trunk/Scribus/scribus/ui/transparencypalette.h
M /trunk/Scribus/scribus/canvas.cpp
M /trunk/Scribus/scribus/pageitem.cpp
M /trunk/Scribus/scribus/scribusXml.cpp
M /trunk/Scribus/scribus/scpainter.h
M /trunk/Scribus/scribus/scribusdoc.cpp
M /trunk/Scribus/scribus/ui/transparencypalette.ui
M /trunk/Scribus/scribus/canvasmode_editgradient.cpp
M /trunk/Scribus/scribus/plugins/xarimplugin/importxar.cpp
M /trunk/Scribus/scribus/scribusview.cpp
M /trunk/Scribus/scribus/ui/transparencypalette.cpp
Diffs:
Index: scribus/canvasmode_editgradient.cpp
===================================================================
--- scribus/canvasmode_editgradient.cpp (revision 14317)
+++ scribus/canvasmode_editgradient.cpp (revision 14318)
@@ -258,7 +258,7 @@
currItem->GrMaskStartY -= np.y();
currItem->GrMaskFocalX -= np.x();
currItem->GrMaskFocalY -= np.y();
- if (currItem->GrMask == 2)
+ if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
{
double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
double radFoc = distance(currItem->GrMaskFocalX - currItem->GrMaskStartX, currItem->GrMaskFocalY - currItem->GrMaskStartY);
@@ -275,7 +275,7 @@
{
currItem->GrMaskFocalX -= np.x();
currItem->GrMaskFocalY -= np.y();
- if (currItem->GrMask == 2)
+ if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
{
double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
double radFoc = distance(currItem->GrMaskFocalX - currItem->GrMaskStartX, currItem->GrMaskFocalY - currItem->GrMaskStartY);
@@ -309,7 +309,7 @@
{
currItem->GrMaskEndX -= np.x();
currItem->GrMaskEndY -= np.y();
- if (currItem->GrMask == 2)
+ if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
{
double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
double radFoc = distance(currItem->GrMaskFocalX - currItem->GrMaskStartX, currItem->GrMaskFocalY - currItem->GrMaskStartY);
Index: scribus/pdflib_core.cpp
===================================================================
--- scribus/pdflib_core.cpp (revision 14317)
+++ scribus/pdflib_core.cpp (revision 14318)
@@ -5563,7 +5563,7 @@
ResCount++;
QString tmp;
QString GXName;
- if ((currItem->GrMask == 1) || (currItem->GrMask == 2))
+ if ((currItem->GrMask == 1) || (currItem->GrMask == 2) || (currItem->GrMask == 4) || (currItem->GrMask == 5))
{
QList<double> StopVec;
QList<double> TransVec;
@@ -5584,7 +5584,6 @@
StopVec.clear();
TransVec.clear();
QTransform mpa;
- mpa.translate(currItem->xPos() - ActPageP->xOffset(), ActPageP->height() - (currItem->yPos() - ActPageP->yOffset()));
mpa.rotate(-currItem->rotation());
QTransform qmatrix;
if (Gskew == 90)
@@ -5597,7 +5596,7 @@
Gskew = 0;
else
Gskew = tan(M_PI / 180.0 * Gskew);
- if (GType == 1)
+ if ((GType == 1) || (GType == 4))
{
mpa.translate(StartX, -StartY);
mpa.shear(Gskew, 0);
@@ -5613,20 +5612,33 @@
mpa.translate(-StartX, StartY);
mpa.scale(1, Gscale);
}
+ QColor qStopColor;
for (uint cst = 0; cst < gradient.Stops(); ++cst)
{
double actualStop = cstops.at(cst)->rampPoint;
+ qStopColor = cstops.at(cst)->color;
+ int h, s, v, sneu, vneu;
+ int shad = cstops.at(cst)->shade;
+ qStopColor.getHsv(&h, &s, &v);
+ sneu = s * shad / 100;
+ vneu = 255 - ((255 - v) * shad / 100);
+ qStopColor.setHsv(h, sneu, vneu);
+ double a = cstops.at(cst)->opacity;
+ double r, g, b;
+ qStopColor.getRgbF(&r, &g, &b);
+ if ((GType == 4) || (GType == 5))
+ a = 1.0 - (0.3 * r + 0.59 * g + 0.11 * b);
if ((cst == 0) && (actualStop != 0.0))
{
StopVec.append(0.0);
- TransVec.append(cstops.at(cst)->opacity);
+ TransVec.append(a);
}
StopVec.append(actualStop);
- TransVec.append(cstops.at(cst)->opacity);
+ TransVec.append(a);
if ((cst == gradient.Stops()-1) && (actualStop < 1.0))
{
StopVec.append(1.0);
- TransVec.append(cstops.at(cst)->opacity);
+ TransVec.append(a);
}
}
QString TRes("");
@@ -5634,10 +5646,10 @@
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(mpa.m11())+" "+FToStr(mpa.m12())+" "+FToStr(mpa.m21())+" "+FToStr(mpa.m22())+" "+FToStr(mpa.dx())+" "+FToStr(mpa.dy())+"]\n");
PutDoc("/Shading\n");
PutDoc("<<\n");
- if (GType == 1)
+ if ((GType == 1) || (GType == 4))
PutDoc("/ShadingType 2\n");
else
PutDoc("/ShadingType 3\n");
@@ -5718,7 +5730,7 @@
Transpar[GXName] = writeGState("/SMask << /S /Luminosity /G "+QString::number(formObject)+" 0 R >>\n/BM /" + blendMode(currItem->fillBlendmode()) + "\n");
tmp = "/"+GXName+" gs\n";
}
- else if (currItem->GrMask == 3)
+ else if ((currItem->GrMask == 3) || (currItem->GrMask == 6))
{
QString tmpOut = "";
PDF_PatternFillStroke(tmpOut, currItem, 2);
@@ -5767,7 +5779,10 @@
ResCount++;
GXName = ResNam+QString::number(ResCount);
ResCount++;
- Transpar[GXName] = writeGState("/SMask << /S /Alpha /G "+QString::number(formObject)+" 0 R >>\n/BM /" + blendMode(currItem->fillBlendmode()) + "\n");
+ if (currItem->GrMask == 6)
+ Transpar[GXName] = writeGState("/SMask << /S /Luminosity /G "+QString::number(formObject)+" 0 R >>\n/BM /" + blendMode(currItem->fillBlendmode()) + "\n");
+ else
+ Transpar[GXName] = writeGState("/SMask << /S /Alpha /G "+QString::number(formObject)+" 0 R >>\n/BM /" + blendMode(currItem->fillBlendmode()) + "\n");
tmp = "/"+GXName+" gs\n";
}
else
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp (revision 14317)
+++ scribus/scribusdoc.cpp (revision 14318)
@@ -5730,7 +5730,7 @@
{
currItem = m_Selection->itemAt(a);
currItem->GrMask = typ;
- if ((typ > 0) && (typ < 4))
+ if ((typ > 0) && (typ < 7))
currItem->updateGradientVectors();
currItem->update();
}
Index: scribus/scribusXml.cpp
===================================================================
--- scribus/scribusXml.cpp (revision 14317)
+++ scribus/scribusXml.cpp (revision 14318)
@@ -216,11 +216,11 @@
OB->GrStrokeSkew = attrAsDbl(attrs, "GRSKEWS", 1.0);
}
OB->GrMask = attrAsInt(attrs, "GRTYPM" , 0);
- if ((OB->GrMask == 1) || (OB->GrMask == 2))
+ if ((OB->GrMask == 1) || (OB->GrMask == 2) || (OB->GrMask == 4) || (OB->GrMask == 5))
{
- if (OB->GrMask == 1)
+ if ((OB->GrMask == 1) || (OB->GrMask == 4))
OB->mask_gradient = VGradient(VGradient::linear);
- else
+ else if ((OB->GrMask == 2) || (OB->GrMask == 5))
OB->mask_gradient = VGradient(VGradient::radial);
OB->mask_gradient.clearStops();
OB->GrMaskStartX = attrAsDbl(attrs, "GRSTARTXM", 0.0);
@@ -232,7 +232,7 @@
OB->GrMaskScale = attrAsDbl(attrs, "GRSCALEM", 1.0);
OB->GrMaskSkew = attrAsDbl(attrs, "GRSKEWM", 1.0);
}
- if (OB->GrMask == 3)
+ if ((OB->GrMask == 3) || (OB->GrMask == 6))
{
OB->patternMaskVal = attrAsString(attrs, "patternM", "");
OB->patternMaskScaleX = attrAsDbl(attrs, "pScaleXM", 100.0);
Index: scribus/canvas.cpp
===================================================================
--- scribus/canvas.cpp (revision 14317)
+++ scribus/canvas.cpp (revision 14318)
@@ -1228,7 +1228,7 @@
qmatrix.translate(0, currItem->GrMaskStartY * (1.0 - currItem->GrMaskScale));
qmatrix.translate(-currItem->GrMaskStartX, -currItem->GrMaskStartY);
qmatrix.scale(1, currItem->GrMaskScale);
- if (currItem->GrMask == 2)
+ if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
psx->drawPoint(qmatrix.map(QPointF(currItem->GrMaskFocalX, currItem->GrMaskFocalY)));
QTransform m;
m.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
Index: scribus/scpainter.cpp
===================================================================
--- scribus/scpainter.cpp (revision 14317)
+++ scribus/scpainter.cpp (revision 14318)
@@ -210,6 +210,8 @@
cairo_pattern_t *patM = getMaskPattern();
setRasterOp(m_blendMode);
cairo_mask(m_cr, patM);
+ if ((maskMode == 2) || (maskMode == 4))
+ cairo_surface_destroy(imageMask);
cairo_pattern_destroy(patM);
}
else
@@ -431,6 +433,8 @@
{
cairo_pattern_t *patM = getMaskPattern();
cairo_mask(m_cr, patM);
+ if ((maskMode == 2) || (maskMode == 4))
+ cairo_surface_destroy(imageMask);
cairo_pattern_destroy(patM);
}
else
@@ -442,6 +446,8 @@
{
cairo_pattern_t *patM = getMaskPattern();
cairo_mask(m_cr, patM);
+ if ((maskMode == 2) || (maskMode == 4))
+ cairo_surface_destroy(imageMask);
cairo_pattern_destroy(patM);
}
else
@@ -1142,7 +1148,7 @@
{
cairo_save( m_cr );
cairo_pattern_t *pat;
- if (maskMode == 1)
+ if ((maskMode == 1) || (maskMode == 3))
{
double x1 = mask_gradient.origin().x();
double y1 = mask_gradient.origin().y();
@@ -1168,6 +1174,8 @@
double a = colorStops[offset]->opacity;
double r, g, b;
qStopColor.getRgbF(&r, &g, &b);
+ if (maskMode == 3)
+ a = 1.0 - (0.3 * r + 0.59 * g + 0.11 * b);
cairo_pattern_add_color_stop_rgba (pat, colorStops[ offset ]->rampPoint, r, g, b, a);
}
cairo_matrix_t matrix;
@@ -1194,8 +1202,33 @@
}
else
{
- cairo_surface_t *image = cairo_image_surface_create_for_data ((uchar*)m_maskPattern->getPattern()->bits(), CAIRO_FORMAT_ARGB32, m_maskPattern->getPattern()->width(), m_maskPattern->getPattern()->height(), m_maskPattern->getPattern()->width()*4);
- pat = cairo_pattern_create_for_surface(image);
+ if (maskMode == 4)
+ {
+ imageQ = m_maskPattern->pattern.copy();
+ int h = imageQ.height();
+ int w = imageQ.width();
+ int k;
+ QRgb *s;
+ QRgb r;
+ for( int yi=0; yi < h; ++yi )
+ {
+ s = (QRgb*)(imageQ.scanLine( yi ));
+ for( int xi=0; xi < w; ++xi )
+ {
+ r = *s;
+ if (qAlpha(r) == 0)
+ k = 255;
+ else
+ k = qMin(qRound(0.3 * qRed(r) + 0.59 * qGreen(r) + 0.11 * qBlue(r)), 255);
+ *s = qRgba(qRed(r), qGreen(r), qBlue(r), 255 - k);
+ s++;
+ }
+ }
+ imageMask = cairo_image_surface_create_for_data ((uchar*)imageQ.bits(), CAIRO_FORMAT_ARGB32, w, h, w*4);
+ }
+ else
+ imageMask = cairo_image_surface_create_for_data ((uchar*)m_maskPattern->getPattern()->bits(), CAIRO_FORMAT_ARGB32, m_maskPattern->getPattern()->width(), m_maskPattern->getPattern()->height(), m_maskPattern->getPattern()->width()*4);
+ pat = cairo_pattern_create_for_surface(imageMask);
cairo_pattern_set_extend(pat, CAIRO_EXTEND_REPEAT);
cairo_pattern_set_filter(pat, CAIRO_FILTER_BEST);
cairo_matrix_t matrix;
@@ -1240,6 +1273,8 @@
#endif
cairo_clip_preserve(m_cr);
cairo_mask(m_cr, pat);
+ if ((maskMode == 2) || (maskMode == 4))
+ cairo_surface_destroy(imageMask);
cairo_pattern_destroy(pat);
}
else
@@ -1310,6 +1345,8 @@
setRasterOp(m_blendModeFill);
#endif
cairo_mask(m_cr, patM);
+ if ((maskMode == 2) || (maskMode == 4))
+ cairo_surface_destroy(imageMask);
cairo_pattern_destroy (patM);
}
else
@@ -1351,6 +1388,8 @@
setRasterOp(m_blendModeFill);
#endif
cairo_mask(m_cr, patM);
+ if ((maskMode == 2) || (maskMode == 4))
+ cairo_surface_destroy(imageMask);
cairo_pattern_destroy (patM);
}
else
@@ -2044,6 +2083,8 @@
{
cairo_pattern_t *patM = getMaskPattern();
cairo_mask(m_cr, patM);
+ if ((maskMode == 2) || (maskMode == 4))
+ cairo_surface_destroy(imageMask);
cairo_pattern_destroy(patM);
}
else
Index: scribus/pageitem.cpp
===================================================================
--- scribus/pageitem.cpp (revision 14317)
+++ scribus/pageitem.cpp (revision 14318)
@@ -1271,27 +1271,33 @@
p->setPenOpacity(1.0 - lineTransparency());
#endif
p->setFillRule(fillRule);
- if ((GrMask == 1) || (GrMask == 2))
+ if ((GrMask == 1) || (GrMask == 2) || (GrMask == 4) || (GrMask == 5))
{
- p->setMaskMode(1);
+ if ((GrMask == 1) || (GrMask == 2))
+ p->setMaskMode(1);
+ else
+ p->setMaskMode(3);
if ((!gradientMaskVal.isEmpty()) && (!m_Doc->docGradients.contains(gradientMaskVal)))
gradientMaskVal = "";
if (!(gradientMaskVal.isEmpty()) && (m_Doc->docGradients.contains(gradientMaskVal)))
mask_gradient = m_Doc->docGradients[gradientMaskVal];
p->mask_gradient = mask_gradient;
- if (GrMask == 1)
+ if ((GrMask == 1) || (GrMask == 4))
p->setGradientMask(VGradient::linear, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskStartX, GrMaskStartY), GrMaskScale, GrMaskSkew);
else
p->setGradientMask(VGradient::radial, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskFocalX, GrMaskFocalY), GrMaskScale, GrMaskSkew);
}
- else if (GrMask == 3)
+ else if ((GrMask == 3) || (GrMask == 6))
{
if ((patternMaskVal.isEmpty()) || (!m_Doc->docPatterns.contains(patternMaskVal)))
p->setMaskMode(0);
else
{
p->setPatternMask(&m_Doc->docPatterns[patternMaskVal], patternMaskScaleX, patternMaskScaleY, patternMaskOffsetX, patternMaskOffsetY, patternMaskRotation, patternMaskSkewX, patternMaskSkewY, patternMaskMirrorX, patternMaskMirrorY);
- p->setMaskMode(2);
+ if (GrMask == 3)
+ p->setMaskMode(2);
+ else
+ p->setMaskMode(4);
}
}
else
@@ -4427,7 +4433,7 @@
lists.collectColor(cstops.at(cst)->name);
}
}
- if ((GrMask == 1) || (GrMask == 2))
+ if ((GrMask == 1) || (GrMask == 2) || (GrMask == 4) || (GrMask == 5))
{
QList<VColorStop*> cstops = mask_gradient.colorStops();
for (uint cst = 0; cst < mask_gradient.Stops(); ++cst)
Index: scribus/scribusview.cpp
===================================================================
--- scribus/scribusview.cpp (revision 14317)
+++ scribus/scribusview.cpp (revision 14318)
@@ -3884,7 +3884,7 @@
currItem->GrStrokeSkew = Buffer->GrStrokeSkew;
}
currItem->GrMask = Buffer->GrMask;
- if (currItem->GrMask == 1)
+ if ((currItem->GrMask == 1) || (currItem->GrMask == 2) || (currItem->GrMask == 4) || (currItem->GrMask == 5))
{
currItem->mask_gradient = Buffer->mask_gradient;
currItem->GrMaskStartX = Buffer->GrMaskStartX;
@@ -3896,7 +3896,7 @@
currItem->GrMaskScale = Buffer->GrMaskScale;
currItem->GrMaskSkew = Buffer->GrMaskSkew;
}
- else if (currItem->GrMask == 3)
+ else if ((currItem->GrMask == 3) || (currItem->GrMask == 6))
{
currItem->setPatternMask(Buffer->patternMaskVal);
currItem->setMaskTransform(Buffer->patternMaskScaleX, Buffer->patternMaskScaleY, Buffer->patternMaskOffsetX, Buffer->patternMaskOffsetY, Buffer->patternMaskRotation, Buffer->patternMaskSkewX, Buffer->patternMaskSkewY);
Index: scribus/ui/transparencypalette.ui
===================================================================
--- scribus/ui/transparencypalette.ui (revision 14317)
+++ scribus/ui/transparencypalette.ui (revision 14318)
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>236</width>
- <height>335</height>
+ <height>357</height>
</rect>
</property>
<property name="windowTitle">
@@ -348,6 +348,13 @@
<item>
<widget class="ScComboBox" name="namedGradient"/>
</item>
+ <item>
+ <widget class="QCheckBox" name="transpCalcGradient">
+ <property name="text">
+ <string>Use Luminosity as Alpha</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<widget class="QWidget" name="tabPattern">
@@ -410,6 +417,13 @@
</item>
</layout>
</item>
+ <item>
+ <widget class="QCheckBox" name="transpCalcPattern">
+ <property name="text">
+ <string>Use Luminosity as Alpha</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</widget>
Index: scribus/ui/transparencypalette.h
===================================================================
--- scribus/ui/transparencypalette.h (revision 14317)
+++ scribus/ui/transparencypalette.h (revision 14318)
@@ -74,6 +74,8 @@
void slotGrad(int nr);
void slotGradType(int type);
void setNamedGradient(const QString &name);
+ void switchGradientMode();
+ void switchPatternMode();
void editGradientVector();
void setActiveGradDia(bool active);
void updatePatternList();
Index: scribus/ui/propertiespalette.cpp
===================================================================
--- scribus/ui/propertiespalette.cpp (revision 14317)
+++ scribus/ui/propertiespalette.cpp (revision 14318)
@@ -4733,7 +4733,7 @@
CurItem->GrMaskFocalY = fy / m_unitRatio;
CurItem->GrMaskScale = sg;
CurItem->GrMaskSkew = sk;
- if (CurItem->GrMask == 1)
+ if ((CurItem->GrMask == 1) || (CurItem->GrMask == 4))
{
CurItem->GrMaskFocalX = CurItem->GrMaskStartX;
CurItem->GrMaskFocalY = CurItem->GrMaskStartY;
Index: scribus/ui/transparencypalette.cpp
===================================================================
--- scribus/ui/transparencypalette.cpp (revision 14317)
+++ scribus/ui/transparencypalette.cpp (revision 14318)
@@ -56,6 +56,8 @@
connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotGrad(int)));
connect(patternBox, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(selectPattern(QListWidgetItem*)));
connect(editPatternProps, SIGNAL(clicked()), this, SLOT(changePatternProps()));
+ connect(transpCalcGradient, SIGNAL(clicked()), this, SLOT(switchGradientMode()));
+ connect(transpCalcPattern, SIGNAL(clicked()), this, SLOT(switchPatternMode()));
}
void Tpalette::setCurrentItem(PageItem* item)
@@ -85,6 +87,8 @@
disconnect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
disconnect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotGrad(int)));
disconnect(gradientType, SIGNAL(activated(int)), this, SLOT(slotGradType(int)));
+ disconnect(transpCalcGradient, SIGNAL(clicked()), this, SLOT(switchGradientMode()));
+ disconnect(transpCalcPattern, SIGNAL(clicked()), this, SLOT(switchPatternMode()));
gradEdit->setGradient(currentItem->mask_gradient);
if (!currentItem->gradientMask().isEmpty())
{
@@ -98,7 +102,7 @@
}
if (currentItem->GrMask == 0)
tabWidget->setCurrentIndex(0);
- else if ((currentItem->GrMask == 1) || (currentItem->GrMask == 2))
+ else if ((currentItem->GrMask == 1) || (currentItem->GrMask == 2) || (currentItem->GrMask == 4) || (currentItem->GrMask == 5))
tabWidget->setCurrentIndex(1);
else
tabWidget->setCurrentIndex(2);
@@ -106,10 +110,18 @@
tabWidget->setTabEnabled(2, false);
else
tabWidget->setTabEnabled(2, true);
+ transpCalcGradient->setChecked(false);
+ transpCalcPattern->setChecked(false);
+ if ((currentItem->GrMask == 4) || (currentItem->GrMask == 5))
+ transpCalcGradient->setChecked(true);
+ if (currentItem->GrMask == 6)
+ transpCalcPattern->setChecked(true);
connect(gradEdit, SIGNAL(gradientChanged()), this, SIGNAL(gradientChanged()));
connect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotGrad(int)));
connect(gradientType, SIGNAL(activated(int)), this, SLOT(slotGradType(int)));
+ connect(transpCalcGradient, SIGNAL(clicked()), this, SLOT(switchGradientMode()));
+ connect(transpCalcPattern, SIGNAL(clicked()), this, SLOT(switchPatternMode()));
}
void Tpalette::updateCList()
@@ -178,13 +190,28 @@
gradEdit->setGradientEditable(true);
}
if (gradientType->currentIndex() == 0)
- emit NewGradient(1);
+ {
+ if (transpCalcGradient->isChecked())
+ emit NewGradient(4);
+ else
+ emit NewGradient(1);
+ }
else
- emit NewGradient(2);
+ {
+ if (transpCalcGradient->isChecked())
+ emit NewGradient(5);
+ else
+ emit NewGradient(2);
+ }
connect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
}
else if (number == 2)
- emit NewGradient(3);
+ {
+ if (transpCalcPattern->isChecked())
+ emit NewGradient(6);
+ else
+ emit NewGradient(3);
+ }
else
emit NewGradient(0);
}
@@ -192,9 +219,19 @@
void Tpalette::slotGradType(int type)
{
if (type == 0)
- emit NewGradient(1);
+ {
+ if (transpCalcGradient->isChecked())
+ emit NewGradient(4);
+ else
+ emit NewGradient(1);
+ }
else
- emit NewGradient(2);
+ {
+ if (transpCalcGradient->isChecked())
+ emit NewGradient(5);
+ else
+ emit NewGradient(2);
+ }
}
void Tpalette::setNamedGradient(const QString &name)
@@ -212,18 +249,55 @@
currentItem->setGradient(name);
}
if (gradientType->currentIndex() == 0)
- emit NewGradient(1);
+ {
+ if (transpCalcGradient->isChecked())
+ emit NewGradient(4);
+ else
+ emit NewGradient(1);
+ }
else
- emit NewGradient(2);
+ {
+ if (transpCalcGradient->isChecked())
+ emit NewGradient(5);
+ else
+ emit NewGradient(2);
+ }
}
+void Tpalette::switchGradientMode()
+{
+ if (gradientType->currentIndex() == 0)
+ {
+ if (transpCalcGradient->isChecked())
+ emit NewGradient(4);
+ else
+ emit NewGradient(1);
+ }
+ else
+ {
+ if (transpCalcGradient->isChecked())
+ emit NewGradient(5);
+ else
+ emit NewGradient(2);
+ }
+}
+
+void Tpalette::switchPatternMode()
+{
+ if (transpCalcPattern->isChecked())
+ emit NewGradient(6);
+ else
+ emit NewGradient(3);
+
+}
+
void Tpalette::editGradientVector()
{
if (gradEditButton->isChecked())
{
TGradDia->unitChange(currentDoc->unitIndex());
TGradDia->setValues(currentItem->GrMaskStartX, currentItem->GrMaskStartY, currentItem->GrMaskEndX, currentItem->GrMaskEndY, currentItem->GrMaskFocalX, currentItem->GrMaskFocalY, currentItem->GrMaskScale, currentItem->GrMaskSkew);
- if (currentItem->GrMask == 1)
+ if ((currentItem->GrMask == 1) || (currentItem->GrMask == 4))
TGradDia->hideExtraWidgets();
else
TGradDia->showExtraWidgets();
Index: scribus/plugins/xarimplugin/importxar.cpp
===================================================================
--- scribus/plugins/xarimplugin/importxar.cpp (revision 14317)
+++ scribus/plugins/xarimplugin/importxar.cpp (revision 14318)
@@ -353,7 +353,7 @@
XarColorMap.insert(-3, color);
if (!m_Doc->PageColors.contains("Red"))
{
- m_Doc->PageColors.insert("Red", ScColor(0, 255, 255, 0));
+ m_Doc->PageColors.insert("Red", ScColor(255, 0, 0));
importedColors.append("Red");
}
color.name = "Red";
@@ -872,6 +872,7 @@
int w = image.width();
int k;
int ts = transStart;
+ int te = transEnd;
QRgb *s;
QRgb r;
for( int yi=0; yi < h; ++yi )
@@ -881,7 +882,9 @@
{
r = *s;
k = qMin(qRound(0.3 * qRed(r) + 0.59 * qGreen(r) + 0.11 * qBlue(r)), 255);
- k = qMax(qRound(k / 255.0 * transEnd), ts);
+ if (qAlpha(r) == 0)
+ k = 255;
+ k = qBound(ts, k, te);
*s = qRgba(qRed(r), qGreen(r), qBlue(r), 255 - k);
s++;
}
Index: scribus/plugins/fileloader/scribus150format/scribus150format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus150format/scribus150format.cpp (revision 14317)
+++ scribus/plugins/fileloader/scribus150format/scribus150format.cpp (revision 14318)
@@ -2866,9 +2866,9 @@
bool mirrorYm = attrs.valueAsBool("pMirrorYM", false);
currItem->setMaskFlip(mirrorXm, mirrorYm);
currItem->GrMask = attrs.valueAsInt("GRTYPM", 0);
- if (currItem->GrMask == 1)
+ if ((currItem->GrMask == 1) || (currItem->GrMask == 4))
currItem->mask_gradient = VGradient(VGradient::linear);
- else
+ else if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
currItem->mask_gradient = VGradient(VGradient::radial);
currItem->mask_gradient.clearStops();
currItem->GrMaskStartX = attrs.valueAsDouble("GRSTARTXM", 0.0);
Index: scribus/scpainter.h
===================================================================
--- scribus/scpainter.h (revision 14317)
+++ scribus/scpainter.h (revision 14318)
@@ -128,6 +128,8 @@
bool pushed;
};
cairo_pattern_t *getMaskPattern();
+ cairo_surface_t *imageMask;
+ QImage imageQ;
#else
QPainter painter;
QPainterPath m_path;
More information about the scribus-commit
mailing list