Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShapeFillWrapper::Private Struct Reference

Public Member Functions

QSharedPointer< KoShapeBackgroundapplyFillGradientStops (KoShape *shape, const QGradient *srcQGradient)
 
void applyFillGradientStops (KoShapeStrokeSP shapeStroke, const QGradient *stopGradient)
 

Public Attributes

KoFlake::FillVariant fillVariant = KoFlake::Fill
 
QList< KoShape * > shapes
 

Detailed Description

Definition at line 165 of file KoShapeFillWrapper.cpp.

Member Function Documentation

◆ applyFillGradientStops() [1/2]

QSharedPointer< KoShapeBackground > KoShapeFillWrapper::Private::applyFillGradientStops ( KoShape * shape,
const QGradient * srcQGradient )

Definition at line 174 of file KoShapeFillWrapper.cpp.

175{
176 QGradientStops stops = stopGradient->stops();
177
178 if (!shape || !stops.count()) {
180 }
181
182 KoGradientBackground *newGradient = 0;
183 QSharedPointer<KoGradientBackground> oldGradient = qSharedPointerDynamicCast<KoGradientBackground>(shape->background());
184 if (oldGradient) {
185 // just copy the gradient and set the new stops
186 QGradient *g = KoFlake::mergeGradient(oldGradient->gradient(), stopGradient);
187 newGradient = new KoGradientBackground(g);
188 newGradient->setTransform(oldGradient->transform());
189 }
190 else {
191 // No gradient yet, so create a new one.
192 QScopedPointer<QLinearGradient> fakeShapeGradient(new QLinearGradient(QPointF(0, 0), QPointF(1, 1)));
193 fakeShapeGradient->setCoordinateMode(QGradient::ObjectBoundingMode);
194
195 QGradient *g = KoFlake::mergeGradient(fakeShapeGradient.data(), stopGradient);
196 newGradient = new KoGradientBackground(g);
197 }
198 return QSharedPointer<KoGradientBackground>(newGradient);
199}
A gradient shape background.
void setTransform(const QTransform &matrix)
Sets the transform matrix.
virtual QSharedPointer< KoShapeBackground > background() const
Definition KoShape.cpp:926
KRITAFLAKE_EXPORT QGradient * mergeGradient(const QGradient *coordsSource, const QGradient *fillSource)
Definition KoFlake.cpp:54

References KoShape::background(), KoFlake::mergeGradient(), and KoGradientBackground::setTransform().

◆ applyFillGradientStops() [2/2]

void KoShapeFillWrapper::Private::applyFillGradientStops ( KoShapeStrokeSP shapeStroke,
const QGradient * stopGradient )

Definition at line 201 of file KoShapeFillWrapper.cpp.

202{
203 QGradientStops stops = stopGradient->stops();
204 if (!stops.count()) return;
205
206 QLinearGradient fakeShapeGradient(QPointF(0, 0), QPointF(1, 1));
207 fakeShapeGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
208 QTransform gradientTransform;
209 const QGradient *shapeGradient = 0;
210
211 {
212 QBrush brush = shapeStroke->lineBrush();
213 gradientTransform = brush.transform();
214 shapeGradient = brush.gradient() ? brush.gradient() : &fakeShapeGradient;
215 }
216
217 {
218 QScopedPointer<QGradient> g(KoFlake::mergeGradient(shapeGradient, stopGradient));
219 QBrush newBrush = *g;
220 newBrush.setTransform(gradientTransform);
221 shapeStroke->setLineBrush(newBrush);
222 }
223}
QTransform gradientTransform() const

References KoShapeFillWrapper::gradientTransform(), and KoFlake::mergeGradient().

Member Data Documentation

◆ fillVariant

KoFlake::FillVariant KoShapeFillWrapper::Private::fillVariant = KoFlake::Fill

Definition at line 168 of file KoShapeFillWrapper.cpp.

◆ shapes

QList<KoShape*> KoShapeFillWrapper::Private::shapes

Definition at line 167 of file KoShapeFillWrapper.cpp.


The documentation for this struct was generated from the following file: