| 289 | } |
| 290 | |
| 291 | QColor Rainbow::tint(const QColor &base, const QColor &color, qreal amount) |
| 292 | { |
| 293 | if (amount <= 0.0) |
| 294 | { |
| 295 | return base; |
| 296 | } |
| 297 | if (amount >= 1.0) |
| 298 | { |
| 299 | return color; |
| 300 | } |
| 301 | if (qIsNaN(amount)) |
| 302 | { |
| 303 | return base; |
| 304 | } |
| 305 | |
| 306 | qreal baseLuma = luma(base); // cache value because luma call is expensive |
| 307 | double ri = contrastRatioForLuma(baseLuma, luma(color)); |
| 308 | double rg = 1.0 + ((ri + 1.0) * amount * amount * amount); |
| 309 | double u = 1.0, l = 0.0; |
| 310 | QColor result; |
| 311 | for (int i = 12; i; --i) |
| 312 | { |
| 313 | double a = 0.5 * (l + u); |
| 314 | result = tintHelper(base, baseLuma, color, a); |
| 315 | double ra = contrastRatioForLuma(baseLuma, luma(result)); |
| 316 | if (ra > rg) |
| 317 | { |
| 318 | u = a; |
| 319 | } |
| 320 | else |
| 321 | { |
| 322 | l = a; |
| 323 | } |
| 324 | } |
| 325 | return result; |
| 326 | } |
| 327 | |
| 328 | QColor Rainbow::mix(const QColor &c1, const QColor &c2, qreal bias) |
| 329 | { |
nothing calls this directly
no test coverage detected