Krita Source Code Documentation
Loading...
Searching...
No Matches
KoMeshGradientBackground Class Reference

#include <KoMeshGradientBackground.h>

+ Inheritance diagram for KoMeshGradientBackground:

Classes

class  Private
 

Public Member Functions

bool compareTo (const KoShapeBackground *other) const override
 
SvgMeshGradientgradient ()
 
 KoMeshGradientBackground (const KoMeshGradientBackground &)
 
 KoMeshGradientBackground (const SvgMeshGradient *gradient, const QTransform &matrix=QTransform())
 
KoMeshGradientBackgroundoperator= (const KoMeshGradientBackground &)
 
void paint (QPainter &painter, const QPainterPath &fillPath) const override
 Paints the background using the given fill path.
 
QTransform transform ()
 
 ~KoMeshGradientBackground ()
 
- Public Member Functions inherited from KoShapeBackground
virtual bool hasTransparency () const
 Returns if the background has some transparency.
 
 KoShapeBackground ()
 
virtual operator bool () const
 
virtual ~KoShapeBackground ()
 

Private Attributes

QSharedDataPointer< Privated
 

Detailed Description

Definition at line 12 of file KoMeshGradientBackground.h.

Constructor & Destructor Documentation

◆ KoMeshGradientBackground() [1/2]

KoMeshGradientBackground::KoMeshGradientBackground ( const SvgMeshGradient * gradient,
const QTransform & matrix = QTransform() )

Definition at line 43 of file KoMeshGradientBackground.cpp.

45 , d(new Private)
46{
47 d->gradient.reset(new SvgMeshGradient(*gradient));
48 d->matrix = matrix;
49 Q_ASSERT(d->gradient);
50}
QSharedDataPointer< Private > d

References d, and gradient().

◆ ~KoMeshGradientBackground()

KoMeshGradientBackground::~KoMeshGradientBackground ( )

Definition at line 52 of file KoMeshGradientBackground.cpp.

53{
54}

◆ KoMeshGradientBackground() [2/2]

KoMeshGradientBackground::KoMeshGradientBackground ( const KoMeshGradientBackground & rhs)

Definition at line 56 of file KoMeshGradientBackground.cpp.

57 : d(new Private(*rhs.d))
58{
59}

Member Function Documentation

◆ compareTo()

bool KoMeshGradientBackground::compareTo ( const KoShapeBackground * other) const
overridevirtual

Implements KoShapeBackground.

Definition at line 105 of file KoMeshGradientBackground.cpp.

106{
107 return false;
108}

◆ gradient()

SvgMeshGradient * KoMeshGradientBackground::gradient ( )

Definition at line 110 of file KoMeshGradientBackground.cpp.

111{
112 return d->gradient.data();
113}

References d.

◆ operator=()

KoMeshGradientBackground & KoMeshGradientBackground::operator= ( const KoMeshGradientBackground & rhs)

Definition at line 60 of file KoMeshGradientBackground.cpp.

61{
62 d = rhs.d;
63 return *this;
64}

References d.

◆ paint()

void KoMeshGradientBackground::paint ( QPainter & painter,
const QPainterPath & fillPath ) const
overridevirtual

Paints the background using the given fill path.

Implements KoShapeBackground.

Definition at line 66 of file KoMeshGradientBackground.cpp.

68{
69 if (!d->gradient || !d->gradient->isValid()) return;
70 painter.save();
71
72 QScopedPointer<SvgMeshGradient> gradient(new SvgMeshGradient(*d->gradient));
73
74 QRectF meshBoundingRect = gradient->boundingRect();
75
77 const QTransform relativeToShape = KisAlgebra2D::mapToRect(fillPath.boundingRect());
78 gradient->setTransform(relativeToShape);
79 meshBoundingRect = gradient->boundingRect();
80 }
81
82 if (d->renderer->patchImage()->isNull()) {
83
84 d->renderer->configure(meshBoundingRect, painter.transform());
85 SvgMeshArray *mesharray = gradient->getMeshArray().data();
86
87 for (int row = 0; row < mesharray->numRows(); ++row) {
88 for (int col = 0; col < mesharray->numColumns(); ++col) {
89 SvgMeshPatch *patch = mesharray->getPatch(row, col);
90 d->renderer->fillPatch(patch, gradient->type(), mesharray, row, col);
91 }
92 }
93 // uncomment to debug
94 // d->renderer->patchImage()->save("mesh-patch.png");
95 }
96
97 painter.setClipPath(fillPath);
98
99 // patch is to be drawn wrt. to "user" coordinates
100 painter.drawImage(meshBoundingRect, *d->renderer->patchImage());
101
102 painter.restore();
103}
int numRows() const
int numColumns() const
SvgMeshPatch * getPatch(const int row, const int col) const
void setTransform(const QTransform &matrix)
SvgMeshGradient::Shading type() const
QRectF boundingRect() const
const QScopedPointer< SvgMeshArray > & getMeshArray() const
KoFlake::CoordinateSystem gradientUnits() const
QTransform mapToRect(const QRectF &rect)

References SvgMeshGradient::boundingRect(), d, SvgMeshGradient::getMeshArray(), SvgMeshArray::getPatch(), gradient(), SvgMeshGradient::gradientUnits(), KisAlgebra2D::mapToRect(), SvgMeshArray::numColumns(), SvgMeshArray::numRows(), KoFlake::ObjectBoundingBox, SvgMeshGradient::setTransform(), and SvgMeshGradient::type().

◆ transform()

QTransform KoMeshGradientBackground::transform ( )

Definition at line 115 of file KoMeshGradientBackground.cpp.

116{
117 return d->matrix;
118}

References d.

Member Data Documentation

◆ d

QSharedDataPointer<Private> KoMeshGradientBackground::d
private

Definition at line 31 of file KoMeshGradientBackground.h.


The documentation for this class was generated from the following files: