MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / tint

Method tint

libraries/rainbow/src/rainbow.cpp:237–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237QColor Rainbow::tint(const QColor& base, const QColor& color, qreal amount)
238{
239 if (amount <= 0.0) {
240 return base;
241 }
242 if (amount >= 1.0) {
243 return color;
244 }
245 if (qIsNaN(amount)) {
246 return base;
247 }
248
249 qreal baseLuma = luma(base); // cache value because luma call is expensive
250 double ri = contrastRatioForLuma(baseLuma, luma(color));
251 double rg = 1.0 + ((ri + 1.0) * amount * amount * amount);
252 double u = 1.0, l = 0.0;
253 QColor result;
254 for (int i = 12; i; --i) {
255 double a = 0.5 * (l + u);
256 result = tintHelper(base, baseLuma, color, a);
257 double ra = contrastRatioForLuma(baseLuma, luma(result));
258 if (ra > rg) {
259 u = a;
260 } else {
261 l = a;
262 }
263 }
264 return result;
265}
266
267QColor Rainbow::mix(const QColor& c1, const QColor& c2, qreal bias)
268{

Callers

nothing calls this directly

Calls 2

contrastRatioForLumaFunction · 0.85
tintHelperFunction · 0.85

Tested by

no test coverage detected