| 235 | } |
| 236 | |
| 237 | QColor 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 | |
| 267 | QColor Rainbow::mix(const QColor& c1, const QColor& c2, qreal bias) |
| 268 | { |
nothing calls this directly
no test coverage detected