Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_painting_tweaks.h
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
7#ifndef __KIS_PAINTING_TWEAKS_H
8#define __KIS_PAINTING_TWEAKS_H
9
10#include "kritaglobal_export.h"
11
12#include <QPen>
13#include <QBrush>
14
15#include <QVector3D>
16#include <QVector2D>
17
18class QPainter;
19class QRegion;
20class QRect;
21class QPen;
22
23namespace KisPaintingTweaks {
24
32 KRITAGLOBAL_EXPORT QRegion safeClipRegion(const QPainter &painter);
33
37 KRITAGLOBAL_EXPORT QRect safeClipBoundingRect(const QPainter &painter);
38
39 KRITAGLOBAL_EXPORT void initAntsPen(QPen *antsPen, QPen *outlinePen,
40 int antLength = 4, int antSpace = 4,
41 QColor black = QColor(Qt::black), QColor white = QColor(Qt::white));
42
43
48 class KRITAGLOBAL_EXPORT PenBrushSaver
49 {
50 public:
51 struct allow_noop_t { explicit allow_noop_t() = default; };
52 static constexpr allow_noop_t allow_noop { };
53
57 PenBrushSaver(QPainter *painter);
58
62 PenBrushSaver(QPainter *painter, const QPen &pen, const QBrush &brush);
63
67 PenBrushSaver(QPainter *painter, const QPair<QPen, QBrush> &pair);
68
73 PenBrushSaver(QPainter *painter, const QPair<QPen, QBrush> &pair, allow_noop_t);
74
79
80 private:
81 PenBrushSaver(const PenBrushSaver &rhs) = delete;
82 QPainter *m_painter;
83 QPen m_pen;
84 QBrush m_brush;
85 };
86
87 QColor KRITAGLOBAL_EXPORT blendColors(const QColor &c1, const QColor &c2, qreal r1);
88
89
101 qreal KRITAGLOBAL_EXPORT luminosityCoarse(const QColor &c, bool sRGBtrc = true);
102
110 qreal KRITAGLOBAL_EXPORT colorDifference(const QColor &c1, const QColor &c2);
111
115 void KRITAGLOBAL_EXPORT dragColor(QColor *color, const QColor &baseColor, qreal threshold);
116
117 inline void rectToVertices(QVector3D* vertices, const QRectF &rc)
118 {
119 vertices[0] = QVector3D(rc.left(), rc.bottom(), 0.f);
120 vertices[1] = QVector3D(rc.left(), rc.top(), 0.f);
121 vertices[2] = QVector3D(rc.right(), rc.bottom(), 0.f);
122 vertices[3] = QVector3D(rc.left(), rc.top(), 0.f);
123 vertices[4] = QVector3D(rc.right(), rc.top(), 0.f);
124 vertices[5] = QVector3D(rc.right(), rc.bottom(), 0.f);
125 }
126
127 inline void rectToTexCoords(QVector2D* texCoords, const QRectF &rc)
128 {
129 texCoords[0] = QVector2D(rc.left(), rc.bottom());
130 texCoords[1] = QVector2D(rc.left(), rc.top());
131 texCoords[2] = QVector2D(rc.right(), rc.bottom());
132 texCoords[3] = QVector2D(rc.left(), rc.top());
133 texCoords[4] = QVector2D(rc.right(), rc.top());
134 texCoords[5] = QVector2D(rc.right(), rc.bottom());
135 }
136}
137
138#endif /* __KIS_PAINTING_TWEAKS_H */
QPointF r1
PenBrushSaver(const PenBrushSaver &rhs)=delete
qreal luminosityCoarse(const QColor &c, bool sRGBtrc)
luminosityCoarse This calculates the luminosity of the given QColor. It uses a very coarse (10 step) ...
QColor blendColors(const QColor &c1, const QColor &c2, qreal r1)
qreal colorDifference(const QColor &c1, const QColor &c2)
QRegion safeClipRegion(const QPainter &painter)
void dragColor(QColor *color, const QColor &baseColor, qreal threshold)
QRect safeClipBoundingRect(const QPainter &painter)
void rectToTexCoords(QVector2D *texCoords, const QRectF &rc)
void initAntsPen(QPen *antsPen, QPen *outlinePen, int antLength, int antSpace, QColor black, QColor white)
void rectToVertices(QVector3D *vertices, const QRectF &rc)