Krita Source Code Documentation
Loading...
Searching...
No Matches
KoVectorPatternBackground.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <QTransform>
10#include <KoShape.h>
11#include <KoShapePainter.h>
13
36
42
47
49{
50 Q_UNUSED(other);
51 return false;
52}
53
58
60{
61 return d->referenceCoordinates;
62}
63
68
70{
71 return d->contentCoordinates;
72}
73
75{
76 d->referenceRect = value;
77}
78
80{
81 return d->referenceRect;
82}
83
85{
86 d->patternTransform = value;
87}
88
90{
91 return d->patternTransform;
92}
93
95{
96 qDeleteAll(d->shapes);
97 d->shapes.clear();
98
99 d->shapes = value;
100}
101
103{
104 return d->shapes;
105}
106
107void KoVectorPatternBackground::paint(QPainter &painter, const QPainterPath &fillPath) const
108{
109 const QPainterPath dstShapeOutline = fillPath;
110 const QRectF dstShapeBoundingBox = dstShapeOutline.boundingRect();
111
112 KoBakedShapeRenderer renderer(dstShapeOutline, QTransform(),
113 QTransform(),
114 d->referenceRect,
115 d->contentCoordinates != KoFlake::UserSpaceOnUse,
116 dstShapeBoundingBox,
117 d->referenceCoordinates != KoFlake::UserSpaceOnUse,
118 d->patternTransform);
119
120 QPainter *patchPainter = renderer.bakeShapePainter();
121
123 p.setShapes(d->shapes);
124 p.paint(*patchPainter);
125
126 // uncomment for debug
127 // renderer.patchImage().save("dd_patch_image.png");
128
129 painter.setPen(Qt::NoPen);
130 renderer.renderShape(painter);
131}
132
134{
135 return true;
136}
float value(const T *src, size_t ch)
const Params2D p
void setShapes(const QList< KoShape * > &shapes)
bool compareTo(const KoShapeBackground *other) const override
void setReferenceCoordinates(KoFlake::CoordinateSystem value)
void setContentCoordinates(KoFlake::CoordinateSystem value)
void setReferenceRect(const QRectF &value)
void setPatternTransform(const QTransform &value)
void setShapes(const QList< KoShape * > value)
KoFlake::CoordinateSystem contentCoordinates() const
QList< KoShape * > shapes() const
KoFlake::CoordinateSystem referenceCoordinates() const
bool hasTransparency() const override
Returns if the background has some transparency.
QSharedDataPointer< Private > d
void paint(QPainter &painter, const QPainterPath &fillPath) const override
Paints the background using the given fill path.
void renderShape(QPainter &painter)