示例#1
0
  private static QImage makeShade(QImage image, boolean highlight, boolean darker) {
    double shade_alpha = 0.8;
    double shade_size = 0.2;
    double hl_pos = GOLDEN_MEAN;

    QColor shade_color = QColor.fromRgbF(0, 0, 0, shade_alpha);
    QColor transparent = darker ? QColor.fromRgbF(0, 0, 0, 0.25) : QColor.fromRgbF(0, 0, 0, 0);
    QColor hl_color = QColor.fromRgbF(1, 1, 1, 0.7);

    image = image.copy();
    QPainter p = new QPainter();
    p.begin(image);
    p.scale(image.width(), image.height());

    QLinearGradient lg = new QLinearGradient(0, 0, 1, 0);
    lg.setColorAt(0, shade_color);
    lg.setColorAt(shade_size, transparent);
    if (highlight) lg.setColorAt(hl_pos, hl_color);
    lg.setColorAt(1 - shade_size, transparent);
    lg.setColorAt(1, shade_color);
    p.fillRect(0, 0, 1, 1, new QBrush(lg));

    if (highlight) {
      QRadialGradient rg = new QRadialGradient(hl_pos, 1 - hl_pos, 0.4, hl_pos, 1 - hl_pos);
      rg.setColorAt(0, hl_color);
      rg.setColorAt(1, transparent);
      p.fillRect(0, 0, 1, 1, new QBrush(rg));
    }

    p.end();

    return image;
  }
示例#2
0
  @Override
  protected void paintEvent(QPaintEvent e) {
    m_smoke_effect.next();

    QPainter p = new QPainter();
    p.begin(this);
    p.fillRect(rect(), new QBrush(QColor.white));
    //  p.fillRect(rect(), new QBrush(Qt.CrossPattern));

    p.drawImage(50, 80, m_logo);

    p.setRenderHint(QPainter.RenderHint.SmoothPixmapTransform);
    QImage im = m_smoke_effect.image();
    p.drawImage(
        new QRect(50, -20, im.width(), im.height()),
        im,
        new QRect(0, (int) (im.height() * 0.60), im.width(), (int) (im.height() * 0.39)));

    p.end();
  }