| 349 | } |
| 350 | |
| 351 | QColor Rainbow::overlayColors(const QColor &base, const QColor &paint, |
| 352 | QPainter::CompositionMode comp) |
| 353 | { |
| 354 | // This isn't the fastest way, but should be "fast enough". |
| 355 | // It's also the only safe way to use QPainter::CompositionMode |
| 356 | QImage img(1, 1, QImage::Format_ARGB32_Premultiplied); |
| 357 | QPainter p(&img); |
| 358 | QColor start = base; |
| 359 | start.setAlpha(255); // opaque |
| 360 | p.fillRect(0, 0, 1, 1, start); |
| 361 | p.setCompositionMode(comp); |
| 362 | p.fillRect(0, 0, 1, 1, paint); |
| 363 | p.end(); |
| 364 | return img.pixel(0, 0); |
| 365 | } |