22 const QTransform t = painter.transform();
24 QRegion region = t.type() <= QTransform::TxScale ?
25 painter.clipRegion() :
26 QRegion(painter.clipBoundingRect().toAlignedRect());
28 if (region.rectCount() > 1000) {
29 qWarning() <<
"WARNING: KisPaintingTweaks::safeClipRegion: too many rectangles in the region!" <<
ppVar(region.rectCount());
30 region = QRegion(painter.clipBoundingRect().toAlignedRect());
38 return painter.clipBoundingRect().toAlignedRect();
42 int antLength,
int antSpace,
43 QColor black, QColor white)
46 antDashPattern << antLength << antSpace;
48 *antsPen = QPen(Qt::CustomDashLine);
49 antsPen->setDashPattern(antDashPattern);
50 antsPen->setCosmetic(
true);
51 antsPen->setColor(black);
53 *outlinePen = QPen(Qt::SolidLine);
54 outlinePen->setCosmetic(
true);
55 outlinePen->setColor(white);
60 m_pen(painter->pen()),
61 m_brush(painter->brush())
100 const qreal
r2 = 1.0 -
r1;
102 return QColor::fromRgbF(
103 c1.redF() *
r1 + c2.redF() *
r2,
104 c1.greenF() *
r1 + c2.greenF() *
r2,
105 c1.blueF() *
r1 + c2.blueF() *
r2);
110 const qreal dr = c1.redF() - c2.redF();
111 const qreal dg = c1.greenF() - c2.greenF();
112 const qreal db = c1.blueF() - c2.blueF();
114 return std::sqrt(2 *
pow2(dr) + 4 *
pow2(dg) + 3 *
pow2(db));
117void dragColor(QColor *color,
const QColor &baseColor, qreal threshold)
121 QColor newColor = *color;
123 if (newColor.lightnessF() > baseColor.lightnessF()) {
124 newColor = newColor.lighter(120);
126 newColor = newColor.darker(120);
129 if (newColor == *color) {
172 qreal g = c.greenF();
185 qreal lumi = (r * .2126) + (g * .7152) + (b * .0722);
186 if (sRGBtrc && lumi < 1.0) {
PenBrushSaver(QPainter *painter)
static QMap< qreal, qreal > linearToSRGBTRC
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)
static QMap< qreal, qreal > sRgbTRCToLinear
void initAntsPen(QPen *antsPen, QPen *outlinePen, int antLength, int antSpace, QColor black, QColor white)