Android : Fast animation for showing semi-transparent circle

on Sunday, August 3, 2014


I'm developing a simple test app with Qt for Android. I'm trying to animate every user touch on the screen by showing semi-transparent circle, that increases its radius from 0 to 100 for example.


I added a custom QLabel on top of all widgets. And I'm trying to animate the its QPixmap by updating it with QPropertyAnimation for custom property



Q_PROPERTY(QRect circleGeometry READ getCircleGeometry WRITE setCircleGeometry)


The setter is:



void CircleLabel::setCircleGeometry(QRect circleGeometry)
{
QPixmap pixmap(this->size());
pixmap.fill(Qt::transparent);

QPainter painter(&pixmap);
painter.setOpacity(0.2);
painter.setPen(QPen(Qt::transparent));
painter.setBrush(QBrush(Qt::white));
painter.setRenderHint(QPainter::Antialiasing);

painter.drawEllipse(circleGeometry);

this->setPixmap(pixmap);
}


I see, that the setter is too heavy for the animation, so it runs slow on my android device. Could you please advice me how can I modify my animation to make it fast and smooth.


0 comments:

Post a Comment