Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.79 KB | None | 0 0
  1. void KoShapeShadow::paint(KoShape *shape, QPainter &painter, const KoViewConverter &converter)
  2. {
  3.     if (! d->visible)
  4.         return;
  5.  
  6.     // calculate the shadow offset independent of shape transformation
  7.     QTransform tm;
  8.     tm.translate(d->offset.x(), d->offset.y());
  9.     QTransform tr = shape->absoluteTransformation(&converter);
  10.     QTransform offsetMatrix = tr * tm * tr.inverted();
  11.     QImage img = new QImage();
  12.     QPainter p = new QPainter(img);
  13.     if (shape->background()) {
  14.         p.save();
  15.  
  16.         KoShape::applyConversion(p, converter);
  17.  
  18.         // the shadow direction is independent of the shapes transformation
  19.         // please only change if you know what you are doing
  20.         p.setTransform(offsetMatrix * p.transform());
  21.         p.setBrush(QBrush(d->color));
  22.  
  23.         QPainterPath path(shape->outline());
  24.         KoPathShape * pathShape = dynamic_cast<KoPathShape*>(shape);
  25.         if (pathShape)
  26.             path.setFillRule(pathShape->fillRule());
  27.         p.drawPath(path);
  28.         p.restore();
  29.     }
  30.  
  31.     if (shape->border()) {
  32.         QTransform oldPainterMatrix = p.transform();
  33.         KoShape::applyConversion(p, converter);
  34.         QTransform newPainterMatrix = p.transform();
  35.  
  36.         // the shadow direction is independent of the shapes transformation
  37.         // please only change if you know what you are doing
  38.         p.setTransform(offsetMatrix * p.transform());
  39.  
  40.         // compensate applyConversion call in paint
  41.         QTransform scaleMatrix = newPainterMatrix * oldPainterMatrix.inverted();
  42.         p.setTransform(scaleMatrix.inverted() * p.transform());
  43.  
  44.         shape->border()->paint(shape, p, converter, d->color);
  45.     }
  46.  
  47.     fastBlurAlpha(img, 5);
  48.     const QPoint point = new QPoint(0, 0);
  49.     painter.drawImage(point, img);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement