16,240
社区成员
发帖
与我相关
我的任务
分享
void folding::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.fillRect(rect(), Qt::black);
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.drawPixmap(0, 0, m_pixmap);
int index = m_animator.currentFrame();
if(index>=99)
return;
if(direct==Left)
{
QPoint mouse_pos=QPoint(800-index*8,600-60*index/10);
QPainterPath path1;
QPainterPath path2;
QPainterPath path3;
/* Draw region 1 */
painter.save ();
path1.moveTo(0,600);
path1.lineTo(mouse_pos.x(), 600);
path1.lineTo(800, mouse_pos.y());
path1.lineTo(800,0);
path1.lineTo(0,0);
path1.closeSubpath();
painter.setClipPath (path1);
painter.drawPixmap (0,0, m_lastPixmap);
painter.restore();
/*Draw region 2*/
painter.save();
path2.moveTo(mouse_pos.x(), 600);
path2.lineTo(800, mouse_pos.y());
path2.lineTo(800, 600);
path2.closeSubpath ();
painter.setClipPath (path2);
painter.drawPixmap (0,0,m_pixmap);
painter.restore();
/* Draw region 3 */
path3.moveTo(mouse_pos.x(), 600);
path3.cubicTo(mouse_pos.x(), 600, mouse_pos.x()+9*index/5,(mouse_pos.y()+600)/2, mouse_pos.x(), mouse_pos.y());
path3.cubicTo(mouse_pos.x(), mouse_pos.y(), (mouse_pos.x()+800)/2, mouse_pos.y()+7*index/5, 800, mouse_pos.y());
path3.closeSubpath();
// painter.setBrush(QBrush(QColor(0xF0,0xF8,0xFF)));
// painter.setOpacity(0.9);
painter.setBrush(QBrush(QImage(":/images/image/0.png")));
painter.drawPath(path3);
}
else if(direct==Right)
{
QPoint mouse_pos=QPoint(index*8,600-42*index/10);
QPainterPath path1;
QPainterPath path2;
QPainterPath path3;
/* Draw region 1 */
painter.save ();
path1.moveTo(800,600);
path1.lineTo(mouse_pos.x(), 600);
path1.lineTo(0, mouse_pos.y());
path1.lineTo(0,0);
path1.lineTo(800,0);
path1.closeSubpath();
painter.setClipPath (path1);
painter.drawPixmap (0,0, m_lastPixmap);
painter.restore();
/*Draw region 2*/
painter.save();
path2.moveTo(mouse_pos.x(), 600);
path2.lineTo(0, mouse_pos.y());
path2.lineTo(0, 600);
path2.closeSubpath ();
painter.setClipPath (path2);
painter.drawPixmap (0,0,m_pixmap);
painter.restore();
/* Draw region 3 */
path3.moveTo(mouse_pos.x(), 600);
path3.cubicTo(mouse_pos.x(), 600, mouse_pos.x()-9*index/5,(mouse_pos.y()+600)/2, mouse_pos.x(), mouse_pos.y());
path3.cubicTo(mouse_pos.x(), mouse_pos.y(), (mouse_pos.x())/2, mouse_pos.y()+7*index/5, 0, mouse_pos.y());
path3.closeSubpath();
// painter.setBrush(QBrush(QColor(0xF0,0xF8,0xFF)));
// painter.setOpacity(0.9);
painter.setBrush(QBrush(QImage(":/images/image/0.png")));
painter.drawPath(path3);
}
}