1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| void CCBackground::paint(QPainter * paint, const QStyleOptionGraphicsItem *, QWidget * widget)
{
QTime time;
time.restart();
unsigned int targetZoom=getTargetZoom(widget);
if(zoom!=targetZoom)
{
//std::cout << "new zoom: " << targetZoom << " with " << width() << "*" << height() << std::endl;
cloud=QPixmap(":/cloud.png");
if(cloud.isNull())
abort();
grass=QPixmap(":/grass.png");
if(grass.isNull())
abort();
sun=QPixmap(":/sun.png");
if(sun.isNull())
abort();
treeback=QPixmap(":/treeback.png");
if(treeback.isNull())
abort();
treefront=QPixmap(":/treefront.png");
if(treefront.isNull())
abort();
if(targetZoom>1)
{
scalePix(cloud,targetZoom);
scalePix(grass,targetZoom);
scalePix(sun,targetZoom);
scalePix(treeback,targetZoom);
scalePix(treefront,targetZoom);
}
grassMove=rand()%grass.width()*targetZoom;
treebackMove=rand()%treeback.width()*targetZoom;
treefrontMove=rand()%treefront.width()*targetZoom;
zoom=targetZoom;
} |
Partager