Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void KoShapeShadow::paint(KoShape *shape, QPainter &painter, const KoViewConverter &converter)
- {
- if (! d->visible)
- return;
- // calculate the shadow offset independent of shape transformation
- QTransform tm;
- tm.translate(d->offset.x(), d->offset.y());
- QTransform tr = shape->absoluteTransformation(&converter);
- QTransform offsetMatrix = tr * tm * tr.inverted();
- QImage img = new QImage();
- QPainter p = new QPainter(img);
- if (shape->background()) {
- p.save();
- KoShape::applyConversion(p, converter);
- // the shadow direction is independent of the shapes transformation
- // please only change if you know what you are doing
- p.setTransform(offsetMatrix * p.transform());
- p.setBrush(QBrush(d->color));
- QPainterPath path(shape->outline());
- KoPathShape * pathShape = dynamic_cast<KoPathShape*>(shape);
- if (pathShape)
- path.setFillRule(pathShape->fillRule());
- p.drawPath(path);
- p.restore();
- }
- if (shape->border()) {
- QTransform oldPainterMatrix = p.transform();
- KoShape::applyConversion(p, converter);
- QTransform newPainterMatrix = p.transform();
- // the shadow direction is independent of the shapes transformation
- // please only change if you know what you are doing
- p.setTransform(offsetMatrix * p.transform());
- // compensate applyConversion call in paint
- QTransform scaleMatrix = newPainterMatrix * oldPainterMatrix.inverted();
- p.setTransform(scaleMatrix.inverted() * p.transform());
- shape->border()->paint(shape, p, converter, d->color);
- }
- fastBlurAlpha(img, 5);
- const QPoint point = new QPoint(0, 0);
- painter.drawImage(point, img);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement