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
42
47 class KRITAGLOBAL_EXPORT PenBrushSaver
48 {
49 public:
50 struct allow_noop_t { explicit allow_noop_t() = default; };
51 static constexpr allow_noop_t allow_noop { };
52
56 PenBrushSaver(QPainter *painter);
57
61 PenBrushSaver(QPainter *painter, const QPen &pen, const QBrush &brush);
62
66 PenBrushSaver(QPainter *painter, const QPair<QPen, QBrush> &pair);
67
72 PenBrushSaver(QPainter *painter, const QPair<QPen, QBrush> &pair, allow_noop_t);
73
78
79 private:
80 PenBrushSaver(const PenBrushSaver &rhs) = delete;
81 QPainter *m_painter;
82 QPen m_pen;
83 QBrush m_brush;
84 };
85
86 QColor KRITAGLOBAL_EXPORT blendColors(const QColor &c1, const QColor &c2, qreal r1);
87
88
100 qreal KRITAGLOBAL_EXPORT luminosityCoarse(const QColor &c, bool sRGBtrc = true);
101
109 qreal KRITAGLOBAL_EXPORT colorDifference(const QColor &c1, const QColor &c2);
110
114 void KRITAGLOBAL_EXPORT dragColor(QColor *color, const QColor &baseColor, qreal threshold);
115
116 inline void rectToVertices(QVector3D* vertices, const QRectF &rc)
117 {
118 vertices[0] = QVector3D(rc.left(), rc.bottom(), 0.f);
119 vertices[1] = QVector3D(rc.left(), rc.top(), 0.f);
120 vertices[2] = QVector3D(rc.right(), rc.bottom(), 0.f);
121 vertices[3] = QVector3D(rc.left(), rc.top(), 0.f);
122 vertices[4] = QVector3D(rc.right(), rc.top(), 0.f);
123 vertices[5] = QVector3D(rc.right(), rc.bottom(), 0.f);
124 }
125
126 inline void rectToTexCoords(QVector2D* texCoords, const QRectF &rc)
127 {
128 texCoords[0] = QVector2D(rc.left(), rc.bottom());
129 texCoords[1] = QVector2D(rc.left(), rc.top());
130 texCoords[2] = QVector2D(rc.right(), rc.bottom());
131 texCoords[3] = QVector2D(rc.left(), rc.top());
132 texCoords[4] = QVector2D(rc.right(), rc.top());
133 texCoords[5] = QVector2D(rc.right(), rc.bottom());
134 }
135}
136
137#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) ...
void initAntsPen(QPen *antsPen, QPen *outlinePen, int antLength, int antSpace)
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 rectToVertices(QVector3D *vertices, const QRectF &rc)