Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_color_source_option.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2011 Cyrille Berger <cberger@cberger.net>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
8
10#include "kis_color_source.h"
11#include <kis_painter.h>
12#include <kis_paint_device.h>
13#include <resources/KoPattern.h>
15
23
25 : d(new Private)
26{
28 data.read(setting);
29 d->type = data.type;
30}
31
35
37{
38 Q_ASSERT(_painter);
39
40 switch (d->type) {
42 return new KisPlainColorSource(_painter->backgroundColor(), _painter->paintColor());
44 return new KisGradientColorSource(_painter->gradient(), _painter->paintColor().colorSpace());
46 return new KisUniformRandomColorSource();
48 return new KisTotalRandomColorSource();
50 if (_painter->pattern()) {
51 KisPaintDevice* dev = new KisPaintDevice(_painter->paintColor().colorSpace(), _painter->pattern()->name());
52 dev->convertFromQImage(_painter->pattern()->pattern(), 0);
53 return new KoPatternColorSource(dev, _painter->pattern()->width(), _painter->pattern()->height(), false);
54 }
55 break;
56 }
58 if (_painter->pattern()) {
59 KisPaintDevice* dev = new KisPaintDevice(_painter->paintColor().colorSpace(), _painter->pattern()->name());
60 dev->convertFromQImage(_painter->pattern()->pattern(), 0);
61 return new KoPatternColorSource(dev, _painter->pattern()->width(), _painter->pattern()->height(), true);
62 }
63
64 }
65 }
66 // Fallback in case the patterns are messed up
67 return new KisPlainColorSource(_painter->backgroundColor(), _painter->paintColor());
68}
const QScopedPointer< Private > d
KisColorSourceOption(const KisPropertiesConfiguration *setting)
KisColorSource * createColorSource(const KisPainter *_painter) const
void convertFromQImage(const QImage &image, const KoColorProfile *profile, qint32 offsetX=0, qint32 offsetY=0)
KoColor paintColor
KoColor backgroundColor
KoAbstractGradientSP gradient
KoPatternSP pattern
const KoColorSpace * colorSpace() const
return the current colorSpace
Definition KoColor.h:82
bool read(const KisPropertiesConfiguration *setting)
KisColorSourceOptionData::Type type