QTfrontend/bgwidget.cpp
changeset 2069 f7fad4ad4455
parent 2012 76fff564246b
child 2071 0faa147c47df
equal deleted inserted replaced
2068:9d683de175d7 2069:f7fad4ad4455
    78 
    78 
    79 		QPoint translate(sprite.width()/2, sprite.height()/2);
    79 		QPoint translate(sprite.width()/2, sprite.height()/2);
    80 
    80 
    81 		QPainter p;
    81 		QPainter p;
    82 		p.begin(rotatedSprites[i]);
    82 		p.begin(rotatedSprites[i]);
    83 		p.setRenderHint(QPainter::Antialiasing);
    83 	//	p.setRenderHint(QPainter::Antialiasing);
    84 		p.setRenderHint(QPainter::SmoothPixmapTransform);
    84 		p.setRenderHint(QPainter::SmoothPixmapTransform);
    85 		p.translate(translate.x(), translate.y());
    85 		p.translate(translate.x(), translate.y());
    86 		p.rotate(i);
    86 		p.rotate(i);
    87 		p.translate(-1*translate.x(), -1*translate.y());
    87 		p.translate(-1*translate.x(), -1*translate.y());
    88 		p.drawImage(0, 0, sprite);
    88 		p.drawImage(0, 0, sprite);
    89 
       
    90 	}
    89 	}
    91 
    90 
    92 	timerAnimation = new QTimer();
    91 	timerAnimation = new QTimer();
    93 	connect(timerAnimation, SIGNAL(timeout()), this, SLOT(animate()));
    92 	connect(timerAnimation, SIGNAL(timeout()), this, SLOT(animate()));
    94 	timerAnimation->setInterval(ANIMATION_INTERVAL);
    93 	timerAnimation->setInterval(ANIMATION_INTERVAL);
   114 	p.end();
   113 	p.end();
   115 }
   114 }
   116 
   115 
   117 void BGWidget::animate()
   116 void BGWidget::animate()
   118 {
   117 {
   119 	repaint();
       
   120 	for (int i = 0; i < SPRITE_MAX; i++)
   118 	for (int i = 0; i < SPRITE_MAX; i++)
   121 	{
   119 	{
       
   120         // bottom edge of star *seems* clipped, but in fact, if I switch to just plain old repaint()/update() it is still clipped - artifact of transform?  As for 5, is arbitrary number. 4 was noticeably clipping, 5 seemed same as update() - I assume extra room is due to rotation and value really should be calculated proportional to width/height
       
   121         update(spritePositions[i]->pos().x(),spritePositions[i]->pos().y(), sprite.width()+5, sprite.height()+5);
   122 		spritePositions[i]->move();
   122 		spritePositions[i]->move();
   123 	}
   123 	}
   124 }
   124 }
   125 
   125 
   126 void BGWidget::startAnimation()
   126 void BGWidget::startAnimation()