digiKam
Digikam::ColorTools Namespace Reference

Functions

qreal contrastRatio (const QColor &c1, const QColor &c2)
 
QColor darken (const QColor &color, qreal ky=0.5, qreal kc=1.0)
 
void getHcy (const QColor &color, qreal *h, qreal *c, qreal *y, qreal *a=nullptr)
 
QColor lighten (const QColor &color, qreal ky=0.5, qreal kc=1.0)
 
qreal luma (const QColor &color)
 
QColor mix (const QColor &c1, const QColor &c2, qreal bias)
 
QColor overlayColors (const QColor &base, const QColor &paint, QPainter::CompositionMode comp)
 
QColor shade (const QColor &color, qreal ky, qreal kc=0.0)
 
QColor tint (const QColor &base, const QColor &color, qreal amount=0.3)
 

Function Documentation

◆ contrastRatio()

qreal Digikam::ColorTools::contrastRatio ( const QColor &  c1,
const QColor &  c2 
)

References luma().

◆ darken()

QColor Digikam::ColorTools::darken ( const QColor &  color,
qreal  ky = 0.5,
qreal  kc = 1.0 
)

Adjust the luma of a color by changing its distance from black.

Referenced by Digikam::SchemeManager::shade().

◆ getHcy()

void Digikam::ColorTools::getHcy ( const QColor &  color,
qreal *  h,
qreal *  c,
qreal *  y,
qreal *  a = nullptr 
)

Calculate hue, chroma and luma of a color in one call.

◆ lighten()

QColor Digikam::ColorTools::lighten ( const QColor &  color,
qreal  ky = 0.5,
qreal  kc = 1.0 
)

Adjust the luma of a color by changing its distance from white.

◆ luma()

qreal Digikam::ColorTools::luma ( const QColor &  color)

Calculate the luma of a color. Luma is weighted sum of gamma-adjusted R'G'B' components of a color. The result is similar to qGray. The range is from 0.0 (black) to 1.0 (white).

Referenced by contrastRatio(), Digikam::SchemeManager::shade(), and tint().

◆ mix()

QColor Digikam::ColorTools::mix ( const QColor &  c1,
const QColor &  c2,
qreal  bias 
)

Blend two colors into a new color by linear combination.

◆ overlayColors()

QColor Digikam::ColorTools::overlayColors ( const QColor &  base,
const QColor &  paint,
QPainter::CompositionMode  comp 
)

Blend two colors into a new color by painting the second color over the first using the specified composition mode.

Parameters
basethe base color (alpha channel is ignored).
paintthe color to be overlayed onto the base color.
compthe CompositionMode used to do the blending.

◆ shade()

QColor Digikam::ColorTools::shade ( const QColor &  color,
qreal  ky,
qreal  kc = 0.0 
)

Adjust the luma and chroma components of a color. The amount is added to the corresponding component.

Referenced by Digikam::SchemeManager::shade().

◆ tint()

QColor Digikam::ColorTools::tint ( const QColor &  base,
const QColor &  color,
qreal  amount = 0.3 
)

Create a new color by tinting one color with another. This function is meant for creating additional colors withings the same class (background, foreground) from colors in a different class. Therefore when amount is low, the luma of base is mostly preserved, while the hue and chroma of color is mostly inherited.

Parameters
basecolor to be tinted
colorthe color with which to tint
amounthow strongly to tint the base; 0.0 gives base, 1.0 gives color

References luma().