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)
45 antDashPattern << antLength << antSpace;
47 *antsPen = QPen(Qt::CustomDashLine);
48 antsPen->setDashPattern(antDashPattern);
49 antsPen->setCosmetic(
true);
50 antsPen->setColor(Qt::black);
52 *outlinePen = QPen(Qt::SolidLine);
53 outlinePen->setCosmetic(
true);
54 outlinePen->setColor(Qt::white);
59 m_pen(painter->pen()),
60 m_brush(painter->brush())
99 const qreal
r2 = 1.0 -
r1;
101 return QColor::fromRgbF(
102 c1.redF() *
r1 + c2.redF() *
r2,
103 c1.greenF() *
r1 + c2.greenF() *
r2,
104 c1.blueF() *
r1 + c2.blueF() *
r2);
109 const qreal dr = c1.redF() - c2.redF();
110 const qreal dg = c1.greenF() - c2.greenF();
111 const qreal db = c1.blueF() - c2.blueF();
113 return std::sqrt(2 *
pow2(dr) + 4 *
pow2(dg) + 3 *
pow2(db));
116void dragColor(QColor *color,
const QColor &baseColor, qreal threshold)
120 QColor newColor = *color;
122 if (newColor.lightnessF() > baseColor.lightnessF()) {
123 newColor = newColor.lighter(120);
125 newColor = newColor.darker(120);
128 if (newColor == *color) {
171 qreal g = c.greenF();
184 qreal lumi = (r * .2126) + (g * .7152) + (b * .0722);
185 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) ...
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)
static QMap< qreal, qreal > sRgbTRCToLinear